@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
|
@@ -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
|
});
|
|
@@ -37,6 +37,7 @@ var TabList = function (props) {
|
|
|
37
37
|
setContainerElement = _f[1];
|
|
38
38
|
var tabListContext = useContext(TabListStateContext);
|
|
39
39
|
var selectedKey = tabListContext === null || tabListContext === void 0 ? void 0 : tabListContext.selectedKey;
|
|
40
|
+
var prevSelectedKey = useRef(selectedKey);
|
|
40
41
|
useEffect(function () {
|
|
41
42
|
if (!isDocumentReady) {
|
|
42
43
|
setIsDocumentReady(true);
|
|
@@ -86,7 +87,13 @@ var TabList = function (props) {
|
|
|
86
87
|
if (!isDocumentReady) {
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
|
-
//
|
|
90
|
+
// Only scroll the selected tab into view when the selection actually changes
|
|
91
|
+
// (i.e. user interaction). Skipping the no-op runs avoids scrolling the page
|
|
92
|
+
// on mount when the Tabs sit below the fold.
|
|
93
|
+
if (prevSelectedKey.current === selectedKey) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
prevSelectedKey.current = selectedKey;
|
|
90
97
|
(_a = containerElement === null || containerElement === void 0 ? void 0 : containerElement.querySelector('[role="tab"][data-selected=true]')) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
91
98
|
block: 'nearest',
|
|
92
99
|
inline: 'center'
|
|
@@ -33,7 +33,8 @@ const TimeFieldComponent = /*#__PURE__*/function () {
|
|
|
33
33
|
validationMessage = _a.validationMessage,
|
|
34
34
|
isDisabled = _a.isDisabled,
|
|
35
35
|
classNameOverride = _a.classNameOverride,
|
|
36
|
-
|
|
36
|
+
inputRef = _a.inputRef,
|
|
37
|
+
restProps = __rest(_a, ["id", "label", "locale", "onChange", "value", "status", "validationMessage", "isDisabled", "classNameOverride", "inputRef"]);
|
|
37
38
|
var reactId = useId();
|
|
38
39
|
var id = propsId !== null && propsId !== void 0 ? propsId : reactId;
|
|
39
40
|
var handleOnChange = function (timeValue) {
|
|
@@ -59,14 +60,17 @@ const TimeFieldComponent = /*#__PURE__*/function () {
|
|
|
59
60
|
}));
|
|
60
61
|
var hasError = !!validationMessage && status === 'error';
|
|
61
62
|
var descriptionId = hasError ? "".concat(id, "-field-message") : undefined;
|
|
62
|
-
var
|
|
63
|
+
var internalRef = React.useRef(null);
|
|
63
64
|
var _c = useTimeField(__assign(__assign({}, restProps), {
|
|
64
65
|
label: label,
|
|
65
66
|
isDisabled: isDisabled,
|
|
66
67
|
'aria-describedby': descriptionId
|
|
67
|
-
}), state,
|
|
68
|
+
}), state, internalRef),
|
|
68
69
|
fieldProps = _c.fieldProps,
|
|
69
70
|
labelProps = _c.labelProps;
|
|
71
|
+
var firstEditableIndex = state.segments.findIndex(function (s) {
|
|
72
|
+
return s.isEditable;
|
|
73
|
+
});
|
|
70
74
|
return /*#__PURE__*/React.createElement("div", {
|
|
71
75
|
className: classNameOverride
|
|
72
76
|
}, /*#__PURE__*/React.createElement(Label, __assign({
|
|
@@ -77,13 +81,14 @@ const TimeFieldComponent = /*#__PURE__*/function () {
|
|
|
77
81
|
className: modules_0db24a3e.wrapper
|
|
78
82
|
}, /*#__PURE__*/React.createElement("div", __assign({}, fieldProps, {
|
|
79
83
|
id: id,
|
|
80
|
-
ref:
|
|
84
|
+
ref: internalRef,
|
|
81
85
|
className: classnames(modules_0db24a3e.input, state.isDisabled && modules_0db24a3e.isDisabled, status === 'error' && modules_0db24a3e.error)
|
|
82
86
|
}), state.segments.map(function (segment, i) {
|
|
83
87
|
return /*#__PURE__*/React.createElement(TimeSegment, {
|
|
84
88
|
key: i,
|
|
85
89
|
segment: segment,
|
|
86
90
|
state: state,
|
|
91
|
+
inputRef: i === firstEditableIndex ? inputRef : undefined,
|
|
87
92
|
hasPadding: ![8294, 8297].includes(segment.text.charCodeAt(0))
|
|
88
93
|
});
|
|
89
94
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __assign } from 'tslib';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useDateSegment } from '@react-aria/datepicker';
|
|
4
|
+
import { mergeRefs } from '@react-aria/utils';
|
|
4
5
|
import classnames from 'classnames';
|
|
5
6
|
import { generateSegmentDisplayText } from './utils/generateSegmentDisplayText.mjs';
|
|
6
7
|
import modules_0ac56f95 from './TimeSegment.module.css.mjs';
|
|
@@ -9,9 +10,10 @@ const TimeSegment = /*#__PURE__*/function () {
|
|
|
9
10
|
var segment = _a.segment,
|
|
10
11
|
state = _a.state,
|
|
11
12
|
_b = _a.hasPadding,
|
|
12
|
-
hasPadding = _b === void 0 ? true : _b
|
|
13
|
-
|
|
14
|
-
var
|
|
13
|
+
hasPadding = _b === void 0 ? true : _b,
|
|
14
|
+
inputRef = _a.inputRef;
|
|
15
|
+
var internalRef = React.useRef(null);
|
|
16
|
+
var segmentProps = useDateSegment(segment, state, internalRef).segmentProps;
|
|
15
17
|
// Chrome has a bug where `contenteditable` elements receive focus from external clicks.
|
|
16
18
|
// This (in combination with the invisible character ​) creates boundaries
|
|
17
19
|
// for the element.
|
|
@@ -19,7 +21,7 @@ const TimeSegment = /*#__PURE__*/function () {
|
|
|
19
21
|
return /*#__PURE__*/React.createElement("span", {
|
|
20
22
|
className: modules_0ac56f95.timeSegmentWrapper
|
|
21
23
|
}, "\u200B", /*#__PURE__*/React.createElement("span", __assign({}, segmentProps, {
|
|
22
|
-
ref:
|
|
24
|
+
ref: mergeRefs(internalRef, inputRef),
|
|
23
25
|
className: classnames(modules_0ac56f95.timeSegment, segment.type === 'literal' && modules_0ac56f95.literal, segment.isPlaceholder && modules_0ac56f95.placeholder, segment.type === 'dayPeriod' && modules_0ac56f95.dayPeriod, hasPadding && modules_0ac56f95.hasPadding)
|
|
24
26
|
}), generateSegmentDisplayText(segment)), "\u200B");
|
|
25
27
|
};
|