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