@activecollab/components 1.0.195 → 1.0.196
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/components/EditableContent/EditableContent.js +7 -3
- package/dist/cjs/components/EditableContent/EditableContent.js.map +1 -1
- package/dist/esm/components/EditableContent/EditableContent.d.ts +2 -1
- package/dist/esm/components/EditableContent/EditableContent.d.ts.map +1 -1
- package/dist/esm/components/EditableContent/EditableContent.js +6 -3
- package/dist/esm/components/EditableContent/EditableContent.js.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,9 +9,11 @@ exports.EditableContent = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
+
var _ = require("../..");
|
|
13
|
+
|
|
12
14
|
var _Styles = require("./Styles");
|
|
13
15
|
|
|
14
|
-
var _excluded = ["className", "variant", "weight", "disabled", "inputProps"];
|
|
16
|
+
var _excluded = ["className", "variant", "weight", "disabled", "inputProps", "wrapRef"];
|
|
15
17
|
|
|
16
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
19
|
|
|
@@ -31,9 +33,11 @@ var EditableContent = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
31
33
|
_ref$disabled = _ref.disabled,
|
|
32
34
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
33
35
|
inputProps = _ref.inputProps,
|
|
36
|
+
wrapRef = _ref.wrapRef,
|
|
34
37
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
38
|
|
|
36
39
|
var intInputRef = (0, _react.useRef)(null);
|
|
40
|
+
var handleRef = (0, _.useForkRef)(ref, intInputRef);
|
|
37
41
|
var handleBlur = (0, _react.useCallback)(function (evt) {
|
|
38
42
|
var _intInputRef$current;
|
|
39
43
|
|
|
@@ -42,14 +46,14 @@ var EditableContent = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
42
46
|
}, [inputProps]);
|
|
43
47
|
return /*#__PURE__*/_react.default.createElement(_Styles.StyledDiv, _extends({
|
|
44
48
|
className: className,
|
|
45
|
-
ref:
|
|
49
|
+
ref: wrapRef
|
|
46
50
|
}, props), /*#__PURE__*/_react.default.createElement(_Styles.StyledSpan, {
|
|
47
51
|
variant: variant,
|
|
48
52
|
forwardedAs: "span",
|
|
49
53
|
weight: weight,
|
|
50
54
|
$disabled: disabled
|
|
51
55
|
}, inputProps === null || inputProps === void 0 ? void 0 : inputProps.value), /*#__PURE__*/_react.default.createElement(_Styles.StyledInput, _extends({}, inputProps, {
|
|
52
|
-
ref:
|
|
56
|
+
ref: handleRef,
|
|
53
57
|
forwardedAs: "input",
|
|
54
58
|
variant: variant,
|
|
55
59
|
weight: weight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"names":["EditableContent","ref","className","variant","weight","disabled","inputProps","props","intInputRef","handleBlur","evt","current","setSelectionRange","onBlur","value","displayName"],"mappings":";;;;;;;;;AAAA;;AAEA;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"names":["EditableContent","ref","className","variant","weight","disabled","inputProps","wrapRef","props","intInputRef","handleRef","handleBlur","evt","current","setSelectionRange","onBlur","value","displayName"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;;;;;;;;;;;;;AAeO,IAAMA,eAAe,gBAAG,uBAK7B,gBAUEC,GAVF,EAWK;AAAA,MATDC,SASC,QATDA,SASC;AAAA,0BARDC,OAQC;AAAA,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A,QAAQ,EAAEN;AARZ,KATF,CADF;AAsBD,CAlD4B,CAAxB;;AAqDPL,eAAe,CAACiB,WAAhB,GAA8B,iBAA9B","sourcesContent":["import React, { forwardRef, Ref, useRef, useCallback } from \"react\";\nimport { useForkRef } from \"../..\";\nimport { Variant } from \"../Typography/Typography\";\nimport { StyledDiv, StyledInput, StyledSpan } from \"./Styles\";\n\nexport interface EditableContentInterface {\n /** Typography variant. */\n variant?: Variant;\n /** Typography weight. */\n weight?: \"light\" | \"regular\" | \"bold\" | \"medium\";\n /** Input props. */\n inputProps?: Partial<React.ComponentPropsWithoutRef<\"input\">>;\n /** Disable edit mode. */\n disabled?: boolean;\n /** Wrapper reference. */\n wrapRef?: Ref<HTMLDivElement>;\n}\n\nexport const EditableContent = forwardRef<\n HTMLDivElement,\n EditableContentInterface &\n Omit<React.ComponentPropsWithoutRef<\"div\">, keyof EditableContentInterface>\n>(\n (\n {\n className,\n variant = \"Body 2\",\n weight,\n disabled = false,\n inputProps,\n wrapRef,\n ...props\n },\n ref\n ) => {\n const intInputRef = useRef<HTMLInputElement>(null);\n const handleRef = useForkRef(ref, intInputRef);\n\n const handleBlur = useCallback(\n (evt) => {\n intInputRef?.current?.setSelectionRange(0, 0);\n typeof inputProps?.onBlur === `function` && inputProps?.onBlur(evt);\n },\n [inputProps]\n );\n\n return (\n <StyledDiv className={className} ref={wrapRef} {...props}>\n <StyledSpan\n variant={variant}\n forwardedAs=\"span\"\n weight={weight}\n $disabled={disabled}\n >\n {inputProps?.value}\n </StyledSpan>\n <StyledInput\n {...inputProps}\n ref={handleRef}\n forwardedAs=\"input\"\n variant={variant}\n weight={weight}\n value={inputProps?.value}\n onBlur={handleBlur}\n disabled={disabled}\n />\n </StyledDiv>\n );\n }\n);\n\nEditableContent.displayName = \"EditableContent\";\n"],"file":"EditableContent.js"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { Ref } from "react";
|
|
2
2
|
import { Variant } from "../Typography/Typography";
|
|
3
3
|
export interface EditableContentInterface {
|
|
4
4
|
variant?: Variant;
|
|
5
5
|
weight?: "light" | "regular" | "bold" | "medium";
|
|
6
6
|
inputProps?: Partial<React.ComponentPropsWithoutRef<"input">>;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
wrapRef?: Ref<HTMLDivElement>;
|
|
8
9
|
}
|
|
9
10
|
export declare const EditableContent: React.ForwardRefExoticComponent<EditableContentInterface & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "slot" | "style" | "title" | "key" | "css" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "cs" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "tw">, keyof EditableContentInterface> & React.RefAttributes<HTMLDivElement>>;
|
|
10
11
|
//# sourceMappingURL=EditableContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableContent.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"EditableContent.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,GAAG,EAAuB,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGnD,MAAM,WAAW,wBAAwB;IAEvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IAEjD,UAAU,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9D,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,OAAO,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC/B;AAED,eAAO,MAAM,eAAe,yuJAmD3B,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["className", "variant", "weight", "disabled", "inputProps"];
|
|
3
|
+
var _excluded = ["className", "variant", "weight", "disabled", "inputProps", "wrapRef"];
|
|
4
4
|
import React, { forwardRef, useRef, useCallback } from "react";
|
|
5
|
+
import { useForkRef } from "../..";
|
|
5
6
|
import { StyledDiv, StyledInput, StyledSpan } from "./Styles";
|
|
6
7
|
export var EditableContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
7
8
|
var className = _ref.className,
|
|
@@ -11,9 +12,11 @@ export var EditableContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
11
12
|
_ref$disabled = _ref.disabled,
|
|
12
13
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
13
14
|
inputProps = _ref.inputProps,
|
|
15
|
+
wrapRef = _ref.wrapRef,
|
|
14
16
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
17
|
|
|
16
18
|
var intInputRef = useRef(null);
|
|
19
|
+
var handleRef = useForkRef(ref, intInputRef);
|
|
17
20
|
var handleBlur = useCallback(function (evt) {
|
|
18
21
|
var _intInputRef$current;
|
|
19
22
|
|
|
@@ -22,14 +25,14 @@ export var EditableContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
22
25
|
}, [inputProps]);
|
|
23
26
|
return /*#__PURE__*/React.createElement(StyledDiv, _extends({
|
|
24
27
|
className: className,
|
|
25
|
-
ref:
|
|
28
|
+
ref: wrapRef
|
|
26
29
|
}, props), /*#__PURE__*/React.createElement(StyledSpan, {
|
|
27
30
|
variant: variant,
|
|
28
31
|
forwardedAs: "span",
|
|
29
32
|
weight: weight,
|
|
30
33
|
$disabled: disabled
|
|
31
34
|
}, inputProps == null ? void 0 : inputProps.value), /*#__PURE__*/React.createElement(StyledInput, _extends({}, inputProps, {
|
|
32
|
-
ref:
|
|
35
|
+
ref: handleRef,
|
|
33
36
|
forwardedAs: "input",
|
|
34
37
|
variant: variant,
|
|
35
38
|
weight: weight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"names":["React","forwardRef","useRef","useCallback","StyledDiv","StyledInput","StyledSpan","EditableContent","ref","className","variant","weight","disabled","inputProps","props","intInputRef","handleBlur","evt","current","setSelectionRange","onBlur","value","displayName"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"names":["React","forwardRef","useRef","useCallback","useForkRef","StyledDiv","StyledInput","StyledSpan","EditableContent","ref","className","variant","weight","disabled","inputProps","wrapRef","props","intInputRef","handleRef","handleBlur","evt","current","setSelectionRange","onBlur","value","displayName"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAAiCC,MAAjC,EAAyCC,WAAzC,QAA4D,OAA5D;AACA,SAASC,UAAT,QAA2B,OAA3B;AAEA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,UAAjC,QAAmD,UAAnD;AAeA,OAAO,IAAMC,eAAe,gBAAGP,UAAU,CAKvC,gBAUEQ,GAVF,EAWK;AAAA,MATDC,SASC,QATDA,SASC;AAAA,0BARDC,OAQC;AAAA,MARDA,OAQC,6BARS,QA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B,WAAhB,GAA8B,iBAA9B","sourcesContent":["import React, { forwardRef, Ref, useRef, useCallback } from \"react\";\nimport { useForkRef } from \"../..\";\nimport { Variant } from \"../Typography/Typography\";\nimport { StyledDiv, StyledInput, StyledSpan } from \"./Styles\";\n\nexport interface EditableContentInterface {\n /** Typography variant. */\n variant?: Variant;\n /** Typography weight. */\n weight?: \"light\" | \"regular\" | \"bold\" | \"medium\";\n /** Input props. */\n inputProps?: Partial<React.ComponentPropsWithoutRef<\"input\">>;\n /** Disable edit mode. */\n disabled?: boolean;\n /** Wrapper reference. */\n wrapRef?: Ref<HTMLDivElement>;\n}\n\nexport const EditableContent = forwardRef<\n HTMLDivElement,\n EditableContentInterface &\n Omit<React.ComponentPropsWithoutRef<\"div\">, keyof EditableContentInterface>\n>(\n (\n {\n className,\n variant = \"Body 2\",\n weight,\n disabled = false,\n inputProps,\n wrapRef,\n ...props\n },\n ref\n ) => {\n const intInputRef = useRef<HTMLInputElement>(null);\n const handleRef = useForkRef(ref, intInputRef);\n\n const handleBlur = useCallback(\n (evt) => {\n intInputRef?.current?.setSelectionRange(0, 0);\n typeof inputProps?.onBlur === `function` && inputProps?.onBlur(evt);\n },\n [inputProps]\n );\n\n return (\n <StyledDiv className={className} ref={wrapRef} {...props}>\n <StyledSpan\n variant={variant}\n forwardedAs=\"span\"\n weight={weight}\n $disabled={disabled}\n >\n {inputProps?.value}\n </StyledSpan>\n <StyledInput\n {...inputProps}\n ref={handleRef}\n forwardedAs=\"input\"\n variant={variant}\n weight={weight}\n value={inputProps?.value}\n onBlur={handleBlur}\n disabled={disabled}\n />\n </StyledDiv>\n );\n }\n);\n\nEditableContent.displayName = \"EditableContent\";\n"],"file":"EditableContent.js"}
|
package/dist/index.js
CHANGED
|
@@ -12048,7 +12048,7 @@
|
|
|
12048
12048
|
});
|
|
12049
12049
|
StyledInput.displayName = "StyledInput";
|
|
12050
12050
|
|
|
12051
|
-
var _excluded$5 = ["className", "variant", "weight", "disabled", "inputProps"];
|
|
12051
|
+
var _excluded$5 = ["className", "variant", "weight", "disabled", "inputProps", "wrapRef"];
|
|
12052
12052
|
var EditableContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
12053
12053
|
var className = _ref.className,
|
|
12054
12054
|
_ref$variant = _ref.variant,
|
|
@@ -12057,9 +12057,11 @@
|
|
|
12057
12057
|
_ref$disabled = _ref.disabled,
|
|
12058
12058
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
12059
12059
|
inputProps = _ref.inputProps,
|
|
12060
|
+
wrapRef = _ref.wrapRef,
|
|
12060
12061
|
props = _objectWithoutProperties(_ref, _excluded$5);
|
|
12061
12062
|
|
|
12062
12063
|
var intInputRef = React.useRef(null);
|
|
12064
|
+
var handleRef = useForkRef(ref, intInputRef);
|
|
12063
12065
|
var handleBlur = React.useCallback(function (evt) {
|
|
12064
12066
|
var _intInputRef$current;
|
|
12065
12067
|
|
|
@@ -12068,14 +12070,14 @@
|
|
|
12068
12070
|
}, [inputProps]);
|
|
12069
12071
|
return /*#__PURE__*/React__default["default"].createElement(StyledDiv, _extends({
|
|
12070
12072
|
className: className,
|
|
12071
|
-
ref:
|
|
12073
|
+
ref: wrapRef
|
|
12072
12074
|
}, props), /*#__PURE__*/React__default["default"].createElement(StyledSpan, {
|
|
12073
12075
|
variant: variant,
|
|
12074
12076
|
forwardedAs: "span",
|
|
12075
12077
|
weight: weight,
|
|
12076
12078
|
$disabled: disabled
|
|
12077
12079
|
}, inputProps === null || inputProps === void 0 ? void 0 : inputProps.value), /*#__PURE__*/React__default["default"].createElement(StyledInput, _extends({}, inputProps, {
|
|
12078
|
-
ref:
|
|
12080
|
+
ref: handleRef,
|
|
12079
12081
|
forwardedAs: "input",
|
|
12080
12082
|
variant: variant,
|
|
12081
12083
|
weight: weight,
|