@wistia/ui 0.5.2-beta.a848ca2c.7febb8d → 0.5.2-beta.afcce0d8.98f1a2c
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 +143 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.mjs +142 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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.afcce0d8.98f1a2c
|
|
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,
|
|
@@ -9775,6 +9776,146 @@ 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 StyledInput = (0, import_styled_components65.default)(Input)`
|
|
9785
|
+
:not([rows]) {
|
|
9786
|
+
min-height: unset;
|
|
9787
|
+
}
|
|
9788
|
+
|
|
9789
|
+
resize: vertical;
|
|
9790
|
+
font-size: var(--wui-typography-heading-1-size);
|
|
9791
|
+
font-weight: var(--wui-typography-heading-1-weight);
|
|
9792
|
+
line-height: var(--wui-typography-heading-1-line-height);
|
|
9793
|
+
font-family: var(--wui-typography-heading-1-family);
|
|
9794
|
+
outline: 2px solid var(--wui-color-focus-ring);
|
|
9795
|
+
outline-offset: -2px;
|
|
9796
|
+
|
|
9797
|
+
&& {
|
|
9798
|
+
width: 100%;
|
|
9799
|
+
padding: var(--wui-space-02);
|
|
9800
|
+
border: none;
|
|
9801
|
+
height: ${({ $height }) => `${$height}px`};
|
|
9802
|
+
}
|
|
9803
|
+
`;
|
|
9804
|
+
var editableStyles = import_styled_components65.css`
|
|
9805
|
+
&:has(+ :focus-within) {
|
|
9806
|
+
background: var(--wui-color-bg-surface-hover);
|
|
9807
|
+
}
|
|
9808
|
+
|
|
9809
|
+
&:hover {
|
|
9810
|
+
background: var(--wui-color-bg-surface-hover);
|
|
9811
|
+
cursor: pointer;
|
|
9812
|
+
}
|
|
9813
|
+
`;
|
|
9814
|
+
var StyledHeading2 = (0, import_styled_components65.default)(Heading)`
|
|
9815
|
+
width: 100%;
|
|
9816
|
+
border-radius: var(--wui-border-radius-02);
|
|
9817
|
+
padding: var(--wui-space-02);
|
|
9818
|
+
overflow-wrap: anywhere;
|
|
9819
|
+
transition: all var(--wui-motion-duration-01) var(--wui-motion-ease);
|
|
9820
|
+
${({ $editingDisabled }) => !$editingDisabled && editableStyles}
|
|
9821
|
+
`;
|
|
9822
|
+
var EditableHeading = ({
|
|
9823
|
+
children,
|
|
9824
|
+
onValueChange,
|
|
9825
|
+
onEditingChange,
|
|
9826
|
+
tooltipText = "Click to edit title",
|
|
9827
|
+
ariaLabel = "Edit title",
|
|
9828
|
+
forceEditing = false,
|
|
9829
|
+
editingDisabled = false
|
|
9830
|
+
}) => {
|
|
9831
|
+
const [isEditing, setIsEditing] = (0, import_react46.useState)(false);
|
|
9832
|
+
const [value, setValue] = (0, import_react46.useState)(children);
|
|
9833
|
+
const [previousValue, setPreviousValue] = (0, import_react46.useState)(children);
|
|
9834
|
+
const [headingHeight, setHeadingHeight] = (0, import_react46.useState)("60");
|
|
9835
|
+
const headingRef = (0, import_react46.useRef)(null);
|
|
9836
|
+
const handleSetEditing = (editing) => {
|
|
9837
|
+
if (editingDisabled) return;
|
|
9838
|
+
if (editing && headingRef.current) {
|
|
9839
|
+
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9840
|
+
}
|
|
9841
|
+
if (editing) {
|
|
9842
|
+
setPreviousValue(value);
|
|
9843
|
+
}
|
|
9844
|
+
setIsEditing(editing);
|
|
9845
|
+
onEditingChange?.(editing);
|
|
9846
|
+
};
|
|
9847
|
+
const handleFinishEditing = () => {
|
|
9848
|
+
const trimmedValue = value.trim();
|
|
9849
|
+
if (trimmedValue === "") {
|
|
9850
|
+
setValue(previousValue);
|
|
9851
|
+
} else if (trimmedValue !== previousValue && onValueChange) {
|
|
9852
|
+
onValueChange(trimmedValue);
|
|
9853
|
+
} else {
|
|
9854
|
+
setValue(trimmedValue);
|
|
9855
|
+
}
|
|
9856
|
+
handleSetEditing(false);
|
|
9857
|
+
};
|
|
9858
|
+
const handleKeyDown = (event) => {
|
|
9859
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
9860
|
+
event.preventDefault();
|
|
9861
|
+
handleFinishEditing();
|
|
9862
|
+
}
|
|
9863
|
+
if (event.key === "Escape") {
|
|
9864
|
+
setValue(previousValue);
|
|
9865
|
+
handleSetEditing(false);
|
|
9866
|
+
}
|
|
9867
|
+
};
|
|
9868
|
+
const HeadingComponent2 = /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9869
|
+
StyledHeading2,
|
|
9870
|
+
{
|
|
9871
|
+
ref: headingRef,
|
|
9872
|
+
$editingDisabled: editingDisabled,
|
|
9873
|
+
onClick: () => handleSetEditing(true),
|
|
9874
|
+
variant: "heading1",
|
|
9875
|
+
children: value
|
|
9876
|
+
}
|
|
9877
|
+
);
|
|
9878
|
+
if (editingDisabled) {
|
|
9879
|
+
return HeadingComponent2;
|
|
9880
|
+
}
|
|
9881
|
+
if (isEditing || forceEditing) {
|
|
9882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9883
|
+
StyledInput,
|
|
9884
|
+
{
|
|
9885
|
+
$height: headingHeight,
|
|
9886
|
+
autoFocus: true,
|
|
9887
|
+
fullWidth: true,
|
|
9888
|
+
onBlur: handleFinishEditing,
|
|
9889
|
+
onChange: (event) => setValue(event.target.value),
|
|
9890
|
+
onFocus: (event) => {
|
|
9891
|
+
const { length } = event.currentTarget.value;
|
|
9892
|
+
event.currentTarget.setSelectionRange(length, length);
|
|
9893
|
+
},
|
|
9894
|
+
onKeyDown: handleKeyDown,
|
|
9895
|
+
type: "multiline",
|
|
9896
|
+
value
|
|
9897
|
+
}
|
|
9898
|
+
);
|
|
9899
|
+
}
|
|
9900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(import_jsx_runtime214.Fragment, { children: [
|
|
9901
|
+
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9902
|
+
Tooltip,
|
|
9903
|
+
{
|
|
9904
|
+
compact: true,
|
|
9905
|
+
content: tooltipText,
|
|
9906
|
+
children: HeadingComponent2
|
|
9907
|
+
}
|
|
9908
|
+
),
|
|
9909
|
+
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(ScreenReaderOnly, { children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9910
|
+
"button",
|
|
9911
|
+
{
|
|
9912
|
+
"aria-label": ariaLabel,
|
|
9913
|
+
onClick: () => handleSetEditing(true),
|
|
9914
|
+
type: "button"
|
|
9915
|
+
}
|
|
9916
|
+
) })
|
|
9917
|
+
] });
|
|
9918
|
+
};
|
|
9778
9919
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9779
9920
|
0 && (module.exports = {
|
|
9780
9921
|
ActionButton,
|
|
@@ -9794,6 +9935,7 @@ var DataCardTrend = ({
|
|
|
9794
9935
|
DataCardTrend,
|
|
9795
9936
|
DataCards,
|
|
9796
9937
|
Divider,
|
|
9938
|
+
EditableHeading,
|
|
9797
9939
|
Ellipsis,
|
|
9798
9940
|
Form,
|
|
9799
9941
|
FormErrorSummary,
|