@wistia/ui 0.14.20 → 0.14.21-beta.0ab0ad61.b6d275f
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 +525 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +178 -2
- package/dist/index.d.ts +178 -2
- package/dist/index.mjs +521 -14
- 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.0ab0ad61.b6d275f
|
|
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,
|
|
@@ -107,6 +116,7 @@ __export(index_exports, {
|
|
|
107
116
|
Label: () => Label,
|
|
108
117
|
Link: () => Link,
|
|
109
118
|
List: () => List,
|
|
119
|
+
Mark: () => Mark,
|
|
110
120
|
Menu: () => Menu,
|
|
111
121
|
MenuItem: () => MenuItem,
|
|
112
122
|
MenuItemDescription: () => MenuItemDescription,
|
|
@@ -8341,17 +8351,23 @@ var import_react29 = require("react");
|
|
|
8341
8351
|
var import_styled_components29 = __toESM(require("styled-components"));
|
|
8342
8352
|
var import_type_guards22 = require("@wistia/type-guards");
|
|
8343
8353
|
var import_jsx_runtime206 = require("react/jsx-runtime");
|
|
8344
|
-
var
|
|
8354
|
+
var sharedBodyStyle = import_styled_components29.css`
|
|
8345
8355
|
> strong,
|
|
8346
8356
|
b {
|
|
8347
8357
|
font-weight: var(--wui-typography-weight-body-bold);
|
|
8348
8358
|
}
|
|
8359
|
+
> mark {
|
|
8360
|
+
font-weight: var(--wui-typography-weight-body-mark);
|
|
8361
|
+
}
|
|
8349
8362
|
`;
|
|
8350
8363
|
var labelBoldStyles = import_styled_components29.css`
|
|
8351
8364
|
> strong,
|
|
8352
8365
|
b {
|
|
8353
8366
|
font-weight: var(--wui-typography-weight-label-bold);
|
|
8354
8367
|
}
|
|
8368
|
+
> mark {
|
|
8369
|
+
font-weight: var(--wui-typography-weight-label-mark);
|
|
8370
|
+
}
|
|
8355
8371
|
`;
|
|
8356
8372
|
var body1TextStyle = import_styled_components29.css`
|
|
8357
8373
|
--font-family: var(--wui-typography-body-1-family);
|
|
@@ -8359,7 +8375,7 @@ var body1TextStyle = import_styled_components29.css`
|
|
|
8359
8375
|
--font-weight: var(--wui-typography-body-1-weight);
|
|
8360
8376
|
--line-height: var(--wui-typography-body-1-line-height);
|
|
8361
8377
|
--paragraph-spacing: var(--wui-typography-body-1-paragraph-spacing);
|
|
8362
|
-
${
|
|
8378
|
+
${sharedBodyStyle}
|
|
8363
8379
|
`;
|
|
8364
8380
|
var body2TextStyle = import_styled_components29.css`
|
|
8365
8381
|
--font-family: var(--wui-typography-body-2-family);
|
|
@@ -8367,7 +8383,7 @@ var body2TextStyle = import_styled_components29.css`
|
|
|
8367
8383
|
--font-weight: var(--wui-typography-body-2-weight);
|
|
8368
8384
|
--line-height: var(--wui-typography-body-2-line-height);
|
|
8369
8385
|
--paragraph-spacing: var(--wui-typography-body-2-paragraph-spacing);
|
|
8370
|
-
${
|
|
8386
|
+
${sharedBodyStyle}
|
|
8371
8387
|
`;
|
|
8372
8388
|
var body3TextStyle = import_styled_components29.css`
|
|
8373
8389
|
--font-family: var(--wui-typography-body-3-family);
|
|
@@ -8375,7 +8391,7 @@ var body3TextStyle = import_styled_components29.css`
|
|
|
8375
8391
|
--font-weight: var(--wui-typography-body-3-weight);
|
|
8376
8392
|
--line-height: var(--wui-typography-body-3-line-height);
|
|
8377
8393
|
--paragraph-spacing: var(--wui-typography-body-3-paragraph-spacing);
|
|
8378
|
-
${
|
|
8394
|
+
${sharedBodyStyle}
|
|
8379
8395
|
`;
|
|
8380
8396
|
var body4TextStyle = import_styled_components29.css`
|
|
8381
8397
|
--font-family: var(--wui-typography-body-4-family);
|
|
@@ -8383,7 +8399,7 @@ var body4TextStyle = import_styled_components29.css`
|
|
|
8383
8399
|
--font-weight: var(--wui-typography-body-4-weight);
|
|
8384
8400
|
--line-height: var(--wui-typography-body-4-line-height);
|
|
8385
8401
|
--paragraph-spacing: var(--wui-typography-body-4-paragraph-spacing);
|
|
8386
|
-
${
|
|
8402
|
+
${sharedBodyStyle}
|
|
8387
8403
|
`;
|
|
8388
8404
|
var label1TextStyle = import_styled_components29.css`
|
|
8389
8405
|
--font-family: var(--wui-typography-label-1-family);
|
|
@@ -8474,7 +8490,6 @@ var StyledText = import_styled_components29.default.div`
|
|
|
8474
8490
|
}
|
|
8475
8491
|
return "var(--wui-color-text)";
|
|
8476
8492
|
}};
|
|
8477
|
-
|
|
8478
8493
|
${iconInlineStyle}
|
|
8479
8494
|
color: var(--text-color);
|
|
8480
8495
|
font-family: var(--font-family);
|
|
@@ -11334,6 +11349,7 @@ var Input = (0, import_react47.forwardRef)(
|
|
|
11334
11349
|
{
|
|
11335
11350
|
$fullWidth: fullWidth,
|
|
11336
11351
|
$monospace: monospace,
|
|
11352
|
+
"data-wui-input-container": true,
|
|
11337
11353
|
children: [
|
|
11338
11354
|
leftIconToDisplay ?? null,
|
|
11339
11355
|
type === "multiline" ? /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(
|
|
@@ -17006,10 +17022,474 @@ var ContextMenu = ({
|
|
|
17006
17022
|
) : null;
|
|
17007
17023
|
};
|
|
17008
17024
|
|
|
17009
|
-
// src/components/
|
|
17025
|
+
// src/components/EditableText/EditableTextDisplay.tsx
|
|
17026
|
+
var import_react92 = require("react");
|
|
17027
|
+
var import_styled_components123 = __toESM(require("styled-components"));
|
|
17028
|
+
var import_type_guards73 = require("@wistia/type-guards");
|
|
17029
|
+
|
|
17030
|
+
// src/components/EditableText/EditableTextRoot.tsx
|
|
17031
|
+
var import_react91 = require("react");
|
|
17032
|
+
var import_type_guards72 = require("@wistia/type-guards");
|
|
17010
17033
|
var import_styled_components121 = __toESM(require("styled-components"));
|
|
17011
17034
|
var import_jsx_runtime317 = require("react/jsx-runtime");
|
|
17012
|
-
var
|
|
17035
|
+
var StyledEditableTextRoot = import_styled_components121.default.div`
|
|
17036
|
+
display: contents;
|
|
17037
|
+
|
|
17038
|
+
--wui-editable-text-padding: var(--wui-space-01);
|
|
17039
|
+
--wui-editable-text-border-radius: var(--wui-border-radius-01);
|
|
17040
|
+
`;
|
|
17041
|
+
var EditableTextContext = (0, import_react91.createContext)(null);
|
|
17042
|
+
var EditableTextRoot = ({
|
|
17043
|
+
children,
|
|
17044
|
+
defaultValue = "",
|
|
17045
|
+
value: controlledValue,
|
|
17046
|
+
onValueChange,
|
|
17047
|
+
onValueCommit,
|
|
17048
|
+
onValueRevert,
|
|
17049
|
+
onEditingChange,
|
|
17050
|
+
typographicVariant = "body2",
|
|
17051
|
+
submitMode = "both",
|
|
17052
|
+
readOnly = false,
|
|
17053
|
+
id,
|
|
17054
|
+
label,
|
|
17055
|
+
placeholder = "Click to edit this text",
|
|
17056
|
+
minLines = 1,
|
|
17057
|
+
maxLines,
|
|
17058
|
+
finalFocusEl,
|
|
17059
|
+
...props
|
|
17060
|
+
}) => {
|
|
17061
|
+
const isControlled = controlledValue !== void 0;
|
|
17062
|
+
const [internalValue, setInternalValue] = (0, import_react91.useState)(defaultValue);
|
|
17063
|
+
const [originalValue, setOriginalValue] = (0, import_react91.useState)(defaultValue);
|
|
17064
|
+
const [isEditing, setIsEditing] = (0, import_react91.useState)(false);
|
|
17065
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
17066
|
+
const generatedId = (0, import_react91.useId)();
|
|
17067
|
+
const computedId = (0, import_type_guards72.isNonEmptyString)(id) ? id : `wistia-ui-editable-text-${generatedId}`;
|
|
17068
|
+
const handleSetIsEditing = (0, import_react91.useCallback)(
|
|
17069
|
+
(editing) => {
|
|
17070
|
+
if (editing && !isEditing) {
|
|
17071
|
+
setOriginalValue(value);
|
|
17072
|
+
}
|
|
17073
|
+
setIsEditing(editing);
|
|
17074
|
+
onEditingChange?.(editing);
|
|
17075
|
+
},
|
|
17076
|
+
[isEditing, value, onEditingChange]
|
|
17077
|
+
);
|
|
17078
|
+
const setValue = (0, import_react91.useCallback)(
|
|
17079
|
+
(newValue) => {
|
|
17080
|
+
if (!isControlled) {
|
|
17081
|
+
setInternalValue(newValue);
|
|
17082
|
+
}
|
|
17083
|
+
onValueChange?.(newValue);
|
|
17084
|
+
},
|
|
17085
|
+
[isControlled, onValueChange]
|
|
17086
|
+
);
|
|
17087
|
+
const context = (0, import_react91.useMemo)(() => {
|
|
17088
|
+
return {
|
|
17089
|
+
isEditing,
|
|
17090
|
+
setIsEditing: handleSetIsEditing,
|
|
17091
|
+
value,
|
|
17092
|
+
setValue,
|
|
17093
|
+
originalValue,
|
|
17094
|
+
onValueCommit,
|
|
17095
|
+
onValueRevert,
|
|
17096
|
+
typographicVariant,
|
|
17097
|
+
submitMode,
|
|
17098
|
+
readOnly,
|
|
17099
|
+
id: computedId,
|
|
17100
|
+
label,
|
|
17101
|
+
placeholder,
|
|
17102
|
+
minLines,
|
|
17103
|
+
maxLines,
|
|
17104
|
+
finalFocusEl
|
|
17105
|
+
};
|
|
17106
|
+
}, [
|
|
17107
|
+
isEditing,
|
|
17108
|
+
handleSetIsEditing,
|
|
17109
|
+
value,
|
|
17110
|
+
setValue,
|
|
17111
|
+
originalValue,
|
|
17112
|
+
onValueCommit,
|
|
17113
|
+
onValueRevert,
|
|
17114
|
+
typographicVariant,
|
|
17115
|
+
submitMode,
|
|
17116
|
+
readOnly,
|
|
17117
|
+
computedId,
|
|
17118
|
+
label,
|
|
17119
|
+
placeholder,
|
|
17120
|
+
minLines,
|
|
17121
|
+
maxLines,
|
|
17122
|
+
finalFocusEl
|
|
17123
|
+
]);
|
|
17124
|
+
const getState = () => {
|
|
17125
|
+
if (readOnly) {
|
|
17126
|
+
return "read-only";
|
|
17127
|
+
}
|
|
17128
|
+
if (isEditing) {
|
|
17129
|
+
return "editing";
|
|
17130
|
+
}
|
|
17131
|
+
return "idle";
|
|
17132
|
+
};
|
|
17133
|
+
return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(
|
|
17134
|
+
StyledEditableTextRoot,
|
|
17135
|
+
{
|
|
17136
|
+
"data-testid": "editable-text-root",
|
|
17137
|
+
"data-wui-editable-text-root": true,
|
|
17138
|
+
"data-wui-editable-text-state": getState(),
|
|
17139
|
+
...props,
|
|
17140
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(EditableTextContext.Provider, { value: context, children })
|
|
17141
|
+
}
|
|
17142
|
+
);
|
|
17143
|
+
};
|
|
17144
|
+
|
|
17145
|
+
// src/private/helpers/getTypographicStyles/getTypographicStyles.ts
|
|
17146
|
+
var import_styled_components122 = require("styled-components");
|
|
17147
|
+
var typographicVariantStyleMap = { ...variantStyleMap2, ...variantStyleMap };
|
|
17148
|
+
var getTypographicStyles = (variant) => {
|
|
17149
|
+
return import_styled_components122.css`
|
|
17150
|
+
${typographicVariantStyleMap[variant]}
|
|
17151
|
+
font-family: var(--font-family);
|
|
17152
|
+
font-size: var(--font-size);
|
|
17153
|
+
font-weight: var(--font-weight);
|
|
17154
|
+
line-height: var(--line-height);
|
|
17155
|
+
`;
|
|
17156
|
+
};
|
|
17157
|
+
var typographicVariantElementMap = { ...variantElementMap2, ...variantElementMap };
|
|
17158
|
+
var getDefaultTypographicElement = (variant) => {
|
|
17159
|
+
return typographicVariantElementMap[variant] ?? "span";
|
|
17160
|
+
};
|
|
17161
|
+
|
|
17162
|
+
// src/components/EditableText/EditableTextDisplay.tsx
|
|
17163
|
+
var import_jsx_runtime318 = require("react/jsx-runtime");
|
|
17164
|
+
var StyledEditableTextDisplay = import_styled_components123.default.div`
|
|
17165
|
+
${({ $typographicVariant }) => getTypographicStyles($typographicVariant)}
|
|
17166
|
+
padding: var(--wui-editable-text-padding);
|
|
17167
|
+
border-radius: var(--wui-editable-text-border-radius);
|
|
17168
|
+
margin: 0;
|
|
17169
|
+
transition: all var(--wui-motion-duration-02) var(--wui-motion-ease);
|
|
17170
|
+
${({ $maxLines }) => {
|
|
17171
|
+
if ((0, import_type_guards73.isNotNil)($maxLines)) {
|
|
17172
|
+
return import_styled_components123.css`
|
|
17173
|
+
${ellipsisStyle};
|
|
17174
|
+
${lineClampCss($maxLines)};
|
|
17175
|
+
`;
|
|
17176
|
+
}
|
|
17177
|
+
return void 0;
|
|
17178
|
+
}}
|
|
17179
|
+
${({ $minLines }) => (0, import_type_guards73.isNotNil)($minLines) && import_styled_components123.css`
|
|
17180
|
+
min-height: calc(${$minLines}lh + calc(var(--wui-editable-text-padding) * 2));
|
|
17181
|
+
`}
|
|
17182
|
+
word-break: break-word;
|
|
17183
|
+
|
|
17184
|
+
&[data-wui-editable-text-display='placeholder'] {
|
|
17185
|
+
color: var(--wui-color-text-secondary);
|
|
17186
|
+
}
|
|
17187
|
+
|
|
17188
|
+
&:has(button) {
|
|
17189
|
+
user-select: none;
|
|
17190
|
+
cursor: pointer;
|
|
17191
|
+
|
|
17192
|
+
&:hover,
|
|
17193
|
+
&:focus-within {
|
|
17194
|
+
background-color: var(--wui-color-bg-surface-hover);
|
|
17195
|
+
}
|
|
17196
|
+
}
|
|
17197
|
+
`;
|
|
17198
|
+
var EditableTextDisplayComponent = (0, import_react92.forwardRef)(
|
|
17199
|
+
({ asTrigger, renderAs, ...props }, ref) => {
|
|
17200
|
+
const context = (0, import_react92.useContext)(EditableTextContext);
|
|
17201
|
+
if (!context) {
|
|
17202
|
+
throw new Error("EditableTextDisplay must be used within an EditableTextRoot context");
|
|
17203
|
+
}
|
|
17204
|
+
const { value, typographicVariant, setIsEditing, placeholder, maxLines, isEditing, minLines } = context;
|
|
17205
|
+
const triggerButtonRef = (0, import_react92.useRef)(null);
|
|
17206
|
+
const handleTriggerClick = () => {
|
|
17207
|
+
setIsEditing(true);
|
|
17208
|
+
};
|
|
17209
|
+
const elementType = renderAs ?? getDefaultTypographicElement(typographicVariant);
|
|
17210
|
+
const displayText = value.length > 0 ? value : placeholder;
|
|
17211
|
+
const isPlaceholderVisible = value.length === 0 && !!placeholder;
|
|
17212
|
+
if (isEditing) {
|
|
17213
|
+
return null;
|
|
17214
|
+
}
|
|
17215
|
+
if (asTrigger && !context.readOnly) {
|
|
17216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(ClickRegion, { targetRef: triggerButtonRef, children: /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)(
|
|
17217
|
+
StyledEditableTextDisplay,
|
|
17218
|
+
{
|
|
17219
|
+
ref,
|
|
17220
|
+
$maxLines: maxLines,
|
|
17221
|
+
$minLines: minLines,
|
|
17222
|
+
$typographicVariant: typographicVariant,
|
|
17223
|
+
as: elementType,
|
|
17224
|
+
"data-wui-editable-text-display": isPlaceholderVisible ? "placeholder" : "value",
|
|
17225
|
+
...props,
|
|
17226
|
+
children: [
|
|
17227
|
+
displayText,
|
|
17228
|
+
/* @__PURE__ */ (0, import_jsx_runtime318.jsx)(
|
|
17229
|
+
"button",
|
|
17230
|
+
{
|
|
17231
|
+
ref: triggerButtonRef,
|
|
17232
|
+
onClick: handleTriggerClick,
|
|
17233
|
+
style: { ...visuallyHiddenStyle },
|
|
17234
|
+
type: "button",
|
|
17235
|
+
children: "Edit text"
|
|
17236
|
+
}
|
|
17237
|
+
)
|
|
17238
|
+
]
|
|
17239
|
+
}
|
|
17240
|
+
) });
|
|
17241
|
+
}
|
|
17242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(
|
|
17243
|
+
StyledEditableTextDisplay,
|
|
17244
|
+
{
|
|
17245
|
+
ref,
|
|
17246
|
+
$maxLines: maxLines,
|
|
17247
|
+
$minLines: minLines,
|
|
17248
|
+
$typographicVariant: typographicVariant,
|
|
17249
|
+
as: elementType,
|
|
17250
|
+
"data-placeholder-visible": isPlaceholderVisible || void 0,
|
|
17251
|
+
"data-wui-editable-text-display": true,
|
|
17252
|
+
...props,
|
|
17253
|
+
children: displayText
|
|
17254
|
+
}
|
|
17255
|
+
);
|
|
17256
|
+
}
|
|
17257
|
+
);
|
|
17258
|
+
EditableTextDisplayComponent.displayName = "EditableTextDisplay_UI";
|
|
17259
|
+
var EditableTextDisplay = makePolymorphic(
|
|
17260
|
+
EditableTextDisplayComponent
|
|
17261
|
+
);
|
|
17262
|
+
|
|
17263
|
+
// src/components/EditableText/EditableTextInput.tsx
|
|
17264
|
+
var import_react93 = require("react");
|
|
17265
|
+
var import_styled_components124 = __toESM(require("styled-components"));
|
|
17266
|
+
var import_type_guards74 = require("@wistia/type-guards");
|
|
17267
|
+
var import_jsx_runtime319 = require("react/jsx-runtime");
|
|
17268
|
+
var StyledInput2 = (0, import_styled_components124.default)(Input)`
|
|
17269
|
+
&& {
|
|
17270
|
+
${({ $minLines }) => (0, import_type_guards74.isNotNil)($minLines) && `min-height: calc(${$minLines}lh + calc(var(--wui-editable-text-padding) * 2));`}
|
|
17271
|
+
${({ $maxLines }) => (0, import_type_guards74.isNotNil)($maxLines) && `max-height: calc(${$maxLines}lh + calc(var(--wui-editable-text-padding) * 2));`}
|
|
17272
|
+
${({ $typographicVariant }) => getTypographicStyles($typographicVariant)}
|
|
17273
|
+
padding: var(--wui-editable-text-padding);
|
|
17274
|
+
border-radius: var(--wui-editable-text-border-radius);
|
|
17275
|
+
background-color: var(--wui-color-bg-surface);
|
|
17276
|
+
}
|
|
17277
|
+
`;
|
|
17278
|
+
var EditableTextInput = (props) => {
|
|
17279
|
+
const context = (0, import_react93.useContext)(EditableTextContext);
|
|
17280
|
+
if (!context) {
|
|
17281
|
+
throw new Error("EditableTextInput must be used within an EditableTextRoot context");
|
|
17282
|
+
}
|
|
17283
|
+
const {
|
|
17284
|
+
isEditing,
|
|
17285
|
+
value,
|
|
17286
|
+
setValue,
|
|
17287
|
+
onValueCommit,
|
|
17288
|
+
setIsEditing,
|
|
17289
|
+
typographicVariant,
|
|
17290
|
+
submitMode,
|
|
17291
|
+
originalValue,
|
|
17292
|
+
onValueRevert,
|
|
17293
|
+
id,
|
|
17294
|
+
placeholder,
|
|
17295
|
+
minLines,
|
|
17296
|
+
maxLines,
|
|
17297
|
+
finalFocusEl
|
|
17298
|
+
} = context;
|
|
17299
|
+
const inputRef = (0, import_react93.useRef)(null);
|
|
17300
|
+
(0, import_react93.useEffect)(() => {
|
|
17301
|
+
if (inputRef.current) {
|
|
17302
|
+
if (isEditing) {
|
|
17303
|
+
const element = inputRef.current;
|
|
17304
|
+
const { style } = element;
|
|
17305
|
+
style.height = "0px";
|
|
17306
|
+
const { scrollHeight } = element;
|
|
17307
|
+
style.height = `${scrollHeight}px`;
|
|
17308
|
+
}
|
|
17309
|
+
if (isEditing) {
|
|
17310
|
+
inputRef.current.focus();
|
|
17311
|
+
}
|
|
17312
|
+
}
|
|
17313
|
+
}, [value, isEditing]);
|
|
17314
|
+
const handleChange = (event) => {
|
|
17315
|
+
setValue(event.target.value);
|
|
17316
|
+
};
|
|
17317
|
+
const handleKeyDown = (event) => {
|
|
17318
|
+
if ((submitMode === "enter" || submitMode === "both") && event.key === "Enter" && !event.shiftKey) {
|
|
17319
|
+
event.preventDefault();
|
|
17320
|
+
onValueCommit?.(value);
|
|
17321
|
+
setIsEditing(false);
|
|
17322
|
+
setTimeout(() => {
|
|
17323
|
+
const element = finalFocusEl?.();
|
|
17324
|
+
if (element) {
|
|
17325
|
+
element.focus();
|
|
17326
|
+
}
|
|
17327
|
+
}, 0);
|
|
17328
|
+
}
|
|
17329
|
+
if (event.key === "Escape") {
|
|
17330
|
+
event.preventDefault();
|
|
17331
|
+
setValue(originalValue);
|
|
17332
|
+
onValueRevert?.(originalValue);
|
|
17333
|
+
setIsEditing(false);
|
|
17334
|
+
setTimeout(() => {
|
|
17335
|
+
const element = finalFocusEl?.();
|
|
17336
|
+
if (element) {
|
|
17337
|
+
element.focus();
|
|
17338
|
+
}
|
|
17339
|
+
}, 0);
|
|
17340
|
+
}
|
|
17341
|
+
};
|
|
17342
|
+
const handleBlur2 = () => {
|
|
17343
|
+
if (submitMode === "blur" || submitMode === "both") {
|
|
17344
|
+
onValueCommit?.(value);
|
|
17345
|
+
setIsEditing(false);
|
|
17346
|
+
setTimeout(() => {
|
|
17347
|
+
const element = finalFocusEl?.();
|
|
17348
|
+
if (element) {
|
|
17349
|
+
element.focus();
|
|
17350
|
+
}
|
|
17351
|
+
}, 0);
|
|
17352
|
+
}
|
|
17353
|
+
};
|
|
17354
|
+
if (!isEditing) return null;
|
|
17355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
|
|
17356
|
+
StyledInput2,
|
|
17357
|
+
{
|
|
17358
|
+
ref: inputRef,
|
|
17359
|
+
$maxLines: maxLines ?? "infinity",
|
|
17360
|
+
$minLines: minLines,
|
|
17361
|
+
$typographicVariant: typographicVariant,
|
|
17362
|
+
"data-wui-editable-text-input": true,
|
|
17363
|
+
id,
|
|
17364
|
+
onBlur: handleBlur2,
|
|
17365
|
+
onChange: handleChange,
|
|
17366
|
+
onKeyDown: handleKeyDown,
|
|
17367
|
+
placeholder,
|
|
17368
|
+
type: "multiline",
|
|
17369
|
+
value,
|
|
17370
|
+
...props
|
|
17371
|
+
}
|
|
17372
|
+
);
|
|
17373
|
+
};
|
|
17374
|
+
|
|
17375
|
+
// src/components/EditableText/EditableTextLabel.tsx
|
|
17376
|
+
var import_react94 = require("react");
|
|
17377
|
+
var import_jsx_runtime320 = require("react/jsx-runtime");
|
|
17378
|
+
var EditableTextLabel = ({ ...props }) => {
|
|
17379
|
+
const context = (0, import_react94.useContext)(EditableTextContext);
|
|
17380
|
+
if (!context) {
|
|
17381
|
+
throw new Error("EditableTextLabel must be used within an EditableTextRoot context");
|
|
17382
|
+
}
|
|
17383
|
+
const { id, label } = context;
|
|
17384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(
|
|
17385
|
+
Label,
|
|
17386
|
+
{
|
|
17387
|
+
htmlFor: id,
|
|
17388
|
+
...props,
|
|
17389
|
+
children: label
|
|
17390
|
+
}
|
|
17391
|
+
);
|
|
17392
|
+
};
|
|
17393
|
+
|
|
17394
|
+
// src/components/EditableText/EditableText.tsx
|
|
17395
|
+
var import_jsx_runtime321 = require("react/jsx-runtime");
|
|
17396
|
+
var EditableText = ({ hideLabel = true, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(EditableTextRoot, { ...props, children: [
|
|
17397
|
+
/* @__PURE__ */ (0, import_jsx_runtime321.jsx)(EditableTextLabel, { screenReaderOnly: hideLabel }),
|
|
17398
|
+
/* @__PURE__ */ (0, import_jsx_runtime321.jsx)(EditableTextInput, {}),
|
|
17399
|
+
/* @__PURE__ */ (0, import_jsx_runtime321.jsx)(EditableTextDisplay, { asTrigger: true })
|
|
17400
|
+
] });
|
|
17401
|
+
EditableText.displayName = "EditableText_UI";
|
|
17402
|
+
|
|
17403
|
+
// src/components/EditableText/EditableTextSubmitButton.tsx
|
|
17404
|
+
var import_react95 = require("react");
|
|
17405
|
+
var EditableTextSubmitButton = ({
|
|
17406
|
+
/**
|
|
17407
|
+
* A submit button, typically a [Button]() that will commit the value when clicked.
|
|
17408
|
+
*/
|
|
17409
|
+
children
|
|
17410
|
+
}) => {
|
|
17411
|
+
const context = (0, import_react95.useContext)(EditableTextContext);
|
|
17412
|
+
if (!context) {
|
|
17413
|
+
throw new Error("EditableTextSubmitButton must be used within an EditableTextRoot context");
|
|
17414
|
+
}
|
|
17415
|
+
const { setIsEditing, value, onValueCommit, finalFocusEl, isEditing } = context;
|
|
17416
|
+
const handleClick = () => {
|
|
17417
|
+
onValueCommit?.(value);
|
|
17418
|
+
setIsEditing(false);
|
|
17419
|
+
setTimeout(() => {
|
|
17420
|
+
const element = finalFocusEl?.();
|
|
17421
|
+
if (element) {
|
|
17422
|
+
element.focus();
|
|
17423
|
+
}
|
|
17424
|
+
}, 0);
|
|
17425
|
+
};
|
|
17426
|
+
const onlyChild = import_react95.Children.only(children);
|
|
17427
|
+
const triggerProps = {
|
|
17428
|
+
onClick: handleClick,
|
|
17429
|
+
"data-wui-editable-text-submit": true
|
|
17430
|
+
};
|
|
17431
|
+
if (!isEditing) return null;
|
|
17432
|
+
return (0, import_react95.cloneElement)(onlyChild, triggerProps);
|
|
17433
|
+
};
|
|
17434
|
+
|
|
17435
|
+
// src/components/EditableText/EditableTextCancelButton.tsx
|
|
17436
|
+
var import_react96 = require("react");
|
|
17437
|
+
var EditableTextCancelButton = ({
|
|
17438
|
+
children
|
|
17439
|
+
}) => {
|
|
17440
|
+
const context = (0, import_react96.useContext)(EditableTextContext);
|
|
17441
|
+
if (!context) {
|
|
17442
|
+
throw new Error("EditableTextCancelButton must be used within an EditableTextRoot context");
|
|
17443
|
+
}
|
|
17444
|
+
const { setIsEditing, originalValue, setValue, onValueRevert, finalFocusEl, isEditing } = context;
|
|
17445
|
+
const handleClick = () => {
|
|
17446
|
+
setValue(originalValue);
|
|
17447
|
+
onValueRevert?.(originalValue);
|
|
17448
|
+
setIsEditing(false);
|
|
17449
|
+
setTimeout(() => {
|
|
17450
|
+
const element = finalFocusEl?.();
|
|
17451
|
+
if (element) {
|
|
17452
|
+
element.focus();
|
|
17453
|
+
}
|
|
17454
|
+
}, 0);
|
|
17455
|
+
};
|
|
17456
|
+
const onlyChild = import_react96.Children.only(children);
|
|
17457
|
+
const triggerProps = {
|
|
17458
|
+
onClick: handleClick,
|
|
17459
|
+
"data-wui-editable-text-cancel": true
|
|
17460
|
+
};
|
|
17461
|
+
if (!isEditing) return null;
|
|
17462
|
+
return (0, import_react96.cloneElement)(onlyChild, triggerProps);
|
|
17463
|
+
};
|
|
17464
|
+
|
|
17465
|
+
// src/components/EditableText/EditableTextTrigger.tsx
|
|
17466
|
+
var import_react97 = require("react");
|
|
17467
|
+
var EditableTextTrigger = ({
|
|
17468
|
+
children,
|
|
17469
|
+
...props
|
|
17470
|
+
}) => {
|
|
17471
|
+
const context = (0, import_react97.useContext)(EditableTextContext);
|
|
17472
|
+
if (!context) {
|
|
17473
|
+
throw new Error("EditableTextTrigger must be used within an EditableTextRoot context");
|
|
17474
|
+
}
|
|
17475
|
+
const { setIsEditing, isEditing } = context;
|
|
17476
|
+
const handleClick = () => {
|
|
17477
|
+
setIsEditing(true);
|
|
17478
|
+
};
|
|
17479
|
+
const onlyChild = import_react97.Children.only(children);
|
|
17480
|
+
const triggerProps = {
|
|
17481
|
+
onClick: handleClick,
|
|
17482
|
+
"data-wui-editable-text-trigger": true,
|
|
17483
|
+
...props
|
|
17484
|
+
};
|
|
17485
|
+
if (isEditing) return null;
|
|
17486
|
+
return (0, import_react97.cloneElement)(onlyChild, triggerProps);
|
|
17487
|
+
};
|
|
17488
|
+
|
|
17489
|
+
// src/components/DataList/DataList.tsx
|
|
17490
|
+
var import_styled_components125 = __toESM(require("styled-components"));
|
|
17491
|
+
var import_jsx_runtime322 = require("react/jsx-runtime");
|
|
17492
|
+
var StyledDataList = import_styled_components125.default.dl`
|
|
17013
17493
|
display: grid;
|
|
17014
17494
|
grid-template-columns: auto 1fr;
|
|
17015
17495
|
column-gap: var(--wui-space-02);
|
|
@@ -17037,7 +17517,7 @@ var DataList = ({
|
|
|
17037
17517
|
labelProminence = "primary",
|
|
17038
17518
|
...props
|
|
17039
17519
|
}) => {
|
|
17040
|
-
return /* @__PURE__ */ (0,
|
|
17520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
|
|
17041
17521
|
StyledDataList,
|
|
17042
17522
|
{
|
|
17043
17523
|
role: "list",
|
|
@@ -17060,9 +17540,9 @@ var DataListItem = ({ children }) => {
|
|
|
17060
17540
|
DataListItem.displayName = "DataListItem_UI";
|
|
17061
17541
|
|
|
17062
17542
|
// src/components/DataList/DataListItemLabel.tsx
|
|
17063
|
-
var
|
|
17543
|
+
var import_jsx_runtime323 = require("react/jsx-runtime");
|
|
17064
17544
|
var DataListItemLabel = (props) => {
|
|
17065
|
-
return /* @__PURE__ */ (0,
|
|
17545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(
|
|
17066
17546
|
Text,
|
|
17067
17547
|
{
|
|
17068
17548
|
variant: "label4",
|
|
@@ -17074,9 +17554,9 @@ var DataListItemLabel = (props) => {
|
|
|
17074
17554
|
DataListItemLabel.displayName = "DataListItemLabel_UI";
|
|
17075
17555
|
|
|
17076
17556
|
// src/components/DataList/DataListItemValue.tsx
|
|
17077
|
-
var
|
|
17557
|
+
var import_jsx_runtime324 = require("react/jsx-runtime");
|
|
17078
17558
|
var DataListItemValue = (props) => {
|
|
17079
|
-
return /* @__PURE__ */ (0,
|
|
17559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(
|
|
17080
17560
|
Text,
|
|
17081
17561
|
{
|
|
17082
17562
|
variant: "body3",
|
|
@@ -17086,6 +17566,27 @@ var DataListItemValue = (props) => {
|
|
|
17086
17566
|
);
|
|
17087
17567
|
};
|
|
17088
17568
|
DataListItemValue.displayName = "DataListItemValue_UI";
|
|
17569
|
+
|
|
17570
|
+
// src/components/Mark/Mark.tsx
|
|
17571
|
+
var import_styled_components126 = __toESM(require("styled-components"));
|
|
17572
|
+
var import_jsx_runtime325 = require("react/jsx-runtime");
|
|
17573
|
+
var StyledMark = import_styled_components126.default.mark`
|
|
17574
|
+
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
17575
|
+
background-color: var(--wui-color-bg-surface-tertiary);
|
|
17576
|
+
color: var(--wui-color-text);
|
|
17577
|
+
border-radius: var(--wui-border-radius-01);
|
|
17578
|
+
padding-inline: 0.1em;
|
|
17579
|
+
margin-inline: -0.1em;
|
|
17580
|
+
`;
|
|
17581
|
+
var Mark = ({ children, colorScheme = "inherit", ...props }) => /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(
|
|
17582
|
+
StyledMark,
|
|
17583
|
+
{
|
|
17584
|
+
$colorScheme: colorScheme,
|
|
17585
|
+
...props,
|
|
17586
|
+
children
|
|
17587
|
+
}
|
|
17588
|
+
);
|
|
17589
|
+
Mark.displayName = "Mark_UI";
|
|
17089
17590
|
// Annotate the CommonJS export names for ESM import in node:
|
|
17090
17591
|
0 && (module.exports = {
|
|
17091
17592
|
ActionButton,
|
|
@@ -17131,6 +17632,15 @@ DataListItemValue.displayName = "DataListItemValue_UI";
|
|
|
17131
17632
|
DataListItemValue,
|
|
17132
17633
|
Divider,
|
|
17133
17634
|
EditableHeading,
|
|
17635
|
+
EditableText,
|
|
17636
|
+
EditableTextCancelButton,
|
|
17637
|
+
EditableTextContext,
|
|
17638
|
+
EditableTextDisplay,
|
|
17639
|
+
EditableTextInput,
|
|
17640
|
+
EditableTextLabel,
|
|
17641
|
+
EditableTextRoot,
|
|
17642
|
+
EditableTextSubmitButton,
|
|
17643
|
+
EditableTextTrigger,
|
|
17134
17644
|
Ellipsis,
|
|
17135
17645
|
FileAmountLimitValidator,
|
|
17136
17646
|
FileSizeValidator,
|
|
@@ -17156,6 +17666,7 @@ DataListItemValue.displayName = "DataListItemValue_UI";
|
|
|
17156
17666
|
Label,
|
|
17157
17667
|
Link,
|
|
17158
17668
|
List,
|
|
17669
|
+
Mark,
|
|
17159
17670
|
Menu,
|
|
17160
17671
|
MenuItem,
|
|
17161
17672
|
MenuItemDescription,
|