@wistia/ui 0.5.2-beta.e9c9ab1e.5bceb43 → 0.5.2
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 +1 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +13 -60
- package/dist/index.d.ts +13 -60
- package/dist/index.mjs +1 -148
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.5.2
|
|
3
|
+
* @license @wistia/ui v0.5.2
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -56,7 +56,6 @@ __export(index_exports, {
|
|
|
56
56
|
DataCardTrend: () => DataCardTrend,
|
|
57
57
|
DataCards: () => DataCards,
|
|
58
58
|
Divider: () => Divider,
|
|
59
|
-
EditableHeading: () => EditableHeading,
|
|
60
59
|
Ellipsis: () => Ellipsis,
|
|
61
60
|
Form: () => Form,
|
|
62
61
|
FormErrorSummary: () => FormErrorSummary,
|
|
@@ -9776,152 +9775,6 @@ var DataCardTrend = ({
|
|
|
9776
9775
|
)
|
|
9777
9776
|
] });
|
|
9778
9777
|
};
|
|
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
|
-
inputProps,
|
|
9831
|
-
headingProps,
|
|
9832
|
-
"data-testid": dataTestId
|
|
9833
|
-
}) => {
|
|
9834
|
-
const [isEditing, setIsEditing] = (0, import_react46.useState)(false);
|
|
9835
|
-
const [value, setValue] = (0, import_react46.useState)(children);
|
|
9836
|
-
const [previousValue, setPreviousValue] = (0, import_react46.useState)(children);
|
|
9837
|
-
const [headingHeight, setHeadingHeight] = (0, import_react46.useState)("60");
|
|
9838
|
-
const headingRef = (0, import_react46.useRef)(null);
|
|
9839
|
-
const handleSetEditing = (editing) => {
|
|
9840
|
-
if (editingDisabled) return;
|
|
9841
|
-
if (editing && headingRef.current) {
|
|
9842
|
-
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9843
|
-
}
|
|
9844
|
-
if (editing) {
|
|
9845
|
-
setPreviousValue(value);
|
|
9846
|
-
}
|
|
9847
|
-
setIsEditing(editing);
|
|
9848
|
-
onEditingChange?.(editing);
|
|
9849
|
-
};
|
|
9850
|
-
const handleFinishEditing = () => {
|
|
9851
|
-
const trimmedValue = value.trim();
|
|
9852
|
-
if (trimmedValue === "") {
|
|
9853
|
-
setValue(previousValue);
|
|
9854
|
-
} else if (trimmedValue !== previousValue && onValueChange) {
|
|
9855
|
-
onValueChange(trimmedValue);
|
|
9856
|
-
} else {
|
|
9857
|
-
setValue(trimmedValue);
|
|
9858
|
-
}
|
|
9859
|
-
handleSetEditing(false);
|
|
9860
|
-
};
|
|
9861
|
-
const handleKeyDown = (event) => {
|
|
9862
|
-
if (event.key === "Enter" && !event.shiftKey) {
|
|
9863
|
-
event.preventDefault();
|
|
9864
|
-
handleFinishEditing();
|
|
9865
|
-
}
|
|
9866
|
-
if (event.key === "Escape") {
|
|
9867
|
-
setValue(previousValue);
|
|
9868
|
-
handleSetEditing(false);
|
|
9869
|
-
}
|
|
9870
|
-
};
|
|
9871
|
-
const HeadingComponent2 = /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9872
|
-
StyledHeading2,
|
|
9873
|
-
{
|
|
9874
|
-
...headingProps,
|
|
9875
|
-
ref: headingRef,
|
|
9876
|
-
$editingDisabled: editingDisabled,
|
|
9877
|
-
"data-testid": `${dataTestId} ${dataTestId}-heading`,
|
|
9878
|
-
onClick: () => handleSetEditing(true),
|
|
9879
|
-
variant: "heading1",
|
|
9880
|
-
children: value
|
|
9881
|
-
}
|
|
9882
|
-
);
|
|
9883
|
-
if (editingDisabled) {
|
|
9884
|
-
return HeadingComponent2;
|
|
9885
|
-
}
|
|
9886
|
-
if (isEditing || forceEditing) {
|
|
9887
|
-
return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9888
|
-
StyledInput,
|
|
9889
|
-
{
|
|
9890
|
-
...inputProps,
|
|
9891
|
-
$height: headingHeight,
|
|
9892
|
-
autoFocus: true,
|
|
9893
|
-
fullWidth: true,
|
|
9894
|
-
onBlur: handleFinishEditing,
|
|
9895
|
-
onChange: (event) => setValue(event.target.value),
|
|
9896
|
-
onFocus: (event) => {
|
|
9897
|
-
const { length } = event.currentTarget.value;
|
|
9898
|
-
event.currentTarget.setSelectionRange(length, length);
|
|
9899
|
-
},
|
|
9900
|
-
onKeyDown: handleKeyDown,
|
|
9901
|
-
type: "multiline",
|
|
9902
|
-
value
|
|
9903
|
-
}
|
|
9904
|
-
);
|
|
9905
|
-
}
|
|
9906
|
-
return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(import_jsx_runtime214.Fragment, { children: [
|
|
9907
|
-
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9908
|
-
Tooltip,
|
|
9909
|
-
{
|
|
9910
|
-
compact: true,
|
|
9911
|
-
content: tooltipText,
|
|
9912
|
-
children: HeadingComponent2
|
|
9913
|
-
}
|
|
9914
|
-
),
|
|
9915
|
-
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(ScreenReaderOnly, { children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9916
|
-
"button",
|
|
9917
|
-
{
|
|
9918
|
-
"aria-label": ariaLabel,
|
|
9919
|
-
onClick: () => handleSetEditing(true),
|
|
9920
|
-
type: "button"
|
|
9921
|
-
}
|
|
9922
|
-
) })
|
|
9923
|
-
] });
|
|
9924
|
-
};
|
|
9925
9778
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9926
9779
|
0 && (module.exports = {
|
|
9927
9780
|
ActionButton,
|
|
@@ -9941,7 +9794,6 @@ var EditableHeading = ({
|
|
|
9941
9794
|
DataCardTrend,
|
|
9942
9795
|
DataCards,
|
|
9943
9796
|
Divider,
|
|
9944
|
-
EditableHeading,
|
|
9945
9797
|
Ellipsis,
|
|
9946
9798
|
Form,
|
|
9947
9799
|
FormErrorSummary,
|