@wistia/ui 0.14.20 → 0.14.21-beta.34df95e5.9f33fdd
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 +499 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +165 -2
- package/dist/index.d.ts +165 -2
- package/dist/index.mjs +496 -11
- 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.14.
|
|
3
|
+
* @license @wistia/ui v0.14.21-beta.34df95e5.9f33fdd
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -82,6 +82,15 @@ __export(index_exports, {
|
|
|
82
82
|
DataListItemValue: () => DataListItemValue,
|
|
83
83
|
Divider: () => Divider,
|
|
84
84
|
EditableHeading: () => EditableHeading,
|
|
85
|
+
EditableText: () => EditableText,
|
|
86
|
+
EditableTextCancelButton: () => EditableTextCancelButton,
|
|
87
|
+
EditableTextContext: () => EditableTextContext,
|
|
88
|
+
EditableTextDisplay: () => EditableTextDisplay,
|
|
89
|
+
EditableTextInput: () => EditableTextInput,
|
|
90
|
+
EditableTextLabel: () => EditableTextLabel,
|
|
91
|
+
EditableTextRoot: () => EditableTextRoot,
|
|
92
|
+
EditableTextSubmitButton: () => EditableTextSubmitButton,
|
|
93
|
+
EditableTextTrigger: () => EditableTextTrigger,
|
|
85
94
|
Ellipsis: () => Ellipsis,
|
|
86
95
|
FileAmountLimitValidator: () => import_validators.FileAmountLimitValidator,
|
|
87
96
|
FileSizeValidator: () => import_validators.FileSizeValidator,
|
|
@@ -11334,6 +11343,7 @@ var Input = (0, import_react47.forwardRef)(
|
|
|
11334
11343
|
{
|
|
11335
11344
|
$fullWidth: fullWidth,
|
|
11336
11345
|
$monospace: monospace,
|
|
11346
|
+
"data-wui-input-container": true,
|
|
11337
11347
|
children: [
|
|
11338
11348
|
leftIconToDisplay ?? null,
|
|
11339
11349
|
type === "multiline" ? /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
|
|
@@ -16389,9 +16399,14 @@ var getFramePosition = (frameIndex, framesPerRow, width, height, scaleFactor, fr
|
|
|
16389
16399
|
const row = Math.floor(frameIndex / framesPerRow);
|
|
16390
16400
|
const imageX = -width * col * scaleFactor;
|
|
16391
16401
|
const imageY = -height * row * scaleFactor;
|
|
16392
|
-
|
|
16393
|
-
|
|
16394
|
-
|
|
16402
|
+
let verticalCenterOffset = 0;
|
|
16403
|
+
if (height > width) {
|
|
16404
|
+
const rows = Math.ceil(frameCount / framesPerRow);
|
|
16405
|
+
const frameHeightInStoryboard = height / rows;
|
|
16406
|
+
verticalCenterOffset = Math.max(0, (targetHeight - frameHeightInStoryboard) / 2);
|
|
16407
|
+
} else {
|
|
16408
|
+
verticalCenterOffset = 0;
|
|
16409
|
+
}
|
|
16395
16410
|
const adjustedY = imageY - verticalCenterOffset;
|
|
16396
16411
|
return `${imageX}px ${adjustedY}px`;
|
|
16397
16412
|
};
|
|
@@ -17006,10 +17021,474 @@ var ContextMenu = ({
|
|
|
17006
17021
|
) : null;
|
|
17007
17022
|
};
|
|
17008
17023
|
|
|
17009
|
-
// src/components/
|
|
17024
|
+
// src/components/EditableText/EditableTextDisplay.tsx
|
|
17025
|
+
var import_react92 = require("react");
|
|
17026
|
+
var import_styled_components123 = __toESM(require("styled-components"));
|
|
17027
|
+
var import_type_guards73 = require("@wistia/type-guards");
|
|
17028
|
+
|
|
17029
|
+
// src/components/EditableText/EditableTextRoot.tsx
|
|
17030
|
+
var import_react91 = require("react");
|
|
17031
|
+
var import_type_guards72 = require("@wistia/type-guards");
|
|
17010
17032
|
var import_styled_components121 = __toESM(require("styled-components"));
|
|
17011
17033
|
var import_jsx_runtime317 = require("react/jsx-runtime");
|
|
17012
|
-
var
|
|
17034
|
+
var StyledEditableTextRoot = import_styled_components121.default.div`
|
|
17035
|
+
display: contents;
|
|
17036
|
+
|
|
17037
|
+
--wui-editable-text-padding: var(--wui-space-01);
|
|
17038
|
+
--wui-editable-text-border-radius: var(--wui-border-radius-01);
|
|
17039
|
+
`;
|
|
17040
|
+
var EditableTextContext = (0, import_react91.createContext)(null);
|
|
17041
|
+
var EditableTextRoot = ({
|
|
17042
|
+
children,
|
|
17043
|
+
defaultValue = "",
|
|
17044
|
+
value: controlledValue,
|
|
17045
|
+
onValueChange,
|
|
17046
|
+
onValueCommit,
|
|
17047
|
+
onValueRevert,
|
|
17048
|
+
onEditingChange,
|
|
17049
|
+
typographicVariant = "body2",
|
|
17050
|
+
submitMode = "both",
|
|
17051
|
+
readOnly = false,
|
|
17052
|
+
id,
|
|
17053
|
+
label,
|
|
17054
|
+
placeholder = "Click to edit this text",
|
|
17055
|
+
minLines = 1,
|
|
17056
|
+
maxLines,
|
|
17057
|
+
finalFocusEl,
|
|
17058
|
+
...props
|
|
17059
|
+
}) => {
|
|
17060
|
+
const isControlled = controlledValue !== void 0;
|
|
17061
|
+
const [internalValue, setInternalValue] = (0, import_react91.useState)(defaultValue);
|
|
17062
|
+
const [originalValue, setOriginalValue] = (0, import_react91.useState)(defaultValue);
|
|
17063
|
+
const [isEditing, setIsEditing] = (0, import_react91.useState)(false);
|
|
17064
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
17065
|
+
const generatedId = (0, import_react91.useId)();
|
|
17066
|
+
const computedId = (0, import_type_guards72.isNonEmptyString)(id) ? id : `wistia-ui-editable-text-${generatedId}`;
|
|
17067
|
+
const handleSetIsEditing = (0, import_react91.useCallback)(
|
|
17068
|
+
(editing) => {
|
|
17069
|
+
if (editing && !isEditing) {
|
|
17070
|
+
setOriginalValue(value);
|
|
17071
|
+
}
|
|
17072
|
+
setIsEditing(editing);
|
|
17073
|
+
onEditingChange?.(editing);
|
|
17074
|
+
},
|
|
17075
|
+
[isEditing, value, onEditingChange]
|
|
17076
|
+
);
|
|
17077
|
+
const setValue = (0, import_react91.useCallback)(
|
|
17078
|
+
(newValue) => {
|
|
17079
|
+
if (!isControlled) {
|
|
17080
|
+
setInternalValue(newValue);
|
|
17081
|
+
}
|
|
17082
|
+
onValueChange?.(newValue);
|
|
17083
|
+
},
|
|
17084
|
+
[isControlled, onValueChange]
|
|
17085
|
+
);
|
|
17086
|
+
const context = (0, import_react91.useMemo)(() => {
|
|
17087
|
+
return {
|
|
17088
|
+
isEditing,
|
|
17089
|
+
setIsEditing: handleSetIsEditing,
|
|
17090
|
+
value,
|
|
17091
|
+
setValue,
|
|
17092
|
+
originalValue,
|
|
17093
|
+
onValueCommit,
|
|
17094
|
+
onValueRevert,
|
|
17095
|
+
typographicVariant,
|
|
17096
|
+
submitMode,
|
|
17097
|
+
readOnly,
|
|
17098
|
+
id: computedId,
|
|
17099
|
+
label,
|
|
17100
|
+
placeholder,
|
|
17101
|
+
minLines,
|
|
17102
|
+
maxLines,
|
|
17103
|
+
finalFocusEl
|
|
17104
|
+
};
|
|
17105
|
+
}, [
|
|
17106
|
+
isEditing,
|
|
17107
|
+
handleSetIsEditing,
|
|
17108
|
+
value,
|
|
17109
|
+
setValue,
|
|
17110
|
+
originalValue,
|
|
17111
|
+
onValueCommit,
|
|
17112
|
+
onValueRevert,
|
|
17113
|
+
typographicVariant,
|
|
17114
|
+
submitMode,
|
|
17115
|
+
readOnly,
|
|
17116
|
+
computedId,
|
|
17117
|
+
label,
|
|
17118
|
+
placeholder,
|
|
17119
|
+
minLines,
|
|
17120
|
+
maxLines,
|
|
17121
|
+
finalFocusEl
|
|
17122
|
+
]);
|
|
17123
|
+
const getState = () => {
|
|
17124
|
+
if (readOnly) {
|
|
17125
|
+
return "read-only";
|
|
17126
|
+
}
|
|
17127
|
+
if (isEditing) {
|
|
17128
|
+
return "editing";
|
|
17129
|
+
}
|
|
17130
|
+
return "idle";
|
|
17131
|
+
};
|
|
17132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(
|
|
17133
|
+
StyledEditableTextRoot,
|
|
17134
|
+
{
|
|
17135
|
+
"data-testid": "editable-text-root",
|
|
17136
|
+
"data-wui-editable-text-root": true,
|
|
17137
|
+
"data-wui-editable-text-state": getState(),
|
|
17138
|
+
...props,
|
|
17139
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(EditableTextContext.Provider, { value: context, children })
|
|
17140
|
+
}
|
|
17141
|
+
);
|
|
17142
|
+
};
|
|
17143
|
+
|
|
17144
|
+
// src/private/helpers/getTypographicStyles/getTypographicStyles.ts
|
|
17145
|
+
var import_styled_components122 = require("styled-components");
|
|
17146
|
+
var typographicVariantStyleMap = { ...variantStyleMap2, ...variantStyleMap };
|
|
17147
|
+
var getTypographicStyles = (variant) => {
|
|
17148
|
+
return import_styled_components122.css`
|
|
17149
|
+
${typographicVariantStyleMap[variant]}
|
|
17150
|
+
font-family: var(--font-family);
|
|
17151
|
+
font-size: var(--font-size);
|
|
17152
|
+
font-weight: var(--font-weight);
|
|
17153
|
+
line-height: var(--line-height);
|
|
17154
|
+
`;
|
|
17155
|
+
};
|
|
17156
|
+
var typographicVariantElementMap = { ...variantElementMap2, ...variantElementMap };
|
|
17157
|
+
var getDefaultTypographicElement = (variant) => {
|
|
17158
|
+
return typographicVariantElementMap[variant] ?? "span";
|
|
17159
|
+
};
|
|
17160
|
+
|
|
17161
|
+
// src/components/EditableText/EditableTextDisplay.tsx
|
|
17162
|
+
var import_jsx_runtime318 = require("react/jsx-runtime");
|
|
17163
|
+
var StyledEditableTextDisplay = import_styled_components123.default.div`
|
|
17164
|
+
${({ $typographicVariant }) => getTypographicStyles($typographicVariant)}
|
|
17165
|
+
padding: var(--wui-editable-text-padding);
|
|
17166
|
+
border-radius: var(--wui-editable-text-border-radius);
|
|
17167
|
+
margin: 0;
|
|
17168
|
+
transition: all var(--wui-motion-duration-02) var(--wui-motion-ease);
|
|
17169
|
+
${({ $maxLines }) => {
|
|
17170
|
+
if ((0, import_type_guards73.isNotNil)($maxLines)) {
|
|
17171
|
+
return import_styled_components123.css`
|
|
17172
|
+
${ellipsisStyle};
|
|
17173
|
+
${lineClampCss($maxLines)};
|
|
17174
|
+
`;
|
|
17175
|
+
}
|
|
17176
|
+
return void 0;
|
|
17177
|
+
}}
|
|
17178
|
+
${({ $minLines }) => (0, import_type_guards73.isNotNil)($minLines) && import_styled_components123.css`
|
|
17179
|
+
min-height: calc(${$minLines}lh + calc(var(--wui-editable-text-padding) * 2));
|
|
17180
|
+
`}
|
|
17181
|
+
word-break: break-word;
|
|
17182
|
+
|
|
17183
|
+
&[data-wui-editable-text-display='placeholder'] {
|
|
17184
|
+
color: var(--wui-color-text-secondary);
|
|
17185
|
+
}
|
|
17186
|
+
|
|
17187
|
+
&:has(button) {
|
|
17188
|
+
user-select: none;
|
|
17189
|
+
cursor: pointer;
|
|
17190
|
+
|
|
17191
|
+
&:hover,
|
|
17192
|
+
&:focus-within {
|
|
17193
|
+
background-color: var(--wui-color-bg-surface-hover);
|
|
17194
|
+
}
|
|
17195
|
+
}
|
|
17196
|
+
`;
|
|
17197
|
+
var EditableTextDisplayComponent = (0, import_react92.forwardRef)(
|
|
17198
|
+
({ asTrigger, renderAs, ...props }, ref) => {
|
|
17199
|
+
const context = (0, import_react92.useContext)(EditableTextContext);
|
|
17200
|
+
if (!context) {
|
|
17201
|
+
throw new Error("EditableTextDisplay must be used within an EditableTextRoot context");
|
|
17202
|
+
}
|
|
17203
|
+
const { value, typographicVariant, setIsEditing, placeholder, maxLines, isEditing, minLines } = context;
|
|
17204
|
+
const triggerButtonRef = (0, import_react92.useRef)(null);
|
|
17205
|
+
const handleTriggerClick = () => {
|
|
17206
|
+
setIsEditing(true);
|
|
17207
|
+
};
|
|
17208
|
+
const elementType = renderAs ?? getDefaultTypographicElement(typographicVariant);
|
|
17209
|
+
const displayText = value.length > 0 ? value : placeholder;
|
|
17210
|
+
const isPlaceholderVisible = value.length === 0 && !!placeholder;
|
|
17211
|
+
if (isEditing) {
|
|
17212
|
+
return null;
|
|
17213
|
+
}
|
|
17214
|
+
if (asTrigger && !context.readOnly) {
|
|
17215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(ClickRegion, { targetRef: triggerButtonRef, children: /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)(
|
|
17216
|
+
StyledEditableTextDisplay,
|
|
17217
|
+
{
|
|
17218
|
+
ref,
|
|
17219
|
+
$maxLines: maxLines,
|
|
17220
|
+
$minLines: minLines,
|
|
17221
|
+
$typographicVariant: typographicVariant,
|
|
17222
|
+
as: elementType,
|
|
17223
|
+
"data-wui-editable-text-display": isPlaceholderVisible ? "placeholder" : "value",
|
|
17224
|
+
...props,
|
|
17225
|
+
children: [
|
|
17226
|
+
displayText,
|
|
17227
|
+
/* @__PURE__ */ (0, import_jsx_runtime318.jsx)(
|
|
17228
|
+
"button",
|
|
17229
|
+
{
|
|
17230
|
+
ref: triggerButtonRef,
|
|
17231
|
+
onClick: handleTriggerClick,
|
|
17232
|
+
style: { ...visuallyHiddenStyle },
|
|
17233
|
+
type: "button",
|
|
17234
|
+
children: "Edit text"
|
|
17235
|
+
}
|
|
17236
|
+
)
|
|
17237
|
+
]
|
|
17238
|
+
}
|
|
17239
|
+
) });
|
|
17240
|
+
}
|
|
17241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(
|
|
17242
|
+
StyledEditableTextDisplay,
|
|
17243
|
+
{
|
|
17244
|
+
ref,
|
|
17245
|
+
$maxLines: maxLines,
|
|
17246
|
+
$minLines: minLines,
|
|
17247
|
+
$typographicVariant: typographicVariant,
|
|
17248
|
+
as: elementType,
|
|
17249
|
+
"data-placeholder-visible": isPlaceholderVisible || void 0,
|
|
17250
|
+
"data-wui-editable-text-display": true,
|
|
17251
|
+
...props,
|
|
17252
|
+
children: displayText
|
|
17253
|
+
}
|
|
17254
|
+
);
|
|
17255
|
+
}
|
|
17256
|
+
);
|
|
17257
|
+
EditableTextDisplayComponent.displayName = "EditableTextDisplay_UI";
|
|
17258
|
+
var EditableTextDisplay = makePolymorphic(
|
|
17259
|
+
EditableTextDisplayComponent
|
|
17260
|
+
);
|
|
17261
|
+
|
|
17262
|
+
// src/components/EditableText/EditableTextInput.tsx
|
|
17263
|
+
var import_react93 = require("react");
|
|
17264
|
+
var import_styled_components124 = __toESM(require("styled-components"));
|
|
17265
|
+
var import_type_guards74 = require("@wistia/type-guards");
|
|
17266
|
+
var import_jsx_runtime319 = require("react/jsx-runtime");
|
|
17267
|
+
var StyledInput2 = (0, import_styled_components124.default)(Input)`
|
|
17268
|
+
&& {
|
|
17269
|
+
${({ $minLines }) => (0, import_type_guards74.isNotNil)($minLines) && `min-height: calc(${$minLines}lh + calc(var(--wui-editable-text-padding) * 2));`}
|
|
17270
|
+
${({ $maxLines }) => (0, import_type_guards74.isNotNil)($maxLines) && `max-height: calc(${$maxLines}lh + calc(var(--wui-editable-text-padding) * 2));`}
|
|
17271
|
+
${({ $typographicVariant }) => getTypographicStyles($typographicVariant)}
|
|
17272
|
+
padding: var(--wui-editable-text-padding);
|
|
17273
|
+
border-radius: var(--wui-editable-text-border-radius);
|
|
17274
|
+
background-color: var(--wui-color-bg-surface);
|
|
17275
|
+
}
|
|
17276
|
+
`;
|
|
17277
|
+
var EditableTextInput = (props) => {
|
|
17278
|
+
const context = (0, import_react93.useContext)(EditableTextContext);
|
|
17279
|
+
if (!context) {
|
|
17280
|
+
throw new Error("EditableTextInput must be used within an EditableTextRoot context");
|
|
17281
|
+
}
|
|
17282
|
+
const {
|
|
17283
|
+
isEditing,
|
|
17284
|
+
value,
|
|
17285
|
+
setValue,
|
|
17286
|
+
onValueCommit,
|
|
17287
|
+
setIsEditing,
|
|
17288
|
+
typographicVariant,
|
|
17289
|
+
submitMode,
|
|
17290
|
+
originalValue,
|
|
17291
|
+
onValueRevert,
|
|
17292
|
+
id,
|
|
17293
|
+
placeholder,
|
|
17294
|
+
minLines,
|
|
17295
|
+
maxLines,
|
|
17296
|
+
finalFocusEl
|
|
17297
|
+
} = context;
|
|
17298
|
+
const inputRef = (0, import_react93.useRef)(null);
|
|
17299
|
+
(0, import_react93.useEffect)(() => {
|
|
17300
|
+
if (inputRef.current) {
|
|
17301
|
+
if (isEditing) {
|
|
17302
|
+
const element = inputRef.current;
|
|
17303
|
+
const { style } = element;
|
|
17304
|
+
style.height = "0px";
|
|
17305
|
+
const { scrollHeight } = element;
|
|
17306
|
+
style.height = `${scrollHeight}px`;
|
|
17307
|
+
}
|
|
17308
|
+
if (isEditing) {
|
|
17309
|
+
inputRef.current.focus();
|
|
17310
|
+
}
|
|
17311
|
+
}
|
|
17312
|
+
}, [value, isEditing]);
|
|
17313
|
+
const handleChange = (event) => {
|
|
17314
|
+
setValue(event.target.value);
|
|
17315
|
+
};
|
|
17316
|
+
const handleKeyDown = (event) => {
|
|
17317
|
+
if ((submitMode === "enter" || submitMode === "both") && event.key === "Enter" && !event.shiftKey) {
|
|
17318
|
+
event.preventDefault();
|
|
17319
|
+
onValueCommit?.(value);
|
|
17320
|
+
setIsEditing(false);
|
|
17321
|
+
setTimeout(() => {
|
|
17322
|
+
const element = finalFocusEl?.();
|
|
17323
|
+
if (element) {
|
|
17324
|
+
element.focus();
|
|
17325
|
+
}
|
|
17326
|
+
}, 0);
|
|
17327
|
+
}
|
|
17328
|
+
if (event.key === "Escape") {
|
|
17329
|
+
event.preventDefault();
|
|
17330
|
+
setValue(originalValue);
|
|
17331
|
+
onValueRevert?.(originalValue);
|
|
17332
|
+
setIsEditing(false);
|
|
17333
|
+
setTimeout(() => {
|
|
17334
|
+
const element = finalFocusEl?.();
|
|
17335
|
+
if (element) {
|
|
17336
|
+
element.focus();
|
|
17337
|
+
}
|
|
17338
|
+
}, 0);
|
|
17339
|
+
}
|
|
17340
|
+
};
|
|
17341
|
+
const handleBlur2 = () => {
|
|
17342
|
+
if (submitMode === "blur" || submitMode === "both") {
|
|
17343
|
+
onValueCommit?.(value);
|
|
17344
|
+
setIsEditing(false);
|
|
17345
|
+
setTimeout(() => {
|
|
17346
|
+
const element = finalFocusEl?.();
|
|
17347
|
+
if (element) {
|
|
17348
|
+
element.focus();
|
|
17349
|
+
}
|
|
17350
|
+
}, 0);
|
|
17351
|
+
}
|
|
17352
|
+
};
|
|
17353
|
+
if (!isEditing) return null;
|
|
17354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
|
|
17355
|
+
StyledInput2,
|
|
17356
|
+
{
|
|
17357
|
+
ref: inputRef,
|
|
17358
|
+
$maxLines: maxLines ?? "infinity",
|
|
17359
|
+
$minLines: minLines,
|
|
17360
|
+
$typographicVariant: typographicVariant,
|
|
17361
|
+
"data-wui-editable-text-input": true,
|
|
17362
|
+
id,
|
|
17363
|
+
onBlur: handleBlur2,
|
|
17364
|
+
onChange: handleChange,
|
|
17365
|
+
onKeyDown: handleKeyDown,
|
|
17366
|
+
placeholder,
|
|
17367
|
+
type: "multiline",
|
|
17368
|
+
value,
|
|
17369
|
+
...props
|
|
17370
|
+
}
|
|
17371
|
+
);
|
|
17372
|
+
};
|
|
17373
|
+
|
|
17374
|
+
// src/components/EditableText/EditableTextLabel.tsx
|
|
17375
|
+
var import_react94 = require("react");
|
|
17376
|
+
var import_jsx_runtime320 = require("react/jsx-runtime");
|
|
17377
|
+
var EditableTextLabel = ({ ...props }) => {
|
|
17378
|
+
const context = (0, import_react94.useContext)(EditableTextContext);
|
|
17379
|
+
if (!context) {
|
|
17380
|
+
throw new Error("EditableTextLabel must be used within an EditableTextRoot context");
|
|
17381
|
+
}
|
|
17382
|
+
const { id, label } = context;
|
|
17383
|
+
return /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(
|
|
17384
|
+
Label,
|
|
17385
|
+
{
|
|
17386
|
+
htmlFor: id,
|
|
17387
|
+
...props,
|
|
17388
|
+
children: label
|
|
17389
|
+
}
|
|
17390
|
+
);
|
|
17391
|
+
};
|
|
17392
|
+
|
|
17393
|
+
// src/components/EditableText/EditableText.tsx
|
|
17394
|
+
var import_jsx_runtime321 = require("react/jsx-runtime");
|
|
17395
|
+
var EditableText = ({ hideLabel = true, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(EditableTextRoot, { ...props, children: [
|
|
17396
|
+
/* @__PURE__ */ (0, import_jsx_runtime321.jsx)(EditableTextLabel, { screenReaderOnly: hideLabel }),
|
|
17397
|
+
/* @__PURE__ */ (0, import_jsx_runtime321.jsx)(EditableTextInput, {}),
|
|
17398
|
+
/* @__PURE__ */ (0, import_jsx_runtime321.jsx)(EditableTextDisplay, { asTrigger: true })
|
|
17399
|
+
] });
|
|
17400
|
+
EditableText.displayName = "EditableText_UI";
|
|
17401
|
+
|
|
17402
|
+
// src/components/EditableText/EditableTextSubmitButton.tsx
|
|
17403
|
+
var import_react95 = require("react");
|
|
17404
|
+
var EditableTextSubmitButton = ({
|
|
17405
|
+
/**
|
|
17406
|
+
* A submit button, typically a [Button]() that will commit the value when clicked.
|
|
17407
|
+
*/
|
|
17408
|
+
children
|
|
17409
|
+
}) => {
|
|
17410
|
+
const context = (0, import_react95.useContext)(EditableTextContext);
|
|
17411
|
+
if (!context) {
|
|
17412
|
+
throw new Error("EditableTextSubmitButton must be used within an EditableTextRoot context");
|
|
17413
|
+
}
|
|
17414
|
+
const { setIsEditing, value, onValueCommit, finalFocusEl, isEditing } = context;
|
|
17415
|
+
const handleClick = () => {
|
|
17416
|
+
onValueCommit?.(value);
|
|
17417
|
+
setIsEditing(false);
|
|
17418
|
+
setTimeout(() => {
|
|
17419
|
+
const element = finalFocusEl?.();
|
|
17420
|
+
if (element) {
|
|
17421
|
+
element.focus();
|
|
17422
|
+
}
|
|
17423
|
+
}, 0);
|
|
17424
|
+
};
|
|
17425
|
+
const onlyChild = import_react95.Children.only(children);
|
|
17426
|
+
const triggerProps = {
|
|
17427
|
+
onClick: handleClick,
|
|
17428
|
+
"data-wui-editable-text-submit": true
|
|
17429
|
+
};
|
|
17430
|
+
if (!isEditing) return null;
|
|
17431
|
+
return (0, import_react95.cloneElement)(onlyChild, triggerProps);
|
|
17432
|
+
};
|
|
17433
|
+
|
|
17434
|
+
// src/components/EditableText/EditableTextCancelButton.tsx
|
|
17435
|
+
var import_react96 = require("react");
|
|
17436
|
+
var EditableTextCancelButton = ({
|
|
17437
|
+
children
|
|
17438
|
+
}) => {
|
|
17439
|
+
const context = (0, import_react96.useContext)(EditableTextContext);
|
|
17440
|
+
if (!context) {
|
|
17441
|
+
throw new Error("EditableTextCancelButton must be used within an EditableTextRoot context");
|
|
17442
|
+
}
|
|
17443
|
+
const { setIsEditing, originalValue, setValue, onValueRevert, finalFocusEl, isEditing } = context;
|
|
17444
|
+
const handleClick = () => {
|
|
17445
|
+
setValue(originalValue);
|
|
17446
|
+
onValueRevert?.(originalValue);
|
|
17447
|
+
setIsEditing(false);
|
|
17448
|
+
setTimeout(() => {
|
|
17449
|
+
const element = finalFocusEl?.();
|
|
17450
|
+
if (element) {
|
|
17451
|
+
element.focus();
|
|
17452
|
+
}
|
|
17453
|
+
}, 0);
|
|
17454
|
+
};
|
|
17455
|
+
const onlyChild = import_react96.Children.only(children);
|
|
17456
|
+
const triggerProps = {
|
|
17457
|
+
onClick: handleClick,
|
|
17458
|
+
"data-wui-editable-text-cancel": true
|
|
17459
|
+
};
|
|
17460
|
+
if (!isEditing) return null;
|
|
17461
|
+
return (0, import_react96.cloneElement)(onlyChild, triggerProps);
|
|
17462
|
+
};
|
|
17463
|
+
|
|
17464
|
+
// src/components/EditableText/EditableTextTrigger.tsx
|
|
17465
|
+
var import_react97 = require("react");
|
|
17466
|
+
var EditableTextTrigger = ({
|
|
17467
|
+
children,
|
|
17468
|
+
...props
|
|
17469
|
+
}) => {
|
|
17470
|
+
const context = (0, import_react97.useContext)(EditableTextContext);
|
|
17471
|
+
if (!context) {
|
|
17472
|
+
throw new Error("EditableTextTrigger must be used within an EditableTextRoot context");
|
|
17473
|
+
}
|
|
17474
|
+
const { setIsEditing, isEditing } = context;
|
|
17475
|
+
const handleClick = () => {
|
|
17476
|
+
setIsEditing(true);
|
|
17477
|
+
};
|
|
17478
|
+
const onlyChild = import_react97.Children.only(children);
|
|
17479
|
+
const triggerProps = {
|
|
17480
|
+
onClick: handleClick,
|
|
17481
|
+
"data-wui-editable-text-trigger": true,
|
|
17482
|
+
...props
|
|
17483
|
+
};
|
|
17484
|
+
if (isEditing) return null;
|
|
17485
|
+
return (0, import_react97.cloneElement)(onlyChild, triggerProps);
|
|
17486
|
+
};
|
|
17487
|
+
|
|
17488
|
+
// src/components/DataList/DataList.tsx
|
|
17489
|
+
var import_styled_components125 = __toESM(require("styled-components"));
|
|
17490
|
+
var import_jsx_runtime322 = require("react/jsx-runtime");
|
|
17491
|
+
var StyledDataList = import_styled_components125.default.dl`
|
|
17013
17492
|
display: grid;
|
|
17014
17493
|
grid-template-columns: auto 1fr;
|
|
17015
17494
|
column-gap: var(--wui-space-02);
|
|
@@ -17037,7 +17516,7 @@ var DataList = ({
|
|
|
17037
17516
|
labelProminence = "primary",
|
|
17038
17517
|
...props
|
|
17039
17518
|
}) => {
|
|
17040
|
-
return /* @__PURE__ */ (0,
|
|
17519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
|
|
17041
17520
|
StyledDataList,
|
|
17042
17521
|
{
|
|
17043
17522
|
role: "list",
|
|
@@ -17060,9 +17539,9 @@ var DataListItem = ({ children }) => {
|
|
|
17060
17539
|
DataListItem.displayName = "DataListItem_UI";
|
|
17061
17540
|
|
|
17062
17541
|
// src/components/DataList/DataListItemLabel.tsx
|
|
17063
|
-
var
|
|
17542
|
+
var import_jsx_runtime323 = require("react/jsx-runtime");
|
|
17064
17543
|
var DataListItemLabel = (props) => {
|
|
17065
|
-
return /* @__PURE__ */ (0,
|
|
17544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(
|
|
17066
17545
|
Text,
|
|
17067
17546
|
{
|
|
17068
17547
|
variant: "label4",
|
|
@@ -17074,9 +17553,9 @@ var DataListItemLabel = (props) => {
|
|
|
17074
17553
|
DataListItemLabel.displayName = "DataListItemLabel_UI";
|
|
17075
17554
|
|
|
17076
17555
|
// src/components/DataList/DataListItemValue.tsx
|
|
17077
|
-
var
|
|
17556
|
+
var import_jsx_runtime324 = require("react/jsx-runtime");
|
|
17078
17557
|
var DataListItemValue = (props) => {
|
|
17079
|
-
return /* @__PURE__ */ (0,
|
|
17558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(
|
|
17080
17559
|
Text,
|
|
17081
17560
|
{
|
|
17082
17561
|
variant: "body3",
|
|
@@ -17131,6 +17610,15 @@ DataListItemValue.displayName = "DataListItemValue_UI";
|
|
|
17131
17610
|
DataListItemValue,
|
|
17132
17611
|
Divider,
|
|
17133
17612
|
EditableHeading,
|
|
17613
|
+
EditableText,
|
|
17614
|
+
EditableTextCancelButton,
|
|
17615
|
+
EditableTextContext,
|
|
17616
|
+
EditableTextDisplay,
|
|
17617
|
+
EditableTextInput,
|
|
17618
|
+
EditableTextLabel,
|
|
17619
|
+
EditableTextRoot,
|
|
17620
|
+
EditableTextSubmitButton,
|
|
17621
|
+
EditableTextTrigger,
|
|
17134
17622
|
Ellipsis,
|
|
17135
17623
|
FileAmountLimitValidator,
|
|
17136
17624
|
FileSizeValidator,
|