@wistia/ui 0.5.0-beta.c2166ce5.bf657fa → 0.5.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/index.cjs +1 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -56
- package/dist/index.d.ts +1 -56
- package/dist/index.mjs +1 -154
- 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.0
|
|
3
|
+
* @license @wistia/ui v0.5.0
|
|
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,
|
|
@@ -9383,158 +9382,6 @@ var DataCardTrend = ({
|
|
|
9383
9382
|
)
|
|
9384
9383
|
] });
|
|
9385
9384
|
};
|
|
9386
|
-
|
|
9387
|
-
// src/components/EditableHeading/EditableHeading.tsx
|
|
9388
|
-
var import_styled_components65 = __toESM(require("styled-components"));
|
|
9389
|
-
var import_react46 = require("react");
|
|
9390
|
-
var import_jsx_runtime214 = require("react/jsx-runtime");
|
|
9391
|
-
var sharedInputStyles = import_styled_components65.css`
|
|
9392
|
-
padding: var(--wui-space-02);
|
|
9393
|
-
border-radius: var(--wui-border-radius-01);
|
|
9394
|
-
overflow-wrap: anywhere;
|
|
9395
|
-
`;
|
|
9396
|
-
var StyledEditableHeadingInput = import_styled_components65.default.textarea`
|
|
9397
|
-
:not([rows]) {
|
|
9398
|
-
min-height: unset;
|
|
9399
|
-
}
|
|
9400
|
-
|
|
9401
|
-
${sharedInputStyles}
|
|
9402
|
-
font-size: var(--wui-typography-heading-1-size);
|
|
9403
|
-
font-weight: var(--wui-typography-heading-1-weight);
|
|
9404
|
-
line-height: var(--wui-typography-heading-1-line-height);
|
|
9405
|
-
font-family: var(--wui-typography-heading-1-family);
|
|
9406
|
-
width: 100%;
|
|
9407
|
-
box-sizing: border-box;
|
|
9408
|
-
margin: 0;
|
|
9409
|
-
display: block;
|
|
9410
|
-
overflow: hidden;
|
|
9411
|
-
resize: vertical;
|
|
9412
|
-
height: ${({ $headingHeight }) => `${$headingHeight}px`};
|
|
9413
|
-
background: transparent;
|
|
9414
|
-
border: none;
|
|
9415
|
-
outline: 2px solid var(--wui-color-focus-ring);
|
|
9416
|
-
outline-offset: -2px;
|
|
9417
|
-
|
|
9418
|
-
&:focus {
|
|
9419
|
-
outline: 2px solid var(--wui-color-focus-ring);
|
|
9420
|
-
outline-offset: -2px;
|
|
9421
|
-
}
|
|
9422
|
-
`;
|
|
9423
|
-
var StyledHeading2 = (0, import_styled_components65.default)(Heading)`
|
|
9424
|
-
${sharedInputStyles}
|
|
9425
|
-
transition: all var(--wui-motion-duration-01) var(--wui-motion-ease);
|
|
9426
|
-
${({ $editingDisabled }) => !$editingDisabled && import_styled_components65.css`
|
|
9427
|
-
cursor: pointer;
|
|
9428
|
-
|
|
9429
|
-
&:hover {
|
|
9430
|
-
background: var(--wui-color-bg-surface-hover);
|
|
9431
|
-
}
|
|
9432
|
-
`}
|
|
9433
|
-
`;
|
|
9434
|
-
var EditableHeading = ({
|
|
9435
|
-
children,
|
|
9436
|
-
onValueChange,
|
|
9437
|
-
onEditingChange,
|
|
9438
|
-
tooltipText = "Click to edit title",
|
|
9439
|
-
ariaLabel = "Edit title",
|
|
9440
|
-
forceEditing = false,
|
|
9441
|
-
editingDisabled = false,
|
|
9442
|
-
textareaProps,
|
|
9443
|
-
headingProps,
|
|
9444
|
-
dataTestId
|
|
9445
|
-
}) => {
|
|
9446
|
-
const [isEditing, setIsEditing] = (0, import_react46.useState)(false);
|
|
9447
|
-
const [value, setValue] = (0, import_react46.useState)(children);
|
|
9448
|
-
const [previousValue, setPreviousValue] = (0, import_react46.useState)(children);
|
|
9449
|
-
const [headingHeight, setHeadingHeight] = (0, import_react46.useState)("60");
|
|
9450
|
-
const headingRef = (0, import_react46.useRef)(null);
|
|
9451
|
-
const handleSetEditing = (editing) => {
|
|
9452
|
-
if (editingDisabled) return;
|
|
9453
|
-
if (editing && headingRef.current) {
|
|
9454
|
-
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9455
|
-
}
|
|
9456
|
-
if (editing) {
|
|
9457
|
-
setPreviousValue(value);
|
|
9458
|
-
}
|
|
9459
|
-
setIsEditing(editing);
|
|
9460
|
-
onEditingChange?.(editing);
|
|
9461
|
-
};
|
|
9462
|
-
const handleFinishEditing = () => {
|
|
9463
|
-
const trimmedValue = value.trim();
|
|
9464
|
-
if (trimmedValue === "") {
|
|
9465
|
-
setValue(previousValue);
|
|
9466
|
-
} else if (trimmedValue !== previousValue && onValueChange) {
|
|
9467
|
-
onValueChange(trimmedValue);
|
|
9468
|
-
} else {
|
|
9469
|
-
setValue(trimmedValue);
|
|
9470
|
-
}
|
|
9471
|
-
handleSetEditing(false);
|
|
9472
|
-
};
|
|
9473
|
-
const handleKeyDown = (event) => {
|
|
9474
|
-
if (event.key === "Enter" && !event.shiftKey) {
|
|
9475
|
-
event.preventDefault();
|
|
9476
|
-
handleFinishEditing();
|
|
9477
|
-
}
|
|
9478
|
-
if (event.key === "Escape") {
|
|
9479
|
-
setValue(previousValue);
|
|
9480
|
-
handleSetEditing(false);
|
|
9481
|
-
}
|
|
9482
|
-
};
|
|
9483
|
-
const HeadingComponent2 = /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9484
|
-
StyledHeading2,
|
|
9485
|
-
{
|
|
9486
|
-
...headingProps,
|
|
9487
|
-
ref: headingRef,
|
|
9488
|
-
$editingDisabled: editingDisabled,
|
|
9489
|
-
"data-testid": dataTestId,
|
|
9490
|
-
onClick: () => handleSetEditing(true),
|
|
9491
|
-
variant: "heading1",
|
|
9492
|
-
children: value
|
|
9493
|
-
}
|
|
9494
|
-
);
|
|
9495
|
-
if (editingDisabled) {
|
|
9496
|
-
return HeadingComponent2;
|
|
9497
|
-
}
|
|
9498
|
-
if (isEditing || forceEditing) {
|
|
9499
|
-
return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9500
|
-
StyledEditableHeadingInput,
|
|
9501
|
-
{
|
|
9502
|
-
...textareaProps,
|
|
9503
|
-
$headingHeight: headingHeight,
|
|
9504
|
-
"aria-label": ariaLabel,
|
|
9505
|
-
autoFocus: true,
|
|
9506
|
-
"data-testid": dataTestId,
|
|
9507
|
-
onBlur: handleFinishEditing,
|
|
9508
|
-
onChange: (event) => setValue(event.target.value),
|
|
9509
|
-
onFocus: (event) => {
|
|
9510
|
-
const { length } = event.currentTarget.value;
|
|
9511
|
-
event.currentTarget.setSelectionRange(length, length);
|
|
9512
|
-
},
|
|
9513
|
-
onKeyDown: handleKeyDown,
|
|
9514
|
-
value,
|
|
9515
|
-
children: value
|
|
9516
|
-
}
|
|
9517
|
-
);
|
|
9518
|
-
}
|
|
9519
|
-
return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(import_jsx_runtime214.Fragment, { children: [
|
|
9520
|
-
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9521
|
-
Tooltip,
|
|
9522
|
-
{
|
|
9523
|
-
compact: true,
|
|
9524
|
-
content: tooltipText,
|
|
9525
|
-
children: HeadingComponent2
|
|
9526
|
-
}
|
|
9527
|
-
),
|
|
9528
|
-
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(ScreenReaderOnly, { children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9529
|
-
"button",
|
|
9530
|
-
{
|
|
9531
|
-
"aria-label": ariaLabel,
|
|
9532
|
-
onClick: () => handleSetEditing(true),
|
|
9533
|
-
type: "button"
|
|
9534
|
-
}
|
|
9535
|
-
) })
|
|
9536
|
-
] });
|
|
9537
|
-
};
|
|
9538
9385
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9539
9386
|
0 && (module.exports = {
|
|
9540
9387
|
ActionButton,
|
|
@@ -9554,7 +9401,6 @@ var EditableHeading = ({
|
|
|
9554
9401
|
DataCardTrend,
|
|
9555
9402
|
DataCards,
|
|
9556
9403
|
Divider,
|
|
9557
|
-
EditableHeading,
|
|
9558
9404
|
Ellipsis,
|
|
9559
9405
|
Form,
|
|
9560
9406
|
FormErrorSummary,
|