@kaizen/components 3.1.6 → 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/DateInput/DateInput/DateInput.cjs +1 -2
- package/dist/cjs/src/DatePicker/DatePicker.cjs +6 -4
- 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/cjs/src/Tabs/subcomponents/TabList/TabList.cjs +8 -1
- package/dist/cjs/src/TimeField/TimeField.cjs +9 -4
- package/dist/cjs/src/TimeField/subcomponents/TimeSegment/TimeSegment.cjs +6 -4
- package/dist/esm/src/Avatar/Avatar.mjs +18 -15
- package/dist/esm/src/DateInput/DateInput/DateInput.mjs +1 -2
- package/dist/esm/src/DatePicker/DatePicker.mjs +6 -4
- 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/esm/src/Tabs/subcomponents/TabList/TabList.mjs +8 -1
- package/dist/esm/src/TimeField/TimeField.mjs +9 -4
- package/dist/esm/src/TimeField/subcomponents/TimeSegment/TimeSegment.mjs +6 -4
- package/dist/styles.css +15 -15
- package/dist/types/DateInput/DateInputWithIconButton/DateInputWithIconButton.d.ts +2 -2
- package/dist/types/DatePicker/DatePicker.d.ts +3 -2
- package/dist/types/Focusable/Focusable.d.ts +8 -3
- package/dist/types/Input/Input/Input.d.ts +1 -1
- 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/dist/types/TextArea/TextArea.d.ts +1 -1
- package/dist/types/TimeField/TimeField.d.ts +1 -0
- package/dist/types/TimeField/subcomponents/TimeSegment/TimeSegment.d.ts +3 -1
- package/package.json +7 -7
- package/src/Avatar/Avatar.tsx +19 -11
- package/src/DateInput/DateInput/DateInput.tsx +1 -2
- package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.tsx +2 -2
- package/src/DatePicker/DatePicker.tsx +6 -3
- package/src/Focusable/Focusable.tsx +17 -7
- package/src/Input/Input/Input.tsx +1 -1
- 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
- package/src/Tabs/_docs/Tabs.spec.stories.tsx +39 -0
- package/src/Tabs/_docs/Tabs.stories.tsx +38 -2
- package/src/Tabs/subcomponents/TabList/TabList.tsx +9 -1
- package/src/TextArea/TextArea.tsx +1 -1
- package/src/TimeField/TimeField.tsx +17 -15
- package/src/TimeField/subcomponents/TimeSegment/TimeSegment.tsx +6 -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} |
|
|
@@ -7,7 +7,6 @@ var Input = require('../../Input/Input/Input.cjs');
|
|
|
7
7
|
require('../../Input/InputRange/InputRange.cjs');
|
|
8
8
|
require('../../Input/InputSearch/InputSearch.cjs');
|
|
9
9
|
var Label = require('../../Label/Label.cjs');
|
|
10
|
-
var isRefObject = require('../../utils/isRefObject.cjs');
|
|
11
10
|
var DateInput_module = require('./DateInput.module.css.cjs');
|
|
12
11
|
function _interopDefault(e) {
|
|
13
12
|
return e && e.__esModule ? e : {
|
|
@@ -33,7 +32,7 @@ var DateInput = React__default.default.forwardRef(function (_a, ref) {
|
|
|
33
32
|
reversed: isReversed,
|
|
34
33
|
disabled: disabled
|
|
35
34
|
}), React__default.default.createElement(Input.Input, tslib.__assign({
|
|
36
|
-
inputRef:
|
|
35
|
+
inputRef: ref,
|
|
37
36
|
id: id,
|
|
38
37
|
type: "text",
|
|
39
38
|
autoComplete: "off",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var i18nReactIntl = require('@cultureamp/i18n-react-intl');
|
|
6
|
+
var utils = require('@react-aria/utils');
|
|
6
7
|
var reactFocusOn = require('react-focus-on');
|
|
7
8
|
var CalendarSingle = require('../Calendar/CalendarSingle/CalendarSingle.cjs');
|
|
8
9
|
require('../Calendar/CalendarRange/CalendarRange.cjs');
|
|
@@ -33,6 +34,7 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
33
34
|
*/
|
|
34
35
|
var DatePicker = function (_a) {
|
|
35
36
|
var propsId = _a.id,
|
|
37
|
+
propsInputRef = _a.inputRef,
|
|
36
38
|
propsButtonRef = _a.buttonRef,
|
|
37
39
|
_b = _a.locale,
|
|
38
40
|
propsLocale = _b === void 0 ? 'en-AU' : _b,
|
|
@@ -54,7 +56,7 @@ var DatePicker = function (_a) {
|
|
|
54
56
|
onButtonClick = _a.onButtonClick,
|
|
55
57
|
onDayChange = _a.onDayChange,
|
|
56
58
|
onValidate = _a.onValidate,
|
|
57
|
-
restDateInputFieldProps = tslib.__rest(_a, ["id", "buttonRef", "locale", "disabledDates", "disabledDaysOfWeek", "disabledRange", "disabledBeforeAfter", "disabledBefore", "disabledAfter", "weekStartsOn", "defaultMonth", "selectedDay", "status", "validationMessage", "onInputClick", "onInputFocus", "onInputChange", "onInputBlur", "onButtonClick", "onDayChange", "onValidate"]);
|
|
59
|
+
restDateInputFieldProps = tslib.__rest(_a, ["id", "inputRef", "buttonRef", "locale", "disabledDates", "disabledDaysOfWeek", "disabledRange", "disabledBeforeAfter", "disabledBefore", "disabledAfter", "weekStartsOn", "defaultMonth", "selectedDay", "status", "validationMessage", "onInputClick", "onInputFocus", "onInputChange", "onInputBlur", "onButtonClick", "onDayChange", "onValidate"]);
|
|
58
60
|
var formatMessage = i18nReactIntl.useIntl().formatMessage;
|
|
59
61
|
var calendarLabelDesc = formatMessage({
|
|
60
62
|
id: 'datePicker.calendarLabelDescription',
|
|
@@ -64,11 +66,11 @@ var DatePicker = function (_a) {
|
|
|
64
66
|
var reactId = React.useId();
|
|
65
67
|
var id = propsId !== null && propsId !== void 0 ? propsId : reactId;
|
|
66
68
|
var containerRef = React.useRef(null);
|
|
67
|
-
var
|
|
69
|
+
var internalInputRef = React.useRef(null);
|
|
68
70
|
var fallbackButtonRef = React.useRef(null);
|
|
69
71
|
var buttonRef = propsButtonRef !== null && propsButtonRef !== void 0 ? propsButtonRef : fallbackButtonRef;
|
|
70
72
|
var dateInputRefs = React.useRef({
|
|
71
|
-
inputRef:
|
|
73
|
+
inputRef: utils.mergeRefs(internalInputRef, propsInputRef),
|
|
72
74
|
buttonRef: buttonRef
|
|
73
75
|
});
|
|
74
76
|
var _c = React.useState(''),
|
|
@@ -177,7 +179,7 @@ var DatePicker = function (_a) {
|
|
|
177
179
|
var handleReturnFocus = function () {
|
|
178
180
|
var _a, _b;
|
|
179
181
|
if (lastTrigger === 'inputKeydown' || lastTrigger === 'inputFocus') {
|
|
180
|
-
return (_a =
|
|
182
|
+
return (_a = internalInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
181
183
|
}
|
|
182
184
|
(_b = buttonRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
183
185
|
};
|
|
@@ -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
|
});
|
|
@@ -46,6 +46,7 @@ var TabList = function (props) {
|
|
|
46
46
|
setContainerElement = _f[1];
|
|
47
47
|
var tabListContext = React.useContext(reactAriaComponents.TabListStateContext);
|
|
48
48
|
var selectedKey = tabListContext === null || tabListContext === void 0 ? void 0 : tabListContext.selectedKey;
|
|
49
|
+
var prevSelectedKey = React.useRef(selectedKey);
|
|
49
50
|
React.useEffect(function () {
|
|
50
51
|
if (!isDocumentReady) {
|
|
51
52
|
setIsDocumentReady(true);
|
|
@@ -95,7 +96,13 @@ var TabList = function (props) {
|
|
|
95
96
|
if (!isDocumentReady) {
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
|
-
//
|
|
99
|
+
// Only scroll the selected tab into view when the selection actually changes
|
|
100
|
+
// (i.e. user interaction). Skipping the no-op runs avoids scrolling the page
|
|
101
|
+
// on mount when the Tabs sit below the fold.
|
|
102
|
+
if (prevSelectedKey.current === selectedKey) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
prevSelectedKey.current = selectedKey;
|
|
99
106
|
(_a = containerElement === null || containerElement === void 0 ? void 0 : containerElement.querySelector('[role="tab"][data-selected=true]')) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
100
107
|
block: 'nearest',
|
|
101
108
|
inline: 'center'
|
|
@@ -38,7 +38,8 @@ var TimeFieldComponent = function (_a) {
|
|
|
38
38
|
validationMessage = _a.validationMessage,
|
|
39
39
|
isDisabled = _a.isDisabled,
|
|
40
40
|
classNameOverride = _a.classNameOverride,
|
|
41
|
-
|
|
41
|
+
inputRef = _a.inputRef,
|
|
42
|
+
restProps = tslib.__rest(_a, ["id", "label", "locale", "onChange", "value", "status", "validationMessage", "isDisabled", "classNameOverride", "inputRef"]);
|
|
42
43
|
var reactId = React.useId();
|
|
43
44
|
var id = propsId !== null && propsId !== void 0 ? propsId : reactId;
|
|
44
45
|
var handleOnChange = function (timeValue) {
|
|
@@ -64,14 +65,17 @@ var TimeFieldComponent = function (_a) {
|
|
|
64
65
|
}));
|
|
65
66
|
var hasError = !!validationMessage && status === 'error';
|
|
66
67
|
var descriptionId = hasError ? "".concat(id, "-field-message") : undefined;
|
|
67
|
-
var
|
|
68
|
+
var internalRef = React__default.default.useRef(null);
|
|
68
69
|
var _c = datepicker$1.useTimeField(tslib.__assign(tslib.__assign({}, restProps), {
|
|
69
70
|
label: label,
|
|
70
71
|
isDisabled: isDisabled,
|
|
71
72
|
'aria-describedby': descriptionId
|
|
72
|
-
}), state,
|
|
73
|
+
}), state, internalRef),
|
|
73
74
|
fieldProps = _c.fieldProps,
|
|
74
75
|
labelProps = _c.labelProps;
|
|
76
|
+
var firstEditableIndex = state.segments.findIndex(function (s) {
|
|
77
|
+
return s.isEditable;
|
|
78
|
+
});
|
|
75
79
|
return React__default.default.createElement("div", {
|
|
76
80
|
className: classNameOverride
|
|
77
81
|
}, React__default.default.createElement(Label.Label, tslib.__assign({
|
|
@@ -82,13 +86,14 @@ var TimeFieldComponent = function (_a) {
|
|
|
82
86
|
className: TimeField_module.wrapper
|
|
83
87
|
}, React__default.default.createElement("div", tslib.__assign({}, fieldProps, {
|
|
84
88
|
id: id,
|
|
85
|
-
ref:
|
|
89
|
+
ref: internalRef,
|
|
86
90
|
className: classnames__default.default(TimeField_module.input, state.isDisabled && TimeField_module.isDisabled, status === 'error' && TimeField_module.error)
|
|
87
91
|
}), state.segments.map(function (segment, i) {
|
|
88
92
|
return React__default.default.createElement(TimeSegment.TimeSegment, {
|
|
89
93
|
key: i,
|
|
90
94
|
segment: segment,
|
|
91
95
|
state: state,
|
|
96
|
+
inputRef: i === firstEditableIndex ? inputRef : undefined,
|
|
92
97
|
hasPadding: ![8294, 8297].includes(segment.text.charCodeAt(0))
|
|
93
98
|
});
|
|
94
99
|
}), React__default.default.createElement("div", {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var datepicker = require('@react-aria/datepicker');
|
|
6
|
+
var utils = require('@react-aria/utils');
|
|
6
7
|
var classnames = require('classnames');
|
|
7
8
|
var generateSegmentDisplayText = require('./utils/generateSegmentDisplayText.cjs');
|
|
8
9
|
var TimeSegment_module = require('./TimeSegment.module.css.cjs');
|
|
@@ -17,9 +18,10 @@ var TimeSegment = function (_a) {
|
|
|
17
18
|
var segment = _a.segment,
|
|
18
19
|
state = _a.state,
|
|
19
20
|
_b = _a.hasPadding,
|
|
20
|
-
hasPadding = _b === void 0 ? true : _b
|
|
21
|
-
|
|
22
|
-
var
|
|
21
|
+
hasPadding = _b === void 0 ? true : _b,
|
|
22
|
+
inputRef = _a.inputRef;
|
|
23
|
+
var internalRef = React__default.default.useRef(null);
|
|
24
|
+
var segmentProps = datepicker.useDateSegment(segment, state, internalRef).segmentProps;
|
|
23
25
|
// Chrome has a bug where `contenteditable` elements receive focus from external clicks.
|
|
24
26
|
// This (in combination with the invisible character ​) creates boundaries
|
|
25
27
|
// for the element.
|
|
@@ -27,7 +29,7 @@ var TimeSegment = function (_a) {
|
|
|
27
29
|
return React__default.default.createElement("span", {
|
|
28
30
|
className: TimeSegment_module.timeSegmentWrapper
|
|
29
31
|
}, "\u200B", React__default.default.createElement("span", tslib.__assign({}, segmentProps, {
|
|
30
|
-
ref:
|
|
32
|
+
ref: utils.mergeRefs(internalRef, inputRef),
|
|
31
33
|
className: classnames__default.default(TimeSegment_module.timeSegment, segment.type === 'literal' && TimeSegment_module.literal, segment.isPlaceholder && TimeSegment_module.placeholder, segment.type === 'dayPeriod' && TimeSegment_module.dayPeriod, hasPadding && TimeSegment_module.hasPadding)
|
|
32
34
|
}), generateSegmentDisplayText.generateSegmentDisplayText(segment)), "\u200B");
|
|
33
35
|
};
|
|
@@ -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} |
|
|
@@ -5,7 +5,6 @@ import { Input } from '../../Input/Input/Input.mjs';
|
|
|
5
5
|
import '../../Input/InputRange/InputRange.mjs';
|
|
6
6
|
import '../../Input/InputSearch/InputSearch.mjs';
|
|
7
7
|
import { Label } from '../../Label/Label.mjs';
|
|
8
|
-
import { isRefObject } from '../../utils/isRefObject.mjs';
|
|
9
8
|
import modules_30be64ed from './DateInput.module.css.mjs';
|
|
10
9
|
const DateInput = /*#__PURE__*/function () {
|
|
11
10
|
const DateInput = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
@@ -25,7 +24,7 @@ const DateInput = /*#__PURE__*/function () {
|
|
|
25
24
|
reversed: isReversed,
|
|
26
25
|
disabled: disabled
|
|
27
26
|
}), /*#__PURE__*/React.createElement(Input, __assign({
|
|
28
|
-
inputRef:
|
|
27
|
+
inputRef: ref,
|
|
29
28
|
id: id,
|
|
30
29
|
type: "text",
|
|
31
30
|
autoComplete: "off",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __rest, __assign } from 'tslib';
|
|
2
2
|
import React, { useId, useRef, useState, useEffect } from 'react';
|
|
3
3
|
import { useIntl } from '@cultureamp/i18n-react-intl';
|
|
4
|
+
import { mergeRefs } from '@react-aria/utils';
|
|
4
5
|
import { FocusOn } from 'react-focus-on';
|
|
5
6
|
import { CalendarSingle } from '../Calendar/CalendarSingle/CalendarSingle.mjs';
|
|
6
7
|
import '../Calendar/CalendarRange/CalendarRange.mjs';
|
|
@@ -26,6 +27,7 @@ import { validateDate } from './utils/validateDate.mjs';
|
|
|
26
27
|
const DatePicker = /*#__PURE__*/function () {
|
|
27
28
|
const DatePicker = function (_a) {
|
|
28
29
|
var propsId = _a.id,
|
|
30
|
+
propsInputRef = _a.inputRef,
|
|
29
31
|
propsButtonRef = _a.buttonRef,
|
|
30
32
|
_b = _a.locale,
|
|
31
33
|
propsLocale = _b === void 0 ? 'en-AU' : _b,
|
|
@@ -47,7 +49,7 @@ const DatePicker = /*#__PURE__*/function () {
|
|
|
47
49
|
onButtonClick = _a.onButtonClick,
|
|
48
50
|
onDayChange = _a.onDayChange,
|
|
49
51
|
onValidate = _a.onValidate,
|
|
50
|
-
restDateInputFieldProps = __rest(_a, ["id", "buttonRef", "locale", "disabledDates", "disabledDaysOfWeek", "disabledRange", "disabledBeforeAfter", "disabledBefore", "disabledAfter", "weekStartsOn", "defaultMonth", "selectedDay", "status", "validationMessage", "onInputClick", "onInputFocus", "onInputChange", "onInputBlur", "onButtonClick", "onDayChange", "onValidate"]);
|
|
52
|
+
restDateInputFieldProps = __rest(_a, ["id", "inputRef", "buttonRef", "locale", "disabledDates", "disabledDaysOfWeek", "disabledRange", "disabledBeforeAfter", "disabledBefore", "disabledAfter", "weekStartsOn", "defaultMonth", "selectedDay", "status", "validationMessage", "onInputClick", "onInputFocus", "onInputChange", "onInputBlur", "onButtonClick", "onDayChange", "onValidate"]);
|
|
51
53
|
var formatMessage = useIntl().formatMessage;
|
|
52
54
|
var calendarLabelDesc = formatMessage({
|
|
53
55
|
id: 'datePicker.calendarLabelDescription',
|
|
@@ -57,11 +59,11 @@ const DatePicker = /*#__PURE__*/function () {
|
|
|
57
59
|
var reactId = useId();
|
|
58
60
|
var id = propsId !== null && propsId !== void 0 ? propsId : reactId;
|
|
59
61
|
var containerRef = useRef(null);
|
|
60
|
-
var
|
|
62
|
+
var internalInputRef = useRef(null);
|
|
61
63
|
var fallbackButtonRef = useRef(null);
|
|
62
64
|
var buttonRef = propsButtonRef !== null && propsButtonRef !== void 0 ? propsButtonRef : fallbackButtonRef;
|
|
63
65
|
var dateInputRefs = useRef({
|
|
64
|
-
inputRef:
|
|
66
|
+
inputRef: mergeRefs(internalInputRef, propsInputRef),
|
|
65
67
|
buttonRef: buttonRef
|
|
66
68
|
});
|
|
67
69
|
var _c = useState(''),
|
|
@@ -170,7 +172,7 @@ const DatePicker = /*#__PURE__*/function () {
|
|
|
170
172
|
var handleReturnFocus = function () {
|
|
171
173
|
var _a, _b;
|
|
172
174
|
if (lastTrigger === 'inputKeydown' || lastTrigger === 'inputFocus') {
|
|
173
|
-
return (_a =
|
|
175
|
+
return (_a = internalInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
174
176
|
}
|
|
175
177
|
(_b = buttonRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
176
178
|
};
|
|
@@ -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 };
|