@wistia/ui 0.5.2-beta.a848ca2c.7febb8d → 0.5.2-beta.a93c5fb4.3a5bcbb
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/index.cjs +160 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +56 -1
- package/dist/index.d.ts +56 -1
- package/dist/index.mjs +159 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.5.2-beta.
|
|
3
|
+
* @license @wistia/ui v0.5.2-beta.a93c5fb4.3a5bcbb
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -56,6 +56,7 @@ __export(index_exports, {
|
|
|
56
56
|
DataCardTrend: () => DataCardTrend,
|
|
57
57
|
DataCards: () => DataCards,
|
|
58
58
|
Divider: () => Divider,
|
|
59
|
+
EditableHeading: () => EditableHeading,
|
|
59
60
|
Ellipsis: () => Ellipsis,
|
|
60
61
|
Form: () => Form,
|
|
61
62
|
FormErrorSummary: () => FormErrorSummary,
|
|
@@ -2080,9 +2081,9 @@ var import_react6 = require("react");
|
|
|
2080
2081
|
// src/private/hooks/useEvent/useEvent.ts
|
|
2081
2082
|
var import_react5 = require("react");
|
|
2082
2083
|
|
|
2083
|
-
// src/private/helpers/
|
|
2084
|
+
// src/private/helpers/isObjectRef/isObjectRef.ts
|
|
2084
2085
|
var import_type_guards6 = require("@wistia/type-guards");
|
|
2085
|
-
var
|
|
2086
|
+
var isObjectRef = (value) => {
|
|
2086
2087
|
return (0, import_type_guards6.isNotNil)(value) && (0, import_type_guards6.isRecord)(value) && "current" in value;
|
|
2087
2088
|
};
|
|
2088
2089
|
|
|
@@ -2102,7 +2103,7 @@ var useEvent = (eventName, eventHandler, eventTarget = window, eventOptions = {}
|
|
|
2102
2103
|
savedEventOptions.current = eventOptions;
|
|
2103
2104
|
}, [eventOptions]);
|
|
2104
2105
|
(0, import_react5.useEffect)(() => {
|
|
2105
|
-
const target =
|
|
2106
|
+
const target = isObjectRef(eventTarget) ? eventTarget.current : eventTarget;
|
|
2106
2107
|
if (!eventName || !isEventTargetSupported(target)) {
|
|
2107
2108
|
return;
|
|
2108
2109
|
}
|
|
@@ -7904,7 +7905,7 @@ var StyledInputContainer = import_styled_components41.default.div`
|
|
|
7904
7905
|
padding-right: 32px;
|
|
7905
7906
|
}
|
|
7906
7907
|
`;
|
|
7907
|
-
var
|
|
7908
|
+
var isValidRef = (ref) => {
|
|
7908
7909
|
return typeof ref === "object" && ref !== null && "current" in ref && (0, import_type_guards24.isNotNil)(ref.current);
|
|
7909
7910
|
};
|
|
7910
7911
|
var Input = (0, import_react30.forwardRef)(
|
|
@@ -7918,7 +7919,7 @@ var Input = (0, import_react30.forwardRef)(
|
|
|
7918
7919
|
...props
|
|
7919
7920
|
}, externalRef) => {
|
|
7920
7921
|
const internalRef = (0, import_react30.useRef)();
|
|
7921
|
-
const ref =
|
|
7922
|
+
const ref = isValidRef(externalRef) ? externalRef : internalRef;
|
|
7922
7923
|
let leftIconToDisplay = leftIcon;
|
|
7923
7924
|
if ((0, import_type_guards24.isNil)(leftIcon) && type === "search") {
|
|
7924
7925
|
leftIconToDisplay = /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(Icon, { type: "search" });
|
|
@@ -9775,6 +9776,158 @@ var DataCardTrend = ({
|
|
|
9775
9776
|
)
|
|
9776
9777
|
] });
|
|
9777
9778
|
};
|
|
9779
|
+
|
|
9780
|
+
// src/components/EditableHeading/EditableHeading.tsx
|
|
9781
|
+
var import_styled_components65 = __toESM(require("styled-components"));
|
|
9782
|
+
var import_react46 = require("react");
|
|
9783
|
+
var import_jsx_runtime214 = require("react/jsx-runtime");
|
|
9784
|
+
var sharedInputStyles = import_styled_components65.css`
|
|
9785
|
+
padding: var(--wui-space-02);
|
|
9786
|
+
border-radius: var(--wui-border-radius-01);
|
|
9787
|
+
overflow-wrap: anywhere;
|
|
9788
|
+
width: 100%;
|
|
9789
|
+
`;
|
|
9790
|
+
var StyledEditableHeadingInput = import_styled_components65.default.textarea`
|
|
9791
|
+
:not([rows]) {
|
|
9792
|
+
min-height: unset;
|
|
9793
|
+
}
|
|
9794
|
+
|
|
9795
|
+
${sharedInputStyles}
|
|
9796
|
+
font-size: var(--wui-typography-heading-1-size);
|
|
9797
|
+
font-weight: var(--wui-typography-heading-1-weight);
|
|
9798
|
+
line-height: var(--wui-typography-heading-1-line-height);
|
|
9799
|
+
font-family: var(--wui-typography-heading-1-family);
|
|
9800
|
+
box-sizing: border-box;
|
|
9801
|
+
margin: 0;
|
|
9802
|
+
display: block;
|
|
9803
|
+
overflow: hidden;
|
|
9804
|
+
resize: vertical;
|
|
9805
|
+
height: ${({ $headingHeight }) => `${$headingHeight}px`};
|
|
9806
|
+
background: transparent;
|
|
9807
|
+
border: none;
|
|
9808
|
+
outline: 2px solid var(--wui-color-focus-ring);
|
|
9809
|
+
outline-offset: -2px;
|
|
9810
|
+
|
|
9811
|
+
&:focus {
|
|
9812
|
+
outline: 2px solid var(--wui-color-focus-ring);
|
|
9813
|
+
outline-offset: -2px;
|
|
9814
|
+
}
|
|
9815
|
+
`;
|
|
9816
|
+
var StyledHeading2 = (0, import_styled_components65.default)(Heading)`
|
|
9817
|
+
${sharedInputStyles}
|
|
9818
|
+
transition: all var(--wui-motion-duration-01) var(--wui-motion-ease);
|
|
9819
|
+
${({ $editingDisabled }) => !$editingDisabled && import_styled_components65.css`
|
|
9820
|
+
cursor: pointer;
|
|
9821
|
+
|
|
9822
|
+
&:hover {
|
|
9823
|
+
background: var(--wui-color-bg-surface-hover);
|
|
9824
|
+
}
|
|
9825
|
+
`}
|
|
9826
|
+
`;
|
|
9827
|
+
var EditableHeading = ({
|
|
9828
|
+
children,
|
|
9829
|
+
onValueChange,
|
|
9830
|
+
onEditingChange,
|
|
9831
|
+
tooltipText = "Click to edit title",
|
|
9832
|
+
ariaLabel = "Edit title",
|
|
9833
|
+
forceEditing = false,
|
|
9834
|
+
editingDisabled = false,
|
|
9835
|
+
textareaProps,
|
|
9836
|
+
headingProps,
|
|
9837
|
+
dataTestId
|
|
9838
|
+
}) => {
|
|
9839
|
+
const [isEditing, setIsEditing] = (0, import_react46.useState)(false);
|
|
9840
|
+
const [value, setValue] = (0, import_react46.useState)(children);
|
|
9841
|
+
const [previousValue, setPreviousValue] = (0, import_react46.useState)(children);
|
|
9842
|
+
const [headingHeight, setHeadingHeight] = (0, import_react46.useState)("60");
|
|
9843
|
+
const headingRef = (0, import_react46.useRef)(null);
|
|
9844
|
+
const handleSetEditing = (editing) => {
|
|
9845
|
+
if (editingDisabled) return;
|
|
9846
|
+
if (editing && headingRef.current) {
|
|
9847
|
+
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9848
|
+
}
|
|
9849
|
+
if (editing) {
|
|
9850
|
+
setPreviousValue(value);
|
|
9851
|
+
}
|
|
9852
|
+
setIsEditing(editing);
|
|
9853
|
+
onEditingChange?.(editing);
|
|
9854
|
+
};
|
|
9855
|
+
const handleFinishEditing = () => {
|
|
9856
|
+
const trimmedValue = value.trim();
|
|
9857
|
+
if (trimmedValue === "") {
|
|
9858
|
+
setValue(previousValue);
|
|
9859
|
+
} else if (trimmedValue !== previousValue && onValueChange) {
|
|
9860
|
+
onValueChange(trimmedValue);
|
|
9861
|
+
} else {
|
|
9862
|
+
setValue(trimmedValue);
|
|
9863
|
+
}
|
|
9864
|
+
handleSetEditing(false);
|
|
9865
|
+
};
|
|
9866
|
+
const handleKeyDown = (event) => {
|
|
9867
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
9868
|
+
event.preventDefault();
|
|
9869
|
+
handleFinishEditing();
|
|
9870
|
+
}
|
|
9871
|
+
if (event.key === "Escape") {
|
|
9872
|
+
setValue(previousValue);
|
|
9873
|
+
handleSetEditing(false);
|
|
9874
|
+
}
|
|
9875
|
+
};
|
|
9876
|
+
const HeadingComponent2 = /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9877
|
+
StyledHeading2,
|
|
9878
|
+
{
|
|
9879
|
+
...headingProps,
|
|
9880
|
+
ref: headingRef,
|
|
9881
|
+
$editingDisabled: editingDisabled,
|
|
9882
|
+
"data-testid": dataTestId,
|
|
9883
|
+
onClick: () => handleSetEditing(true),
|
|
9884
|
+
variant: "heading1",
|
|
9885
|
+
children: value
|
|
9886
|
+
}
|
|
9887
|
+
);
|
|
9888
|
+
if (editingDisabled) {
|
|
9889
|
+
return HeadingComponent2;
|
|
9890
|
+
}
|
|
9891
|
+
if (isEditing || forceEditing) {
|
|
9892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9893
|
+
StyledEditableHeadingInput,
|
|
9894
|
+
{
|
|
9895
|
+
...textareaProps,
|
|
9896
|
+
$headingHeight: headingHeight,
|
|
9897
|
+
"aria-label": ariaLabel,
|
|
9898
|
+
autoFocus: true,
|
|
9899
|
+
"data-testid": dataTestId,
|
|
9900
|
+
onBlur: handleFinishEditing,
|
|
9901
|
+
onChange: (event) => setValue(event.target.value),
|
|
9902
|
+
onFocus: (event) => {
|
|
9903
|
+
const { length } = event.currentTarget.value;
|
|
9904
|
+
event.currentTarget.setSelectionRange(length, length);
|
|
9905
|
+
},
|
|
9906
|
+
onKeyDown: handleKeyDown,
|
|
9907
|
+
value,
|
|
9908
|
+
children: value
|
|
9909
|
+
}
|
|
9910
|
+
);
|
|
9911
|
+
}
|
|
9912
|
+
return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(import_jsx_runtime214.Fragment, { children: [
|
|
9913
|
+
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9914
|
+
Tooltip,
|
|
9915
|
+
{
|
|
9916
|
+
compact: true,
|
|
9917
|
+
content: tooltipText,
|
|
9918
|
+
children: HeadingComponent2
|
|
9919
|
+
}
|
|
9920
|
+
),
|
|
9921
|
+
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(ScreenReaderOnly, { children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9922
|
+
"button",
|
|
9923
|
+
{
|
|
9924
|
+
"aria-label": ariaLabel,
|
|
9925
|
+
onClick: () => handleSetEditing(true),
|
|
9926
|
+
type: "button"
|
|
9927
|
+
}
|
|
9928
|
+
) })
|
|
9929
|
+
] });
|
|
9930
|
+
};
|
|
9778
9931
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9779
9932
|
0 && (module.exports = {
|
|
9780
9933
|
ActionButton,
|
|
@@ -9794,6 +9947,7 @@ var DataCardTrend = ({
|
|
|
9794
9947
|
DataCardTrend,
|
|
9795
9948
|
DataCards,
|
|
9796
9949
|
Divider,
|
|
9950
|
+
EditableHeading,
|
|
9797
9951
|
Ellipsis,
|
|
9798
9952
|
Form,
|
|
9799
9953
|
FormErrorSummary,
|