@wistia/ui 0.5.0-beta.1aeeeb0e.90a89da → 0.5.0-beta.c2166ce5.bf657fa
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 +60 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +34 -4
- package/dist/index.d.ts +34 -4
- package/dist/index.mjs +60 -36
- 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-beta.
|
|
3
|
+
* @license @wistia/ui v0.5.0-beta.c2166ce5.bf657fa
|
|
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,
|
|
@@ -65,7 +66,6 @@ __export(index_exports, {
|
|
|
65
66
|
Icon: () => Icon,
|
|
66
67
|
IconButton: () => IconButton,
|
|
67
68
|
Input: () => Input,
|
|
68
|
-
InputHeading: () => InputHeading,
|
|
69
69
|
Label: () => Label,
|
|
70
70
|
Link: () => Link,
|
|
71
71
|
Menu: () => Menu,
|
|
@@ -9384,7 +9384,7 @@ var DataCardTrend = ({
|
|
|
9384
9384
|
] });
|
|
9385
9385
|
};
|
|
9386
9386
|
|
|
9387
|
-
// src/components/
|
|
9387
|
+
// src/components/EditableHeading/EditableHeading.tsx
|
|
9388
9388
|
var import_styled_components65 = __toESM(require("styled-components"));
|
|
9389
9389
|
var import_react46 = require("react");
|
|
9390
9390
|
var import_jsx_runtime214 = require("react/jsx-runtime");
|
|
@@ -9393,26 +9393,25 @@ var sharedInputStyles = import_styled_components65.css`
|
|
|
9393
9393
|
border-radius: var(--wui-border-radius-01);
|
|
9394
9394
|
overflow-wrap: anywhere;
|
|
9395
9395
|
`;
|
|
9396
|
-
var
|
|
9396
|
+
var StyledEditableHeadingInput = import_styled_components65.default.textarea`
|
|
9397
|
+
:not([rows]) {
|
|
9398
|
+
min-height: unset;
|
|
9399
|
+
}
|
|
9400
|
+
|
|
9397
9401
|
${sharedInputStyles}
|
|
9398
9402
|
font-size: var(--wui-typography-heading-1-size);
|
|
9399
9403
|
font-weight: var(--wui-typography-heading-1-weight);
|
|
9400
9404
|
line-height: var(--wui-typography-heading-1-line-height);
|
|
9401
9405
|
font-family: var(--wui-typography-heading-1-family);
|
|
9402
9406
|
width: 100%;
|
|
9403
|
-
min-height: 44px;
|
|
9404
9407
|
box-sizing: border-box;
|
|
9405
9408
|
margin: 0;
|
|
9406
9409
|
display: block;
|
|
9407
|
-
resize: none;
|
|
9408
9410
|
overflow: hidden;
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
field-sizing: content;
|
|
9412
|
-
|
|
9411
|
+
resize: vertical;
|
|
9412
|
+
height: ${({ $headingHeight }) => `${$headingHeight}px`};
|
|
9413
9413
|
background: transparent;
|
|
9414
9414
|
border: none;
|
|
9415
|
-
|
|
9416
9415
|
outline: 2px solid var(--wui-color-focus-ring);
|
|
9417
9416
|
outline-offset: -2px;
|
|
9418
9417
|
|
|
@@ -9420,30 +9419,40 @@ var StyledInputHeading = import_styled_components65.default.textarea`
|
|
|
9420
9419
|
outline: 2px solid var(--wui-color-focus-ring);
|
|
9421
9420
|
outline-offset: -2px;
|
|
9422
9421
|
}
|
|
9423
|
-
|
|
9424
|
-
:not([rows]) {
|
|
9425
|
-
min-height: 44px;
|
|
9426
|
-
}
|
|
9427
9422
|
`;
|
|
9428
9423
|
var StyledHeading2 = (0, import_styled_components65.default)(Heading)`
|
|
9429
9424
|
${sharedInputStyles}
|
|
9430
|
-
|
|
9431
|
-
|
|
9425
|
+
transition: all var(--wui-motion-duration-01) var(--wui-motion-ease);
|
|
9426
|
+
${({ $editingDisabled }) => !$editingDisabled && import_styled_components65.css`
|
|
9427
|
+
cursor: pointer;
|
|
9432
9428
|
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9429
|
+
&:hover {
|
|
9430
|
+
background: var(--wui-color-bg-surface-hover);
|
|
9431
|
+
}
|
|
9432
|
+
`}
|
|
9436
9433
|
`;
|
|
9437
|
-
var
|
|
9434
|
+
var EditableHeading = ({
|
|
9438
9435
|
children,
|
|
9439
9436
|
onValueChange,
|
|
9440
9437
|
onEditingChange,
|
|
9441
|
-
|
|
9438
|
+
tooltipText = "Click to edit title",
|
|
9439
|
+
ariaLabel = "Edit title",
|
|
9440
|
+
forceEditing = false,
|
|
9441
|
+
editingDisabled = false,
|
|
9442
|
+
textareaProps,
|
|
9443
|
+
headingProps,
|
|
9444
|
+
dataTestId
|
|
9442
9445
|
}) => {
|
|
9443
9446
|
const [isEditing, setIsEditing] = (0, import_react46.useState)(false);
|
|
9444
9447
|
const [value, setValue] = (0, import_react46.useState)(children);
|
|
9445
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);
|
|
9446
9451
|
const handleSetEditing = (editing) => {
|
|
9452
|
+
if (editingDisabled) return;
|
|
9453
|
+
if (editing && headingRef.current) {
|
|
9454
|
+
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9455
|
+
}
|
|
9447
9456
|
if (editing) {
|
|
9448
9457
|
setPreviousValue(value);
|
|
9449
9458
|
}
|
|
@@ -9471,14 +9480,36 @@ var InputHeading = ({
|
|
|
9471
9480
|
handleSetEditing(false);
|
|
9472
9481
|
}
|
|
9473
9482
|
};
|
|
9474
|
-
|
|
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) {
|
|
9475
9499
|
return /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9476
|
-
|
|
9500
|
+
StyledEditableHeadingInput,
|
|
9477
9501
|
{
|
|
9478
|
-
...
|
|
9502
|
+
...textareaProps,
|
|
9503
|
+
$headingHeight: headingHeight,
|
|
9504
|
+
"aria-label": ariaLabel,
|
|
9479
9505
|
autoFocus: true,
|
|
9506
|
+
"data-testid": dataTestId,
|
|
9480
9507
|
onBlur: handleFinishEditing,
|
|
9481
9508
|
onChange: (event) => setValue(event.target.value),
|
|
9509
|
+
onFocus: (event) => {
|
|
9510
|
+
const { length } = event.currentTarget.value;
|
|
9511
|
+
event.currentTarget.setSelectionRange(length, length);
|
|
9512
|
+
},
|
|
9482
9513
|
onKeyDown: handleKeyDown,
|
|
9483
9514
|
value,
|
|
9484
9515
|
children: value
|
|
@@ -9490,21 +9521,14 @@ var InputHeading = ({
|
|
|
9490
9521
|
Tooltip,
|
|
9491
9522
|
{
|
|
9492
9523
|
compact: true,
|
|
9493
|
-
content:
|
|
9494
|
-
children:
|
|
9495
|
-
StyledHeading2,
|
|
9496
|
-
{
|
|
9497
|
-
onClick: () => handleSetEditing(true),
|
|
9498
|
-
variant: "heading1",
|
|
9499
|
-
children: value
|
|
9500
|
-
}
|
|
9501
|
-
)
|
|
9524
|
+
content: tooltipText,
|
|
9525
|
+
children: HeadingComponent2
|
|
9502
9526
|
}
|
|
9503
9527
|
),
|
|
9504
9528
|
/* @__PURE__ */ (0, import_jsx_runtime214.jsx)(ScreenReaderOnly, { children: /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
|
|
9505
9529
|
"button",
|
|
9506
9530
|
{
|
|
9507
|
-
"aria-label":
|
|
9531
|
+
"aria-label": ariaLabel,
|
|
9508
9532
|
onClick: () => handleSetEditing(true),
|
|
9509
9533
|
type: "button"
|
|
9510
9534
|
}
|
|
@@ -9530,6 +9554,7 @@ var InputHeading = ({
|
|
|
9530
9554
|
DataCardTrend,
|
|
9531
9555
|
DataCards,
|
|
9532
9556
|
Divider,
|
|
9557
|
+
EditableHeading,
|
|
9533
9558
|
Ellipsis,
|
|
9534
9559
|
Form,
|
|
9535
9560
|
FormErrorSummary,
|
|
@@ -9539,7 +9564,6 @@ var InputHeading = ({
|
|
|
9539
9564
|
Icon,
|
|
9540
9565
|
IconButton,
|
|
9541
9566
|
Input,
|
|
9542
|
-
InputHeading,
|
|
9543
9567
|
Label,
|
|
9544
9568
|
Link,
|
|
9545
9569
|
Menu,
|