@kaizen/components 3.2.0 → 3.3.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/dist/cjs/src/Avatar/Avatar.cjs +18 -14
- package/dist/cjs/src/Focusable/Focusable.cjs +5 -4
- package/dist/cjs/src/MultiSelect/MultiSelect.cjs +4 -2
- package/dist/cjs/src/RichTextEditor/RichTextEditor/RichTextEditor.cjs +4 -1
- package/dist/cjs/src/RichTextEditor/RichTextEditor/utils/inputrules.cjs +0 -1
- package/dist/cjs/src/RichTextEditor/utils/core/createRichTextEditor.cjs +2 -1
- package/dist/cjs/src/RichTextEditor/utils/core/hooks/useRichTextEditor.cjs +24 -9
- package/dist/cjs/src/SingleSelect/SingleSelect.cjs +4 -2
- package/dist/esm/src/Avatar/Avatar.mjs +18 -15
- package/dist/esm/src/Focusable/Focusable.mjs +5 -4
- package/dist/esm/src/MultiSelect/MultiSelect.mjs +4 -2
- package/dist/esm/src/RichTextEditor/RichTextEditor/RichTextEditor.mjs +4 -1
- package/dist/esm/src/RichTextEditor/RichTextEditor/utils/inputrules.mjs +0 -1
- package/dist/esm/src/RichTextEditor/utils/core/createRichTextEditor.mjs +2 -1
- package/dist/esm/src/RichTextEditor/utils/core/hooks/useRichTextEditor.mjs +24 -9
- package/dist/esm/src/SingleSelect/SingleSelect.mjs +4 -2
- package/dist/styles.css +15 -15
- package/dist/types/Focusable/Focusable.d.ts +8 -3
- package/dist/types/MultiSelect/MultiSelect.d.ts +3 -2
- package/dist/types/Notification/index.d.ts +1 -0
- package/dist/types/RichTextEditor/RichTextEditor/RichTextEditor.d.ts +2 -1
- package/dist/types/RichTextEditor/utils/core/createRichTextEditor.d.ts +1 -0
- package/dist/types/RichTextEditor/utils/core/hooks/useRichTextEditor.d.ts +3 -2
- package/dist/types/SingleSelect/SingleSelect.d.ts +3 -3
- package/package.json +1 -1
- package/src/Avatar/Avatar.tsx +19 -11
- package/src/Focusable/Focusable.tsx +17 -7
- package/src/MultiSelect/MultiSelect.tsx +4 -1
- package/src/Notification/index.ts +1 -0
- package/src/RichTextEditor/RichTextEditor/RichTextEditor.tsx +3 -0
- package/src/RichTextEditor/utils/core/createRichTextEditor.spec.ts +1 -1
- package/src/RichTextEditor/utils/core/createRichTextEditor.ts +2 -0
- package/src/RichTextEditor/utils/core/hooks/useRichTextEditor.spec.tsx +8 -3
- package/src/RichTextEditor/utils/core/hooks/useRichTextEditor.ts +20 -7
- package/src/SingleSelect/SingleSelect.tsx +5 -3
|
@@ -54,21 +54,25 @@ var renderInitials = function (fullName, alt, size, disableInitials) {
|
|
|
54
54
|
var initials = getInitials(fullName);
|
|
55
55
|
var isLongName = initials.length > 2 && size !== 'small';
|
|
56
56
|
var renderFallback = disableInitials || initials === '';
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
if (renderFallback) {
|
|
58
|
+
return React__default.default.createElement(FallbackIcon, {
|
|
59
|
+
alt: alt
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (isLongName) {
|
|
63
|
+
return React__default.default.createElement("abbr", {
|
|
64
|
+
className: classnames__default.default(Avatar_module.initials, Avatar_module.longName),
|
|
65
|
+
title: alt,
|
|
66
|
+
"data-chromatic": "ignore"
|
|
67
|
+
}, React__default.default.createElement(reactTextfit.Textfit, {
|
|
68
|
+
mode: "single",
|
|
69
|
+
max: getMaxFontSizePixels(size)
|
|
70
|
+
}, initials));
|
|
71
|
+
}
|
|
72
|
+
return React__default.default.createElement("abbr", {
|
|
73
|
+
className: Avatar_module.initials,
|
|
61
74
|
title: alt
|
|
62
|
-
},
|
|
63
|
-
// Only called if 3 or more initials, fits text width for long names
|
|
64
|
-
//
|
|
65
|
-
// Ignore Chromatic diffs since the font-size calculation has shown itself to be slightly non-deterministic,
|
|
66
|
-
// causing flaky tests.
|
|
67
|
-
React__default.default.createElement(reactTextfit.Textfit, {
|
|
68
|
-
mode: "single",
|
|
69
|
-
max: getMaxFontSizePixels(size),
|
|
70
|
-
"data-chromatic": "ignore"
|
|
71
|
-
}, initials) : getInitials(fullName, size === 'small'));
|
|
75
|
+
}, getInitials(fullName, size === 'small'));
|
|
72
76
|
};
|
|
73
77
|
/**
|
|
74
78
|
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3064857475/Avatar Guidance} |
|
|
@@ -15,17 +15,18 @@ var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
|
15
15
|
var Focusable = function (_a) {
|
|
16
16
|
var children = _a.children,
|
|
17
17
|
className = _a.className,
|
|
18
|
-
|
|
18
|
+
tag = _a.tag,
|
|
19
|
+
props = tslib.__rest(_a, ["children", "className", "tag"]);
|
|
19
20
|
var ref = React.useRef(null);
|
|
20
21
|
var focusableProps = reactAria.useFocusable(props, ref).focusableProps;
|
|
21
|
-
|
|
22
|
+
var Element = tag !== null && tag !== void 0 ? tag : 'div';
|
|
23
|
+
return React__default.default.createElement(Element, tslib.__assign({
|
|
22
24
|
ref: ref,
|
|
23
25
|
className: classnames__default.default(Focusable_module.focusableWrapper, className)
|
|
24
26
|
}, focusableProps, {
|
|
25
27
|
"data-inline-hidden-content": true,
|
|
26
|
-
// We want the
|
|
28
|
+
// We want the element to be focusable for keyboard users,
|
|
27
29
|
// but screen readers will have the VisuallyHidden content
|
|
28
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
29
30
|
tabIndex: 0,
|
|
30
31
|
"aria-describedby": undefined
|
|
31
32
|
}, props), children);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var utils = require('@react-aria/utils');
|
|
5
6
|
var classnames = require('classnames');
|
|
6
7
|
var FieldMessage = require('../FieldMessage/FieldMessage.cjs');
|
|
7
8
|
var Heading = require('../Heading/Heading.cjs');
|
|
@@ -28,7 +29,8 @@ var MultiSelect = function (_a) {
|
|
|
28
29
|
onOpenChange = _a.onOpenChange,
|
|
29
30
|
classNameOverride = _a.classNameOverride,
|
|
30
31
|
validationMessage = _a.validationMessage,
|
|
31
|
-
|
|
32
|
+
inputRef = _a.inputRef,
|
|
33
|
+
restProps = tslib.__rest(_a, ["id", "label", "items", "selectedValues", "description", "onSelectedValuesChange", "isOpen", "onOpenChange", "classNameOverride", "validationMessage", "inputRef"]);
|
|
32
34
|
var fallbackId = React.useId();
|
|
33
35
|
var id = propsId !== null && propsId !== void 0 ? propsId : fallbackId;
|
|
34
36
|
var descriptionId = "".concat(id, "-description");
|
|
@@ -73,7 +75,7 @@ var MultiSelect = function (_a) {
|
|
|
73
75
|
ref: refs.setReference,
|
|
74
76
|
className: MultiSelect_module.toggleContainer
|
|
75
77
|
}, React__default.default.createElement(MultiSelectToggle.MultiSelectToggle, {
|
|
76
|
-
ref: toggleButtonRef,
|
|
78
|
+
ref: utils.mergeRefs(toggleButtonRef, inputRef),
|
|
77
79
|
id: "".concat(id, "--toggle"),
|
|
78
80
|
"aria-labelledby": "".concat(id, "--label"),
|
|
79
81
|
"aria-describedby": "".concat(validationId, " ").concat(descriptionId),
|
|
@@ -66,6 +66,7 @@ var ProseMirrorHistory__namespace = /*#__PURE__*/_interopNamespace(ProseMirrorHi
|
|
|
66
66
|
*/
|
|
67
67
|
var RichTextEditor = function (_a) {
|
|
68
68
|
var id = _a.id,
|
|
69
|
+
inputRef = _a.inputRef,
|
|
69
70
|
onChange = _a.onChange,
|
|
70
71
|
defaultValue = _a.defaultValue,
|
|
71
72
|
labelText = _a.labelText,
|
|
@@ -81,7 +82,7 @@ var RichTextEditor = function (_a) {
|
|
|
81
82
|
description = _a.description,
|
|
82
83
|
_c = _a.status,
|
|
83
84
|
status = _c === void 0 ? 'default' : _c,
|
|
84
|
-
restProps = tslib.__rest(_a, ["id", "onChange", "defaultValue", "labelText", 'aria-labelledby', 'aria-describedby', "classNameOverride", "controls", "rows", "dataError", "onDataError", "validationMessage", "description", "status"]);
|
|
85
|
+
restProps = tslib.__rest(_a, ["id", "inputRef", "onChange", "defaultValue", "labelText", 'aria-labelledby', 'aria-describedby', "classNameOverride", "controls", "rows", "dataError", "onDataError", "validationMessage", "description", "status"]);
|
|
85
86
|
var generatedId = React.useId();
|
|
86
87
|
var schema$1 = React.useState(schema.createSchemaFromControls(controls))[0];
|
|
87
88
|
var editorId = id !== null && id !== void 0 ? id : generatedId;
|
|
@@ -108,6 +109,8 @@ var RichTextEditor = function (_a) {
|
|
|
108
109
|
'aria-labelledby': labelId,
|
|
109
110
|
'role': 'textbox',
|
|
110
111
|
'aria-describedby': ariaDescribedBy
|
|
112
|
+
}, {
|
|
113
|
+
inputRef: inputRef
|
|
111
114
|
});
|
|
112
115
|
} catch (_a) {
|
|
113
116
|
return new Error('Bad data error');
|
|
@@ -47,7 +47,8 @@ var createRichTextEditor = function (_a) {
|
|
|
47
47
|
destroy: function () {
|
|
48
48
|
return editorView.destroy();
|
|
49
49
|
},
|
|
50
|
-
dispatchTransaction: dispatchCommandOrTransaction
|
|
50
|
+
dispatchTransaction: dispatchCommandOrTransaction,
|
|
51
|
+
dom: editorView.dom
|
|
51
52
|
};
|
|
52
53
|
};
|
|
53
54
|
exports.createRichTextEditor = createRichTextEditor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib = require('tslib');
|
|
4
3
|
var React = require('react');
|
|
4
|
+
var isRefObject = require('../../../../utils/isRefObject.cjs');
|
|
5
5
|
var createRichTextEditor = require('../createRichTextEditor.cjs');
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -16,13 +16,14 @@ var useRichTextEditor = function (initialEditorState,
|
|
|
16
16
|
/*
|
|
17
17
|
* Pass in HTML attributes into the parent RTE node
|
|
18
18
|
*/
|
|
19
|
-
attributes,
|
|
20
|
-
|
|
21
|
-
editable
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
attributes, _a) {
|
|
20
|
+
var _b = _a === void 0 ? {} : _a,
|
|
21
|
+
_c = _b.editable,
|
|
22
|
+
editable = _c === void 0 ? true : _c,
|
|
23
|
+
inputRef = _b.inputRef;
|
|
24
|
+
var _d = React.useState(initialEditorState),
|
|
25
|
+
editorState = _d[0],
|
|
26
|
+
setEditorState = _d[1];
|
|
26
27
|
// Refs to hold the methods returned from ProseMirror’s initialization
|
|
27
28
|
var destroyEditorRef = React.useRef();
|
|
28
29
|
var dispatchTransactionRef = React.useRef(function () {
|
|
@@ -34,7 +35,10 @@ attributes, options) {
|
|
|
34
35
|
dispatchTransactionRef.current(commandOrTransaction);
|
|
35
36
|
}, [dispatchTransactionRef]);
|
|
36
37
|
// Hold editableStatus as a ref so we can toggle its status
|
|
37
|
-
var editableStatusRef = React.useRef(
|
|
38
|
+
var editableStatusRef = React.useRef(editable);
|
|
39
|
+
// Stable ref to avoid recreating editorRef when inputRef callback identity changes
|
|
40
|
+
var inputRefRef = React.useRef(inputRef);
|
|
41
|
+
inputRefRef.current = inputRef;
|
|
38
42
|
var setEditableStatus = React.useCallback(function (status) {
|
|
39
43
|
editableStatusRef.current = status;
|
|
40
44
|
// Trigger an update within ProseMirror by issuing a noop transaction
|
|
@@ -48,11 +52,17 @@ attributes, options) {
|
|
|
48
52
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
53
|
[editableStatusRef]);
|
|
50
54
|
var editorRef = React.useCallback(function (node) {
|
|
55
|
+
var _a, _b;
|
|
51
56
|
if (node === null) {
|
|
52
57
|
if (destroyEditorRef.current) {
|
|
53
58
|
destroyEditorRef.current();
|
|
54
59
|
destroyEditorRef.current = undefined;
|
|
55
60
|
}
|
|
61
|
+
if (inputRefRef.current && isRefObject.isRefObject(inputRefRef.current)) {
|
|
62
|
+
inputRefRef.current.current = null;
|
|
63
|
+
} else {
|
|
64
|
+
(_a = inputRefRef.current) === null || _a === void 0 ? void 0 : _a.call(inputRefRef, null);
|
|
65
|
+
}
|
|
56
66
|
return;
|
|
57
67
|
}
|
|
58
68
|
var instance = createRichTextEditor.createRichTextEditor({
|
|
@@ -66,6 +76,11 @@ attributes, options) {
|
|
|
66
76
|
});
|
|
67
77
|
destroyEditorRef.current = instance.destroy;
|
|
68
78
|
dispatchTransactionRef.current = instance.dispatchTransaction;
|
|
79
|
+
if (inputRefRef.current && isRefObject.isRefObject(inputRefRef.current)) {
|
|
80
|
+
inputRefRef.current.current = instance.dom;
|
|
81
|
+
} else {
|
|
82
|
+
(_b = inputRefRef.current) === null || _b === void 0 ? void 0 : _b.call(inputRefRef, instance.dom);
|
|
83
|
+
}
|
|
69
84
|
},
|
|
70
85
|
// Including editorState in the dependencies here will cause an endless
|
|
71
86
|
// loop as the initialization changes its value
|
|
@@ -4,6 +4,7 @@ var tslib = require('tslib');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var button = require('@react-aria/button');
|
|
6
6
|
var select$1 = require('@react-aria/select');
|
|
7
|
+
var utils = require('@react-aria/utils');
|
|
7
8
|
var select = require('@react-stately/select');
|
|
8
9
|
var classnames = require('classnames');
|
|
9
10
|
var FieldMessage = require('../FieldMessage/FieldMessage.cjs');
|
|
@@ -53,7 +54,8 @@ var SingleSelect = function (_a) {
|
|
|
53
54
|
isDisabled = _a.isDisabled,
|
|
54
55
|
onSelectionChange = _a.onSelectionChange,
|
|
55
56
|
portalContainerId = _a.portalContainerId,
|
|
56
|
-
|
|
57
|
+
inputRef = _a.inputRef,
|
|
58
|
+
restProps = tslib.__rest(_a, ["label", "items", "id", "trigger", "children", "status", "validationMessage", "isReversed", "isRequired", "isFullWidth", "classNameOverride", "selectedKey", "description", "isDisabled", "onSelectionChange", "portalContainerId", "inputRef"]);
|
|
57
59
|
var refs = reactDom.useFloating().refs;
|
|
58
60
|
var triggerRef = refs.reference;
|
|
59
61
|
var fallbackId = React.useId();
|
|
@@ -102,7 +104,7 @@ var SingleSelect = function (_a) {
|
|
|
102
104
|
status: status,
|
|
103
105
|
'isDisabled': triggerProps.isDisabled,
|
|
104
106
|
isReversed: isReversed,
|
|
105
|
-
'ref': refs.setReference,
|
|
107
|
+
'ref': utils.mergeRefs(inputRef, refs.setReference),
|
|
106
108
|
'aria-describedby': classnames__default.default(validationMessage && validationId, description && descriptionId),
|
|
107
109
|
'aria-required': isRequired
|
|
108
110
|
});
|
|
@@ -45,22 +45,25 @@ var renderInitials = function (fullName, alt, size, disableInitials) {
|
|
|
45
45
|
var initials = getInitials(fullName);
|
|
46
46
|
var isLongName = initials.length > 2 && size !== 'small';
|
|
47
47
|
var renderFallback = disableInitials || initials === '';
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
if (renderFallback) {
|
|
49
|
+
return /*#__PURE__*/React.createElement(FallbackIcon, {
|
|
50
|
+
alt: alt
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (isLongName) {
|
|
54
|
+
return /*#__PURE__*/React.createElement("abbr", {
|
|
55
|
+
className: classnames(modules_f30548d5.initials, modules_f30548d5.longName),
|
|
56
|
+
title: alt,
|
|
57
|
+
"data-chromatic": "ignore"
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Textfit, {
|
|
59
|
+
mode: "single",
|
|
60
|
+
max: getMaxFontSizePixels(size)
|
|
61
|
+
}, initials));
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/React.createElement("abbr", {
|
|
64
|
+
className: modules_f30548d5.initials,
|
|
52
65
|
title: alt
|
|
53
|
-
},
|
|
54
|
-
/*#__PURE__*/
|
|
55
|
-
// Only called if 3 or more initials, fits text width for long names
|
|
56
|
-
//
|
|
57
|
-
// Ignore Chromatic diffs since the font-size calculation has shown itself to be slightly non-deterministic,
|
|
58
|
-
// causing flaky tests.
|
|
59
|
-
React.createElement(Textfit, {
|
|
60
|
-
mode: "single",
|
|
61
|
-
max: getMaxFontSizePixels(size),
|
|
62
|
-
"data-chromatic": "ignore"
|
|
63
|
-
}, initials)) : getInitials(fullName, size === 'small')));
|
|
66
|
+
}, getInitials(fullName, size === 'small'));
|
|
64
67
|
};
|
|
65
68
|
/**
|
|
66
69
|
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3064857475/Avatar Guidance} |
|
|
@@ -6,17 +6,18 @@ import modules_99c30b46 from './Focusable.module.css.mjs';
|
|
|
6
6
|
var Focusable = function (_a) {
|
|
7
7
|
var children = _a.children,
|
|
8
8
|
className = _a.className,
|
|
9
|
-
|
|
9
|
+
tag = _a.tag,
|
|
10
|
+
props = __rest(_a, ["children", "className", "tag"]);
|
|
10
11
|
var ref = useRef(null);
|
|
11
12
|
var focusableProps = useFocusable(props, ref).focusableProps;
|
|
12
|
-
|
|
13
|
+
var Element = tag !== null && tag !== void 0 ? tag : 'div';
|
|
14
|
+
return /*#__PURE__*/React.createElement(Element, __assign({
|
|
13
15
|
ref: ref,
|
|
14
16
|
className: classnames(modules_99c30b46.focusableWrapper, className)
|
|
15
17
|
}, focusableProps, {
|
|
16
18
|
"data-inline-hidden-content": true,
|
|
17
|
-
// We want the
|
|
19
|
+
// We want the element to be focusable for keyboard users,
|
|
18
20
|
// but screen readers will have the VisuallyHidden content
|
|
19
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
20
21
|
tabIndex: 0,
|
|
21
22
|
"aria-describedby": undefined
|
|
22
23
|
}, props), children);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
2
|
import React, { useId, useRef } from 'react';
|
|
3
|
+
import { mergeRefs } from '@react-aria/utils';
|
|
3
4
|
import classnames from 'classnames';
|
|
4
5
|
import { FieldMessage } from '../FieldMessage/FieldMessage.mjs';
|
|
5
6
|
import { Heading } from '../Heading/Heading.mjs';
|
|
@@ -20,7 +21,8 @@ const MultiSelect = /*#__PURE__*/function () {
|
|
|
20
21
|
onOpenChange = _a.onOpenChange,
|
|
21
22
|
classNameOverride = _a.classNameOverride,
|
|
22
23
|
validationMessage = _a.validationMessage,
|
|
23
|
-
|
|
24
|
+
inputRef = _a.inputRef,
|
|
25
|
+
restProps = __rest(_a, ["id", "label", "items", "selectedValues", "description", "onSelectedValuesChange", "isOpen", "onOpenChange", "classNameOverride", "validationMessage", "inputRef"]);
|
|
24
26
|
var fallbackId = useId();
|
|
25
27
|
var id = propsId !== null && propsId !== void 0 ? propsId : fallbackId;
|
|
26
28
|
var descriptionId = "".concat(id, "-description");
|
|
@@ -65,7 +67,7 @@ const MultiSelect = /*#__PURE__*/function () {
|
|
|
65
67
|
ref: refs.setReference,
|
|
66
68
|
className: modules_66f395c3.toggleContainer
|
|
67
69
|
}, /*#__PURE__*/React.createElement(MultiSelectToggle, {
|
|
68
|
-
ref: toggleButtonRef,
|
|
70
|
+
ref: mergeRefs(toggleButtonRef, inputRef),
|
|
69
71
|
id: "".concat(id, "--toggle"),
|
|
70
72
|
"aria-labelledby": "".concat(id, "--label"),
|
|
71
73
|
"aria-describedby": "".concat(validationId, " ").concat(descriptionId),
|
|
@@ -34,6 +34,7 @@ import modules_75dcabc8 from './RichTextEditor.module.scss.mjs';
|
|
|
34
34
|
const RichTextEditor = /*#__PURE__*/function () {
|
|
35
35
|
const RichTextEditor = function (_a) {
|
|
36
36
|
var id = _a.id,
|
|
37
|
+
inputRef = _a.inputRef,
|
|
37
38
|
onChange = _a.onChange,
|
|
38
39
|
defaultValue = _a.defaultValue,
|
|
39
40
|
labelText = _a.labelText,
|
|
@@ -49,7 +50,7 @@ const RichTextEditor = /*#__PURE__*/function () {
|
|
|
49
50
|
description = _a.description,
|
|
50
51
|
_c = _a.status,
|
|
51
52
|
status = _c === void 0 ? 'default' : _c,
|
|
52
|
-
restProps = __rest(_a, ["id", "onChange", "defaultValue", "labelText", 'aria-labelledby', 'aria-describedby', "classNameOverride", "controls", "rows", "dataError", "onDataError", "validationMessage", "description", "status"]);
|
|
53
|
+
restProps = __rest(_a, ["id", "inputRef", "onChange", "defaultValue", "labelText", 'aria-labelledby', 'aria-describedby', "classNameOverride", "controls", "rows", "dataError", "onDataError", "validationMessage", "description", "status"]);
|
|
53
54
|
var generatedId = useId();
|
|
54
55
|
var schema = useState(createSchemaFromControls(controls))[0];
|
|
55
56
|
var editorId = id !== null && id !== void 0 ? id : generatedId;
|
|
@@ -76,6 +77,8 @@ const RichTextEditor = /*#__PURE__*/function () {
|
|
|
76
77
|
'aria-labelledby': labelId,
|
|
77
78
|
'role': 'textbox',
|
|
78
79
|
'aria-describedby': ariaDescribedBy
|
|
80
|
+
}, {
|
|
81
|
+
inputRef: inputRef
|
|
79
82
|
});
|
|
80
83
|
} catch (_a) {
|
|
81
84
|
return new Error('Bad data error');
|
|
@@ -45,7 +45,8 @@ var createRichTextEditor = function (_a) {
|
|
|
45
45
|
destroy: function () {
|
|
46
46
|
return editorView.destroy();
|
|
47
47
|
},
|
|
48
|
-
dispatchTransaction: dispatchCommandOrTransaction
|
|
48
|
+
dispatchTransaction: dispatchCommandOrTransaction,
|
|
49
|
+
dom: editorView.dom
|
|
49
50
|
};
|
|
50
51
|
};
|
|
51
52
|
export { createRichTextEditor };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __assign } from 'tslib';
|
|
2
1
|
import { useState, useRef, useCallback } from 'react';
|
|
2
|
+
import { isRefObject } from '../../../../utils/isRefObject.mjs';
|
|
3
3
|
import { createRichTextEditor } from '../createRichTextEditor.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -14,13 +14,14 @@ var useRichTextEditor = function (initialEditorState,
|
|
|
14
14
|
/*
|
|
15
15
|
* Pass in HTML attributes into the parent RTE node
|
|
16
16
|
*/
|
|
17
|
-
attributes,
|
|
18
|
-
|
|
19
|
-
editable
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
attributes, _a) {
|
|
18
|
+
var _b = _a === void 0 ? {} : _a,
|
|
19
|
+
_c = _b.editable,
|
|
20
|
+
editable = _c === void 0 ? true : _c,
|
|
21
|
+
inputRef = _b.inputRef;
|
|
22
|
+
var _d = useState(initialEditorState),
|
|
23
|
+
editorState = _d[0],
|
|
24
|
+
setEditorState = _d[1];
|
|
24
25
|
// Refs to hold the methods returned from ProseMirror’s initialization
|
|
25
26
|
var destroyEditorRef = useRef();
|
|
26
27
|
var dispatchTransactionRef = useRef(function () {
|
|
@@ -32,7 +33,10 @@ attributes, options) {
|
|
|
32
33
|
dispatchTransactionRef.current(commandOrTransaction);
|
|
33
34
|
}, [dispatchTransactionRef]);
|
|
34
35
|
// Hold editableStatus as a ref so we can toggle its status
|
|
35
|
-
var editableStatusRef = useRef(
|
|
36
|
+
var editableStatusRef = useRef(editable);
|
|
37
|
+
// Stable ref to avoid recreating editorRef when inputRef callback identity changes
|
|
38
|
+
var inputRefRef = useRef(inputRef);
|
|
39
|
+
inputRefRef.current = inputRef;
|
|
36
40
|
var setEditableStatus = useCallback(function (status) {
|
|
37
41
|
editableStatusRef.current = status;
|
|
38
42
|
// Trigger an update within ProseMirror by issuing a noop transaction
|
|
@@ -46,11 +50,17 @@ attributes, options) {
|
|
|
46
50
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
51
|
[editableStatusRef]);
|
|
48
52
|
var editorRef = useCallback(function (node) {
|
|
53
|
+
var _a, _b;
|
|
49
54
|
if (node === null) {
|
|
50
55
|
if (destroyEditorRef.current) {
|
|
51
56
|
destroyEditorRef.current();
|
|
52
57
|
destroyEditorRef.current = undefined;
|
|
53
58
|
}
|
|
59
|
+
if (inputRefRef.current && isRefObject(inputRefRef.current)) {
|
|
60
|
+
inputRefRef.current.current = null;
|
|
61
|
+
} else {
|
|
62
|
+
(_a = inputRefRef.current) === null || _a === void 0 ? void 0 : _a.call(inputRefRef, null);
|
|
63
|
+
}
|
|
54
64
|
return;
|
|
55
65
|
}
|
|
56
66
|
var instance = createRichTextEditor({
|
|
@@ -64,6 +74,11 @@ attributes, options) {
|
|
|
64
74
|
});
|
|
65
75
|
destroyEditorRef.current = instance.destroy;
|
|
66
76
|
dispatchTransactionRef.current = instance.dispatchTransaction;
|
|
77
|
+
if (inputRefRef.current && isRefObject(inputRefRef.current)) {
|
|
78
|
+
inputRefRef.current.current = instance.dom;
|
|
79
|
+
} else {
|
|
80
|
+
(_b = inputRefRef.current) === null || _b === void 0 ? void 0 : _b.call(inputRefRef, instance.dom);
|
|
81
|
+
}
|
|
67
82
|
},
|
|
68
83
|
// Including editorState in the dependencies here will cause an endless
|
|
69
84
|
// loop as the initialization changes its value
|
|
@@ -2,6 +2,7 @@ import { __rest, __assign } from 'tslib';
|
|
|
2
2
|
import React, { useId, useState, useEffect } from 'react';
|
|
3
3
|
import { useButton } from '@react-aria/button';
|
|
4
4
|
import { useSelect, HiddenSelect } from '@react-aria/select';
|
|
5
|
+
import { mergeRefs } from '@react-aria/utils';
|
|
5
6
|
import { useSelectState } from '@react-stately/select';
|
|
6
7
|
import classnames from 'classnames';
|
|
7
8
|
import { FieldMessage } from '../FieldMessage/FieldMessage.mjs';
|
|
@@ -45,7 +46,8 @@ const SingleSelect = /*#__PURE__*/function () {
|
|
|
45
46
|
isDisabled = _a.isDisabled,
|
|
46
47
|
onSelectionChange = _a.onSelectionChange,
|
|
47
48
|
portalContainerId = _a.portalContainerId,
|
|
48
|
-
|
|
49
|
+
inputRef = _a.inputRef,
|
|
50
|
+
restProps = __rest(_a, ["label", "items", "id", "trigger", "children", "status", "validationMessage", "isReversed", "isRequired", "isFullWidth", "classNameOverride", "selectedKey", "description", "isDisabled", "onSelectionChange", "portalContainerId", "inputRef"]);
|
|
49
51
|
var refs = useFloating().refs;
|
|
50
52
|
var triggerRef = refs.reference;
|
|
51
53
|
var fallbackId = useId();
|
|
@@ -94,7 +96,7 @@ const SingleSelect = /*#__PURE__*/function () {
|
|
|
94
96
|
status: status,
|
|
95
97
|
'isDisabled': triggerProps.isDisabled,
|
|
96
98
|
isReversed: isReversed,
|
|
97
|
-
'ref': refs.setReference,
|
|
99
|
+
'ref': mergeRefs(inputRef, refs.setReference),
|
|
98
100
|
'aria-describedby': classnames(validationMessage && validationId, description && descriptionId),
|
|
99
101
|
'aria-required': isRequired
|
|
100
102
|
});
|