@wistia/ui 0.5.3-beta.eb8f3f6e.3b96b5f → 0.5.3
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 +56 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +14 -47
- package/dist/index.d.ts +14 -47
- package/dist/index.mjs +62 -175
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1584,7 +1584,7 @@ type TextProps = ComponentPropsWithoutRef<'div'> & {
|
|
|
1584
1584
|
/**
|
|
1585
1585
|
* Used for rending paragraphs and inline text.
|
|
1586
1586
|
*/
|
|
1587
|
-
declare const Text: (<C extends ElementType = "
|
|
1587
|
+
declare const Text: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, TextProps>) => react.ReactElement | null) & UnknownRecord;
|
|
1588
1588
|
|
|
1589
1589
|
type MenuItemLabelProps = {
|
|
1590
1590
|
/**
|
|
@@ -2230,22 +2230,12 @@ type DataCardTrendProps = {
|
|
|
2230
2230
|
};
|
|
2231
2231
|
declare const DataCardTrend: ({ direction, outlook, children, ...props }: DataCardTrendProps) => JSX.Element;
|
|
2232
2232
|
|
|
2233
|
-
type VariantTypes = keyof typeof variantStyleMap$1 | keyof typeof variantStyleMap;
|
|
2234
|
-
type VariantElementTypes = (typeof variantElementMap)[keyof typeof variantElementMap];
|
|
2235
|
-
type FullWidthConfig = boolean | {
|
|
2236
|
-
heading?: boolean;
|
|
2237
|
-
input?: boolean;
|
|
2238
|
-
};
|
|
2239
|
-
declare const variantElementMap: {
|
|
2240
|
-
[x: string]: react.ElementType;
|
|
2241
|
-
};
|
|
2242
2233
|
type EditableHeadingProps = {
|
|
2243
2234
|
/**
|
|
2244
|
-
* The text content of the heading.
|
|
2245
|
-
*
|
|
2246
|
-
* If provided with onValueChange, acts as controlled value.
|
|
2235
|
+
* The initial text content of the heading.
|
|
2236
|
+
* This will be displayed and used as the starting value when editing begins.
|
|
2247
2237
|
*/
|
|
2248
|
-
|
|
2238
|
+
children: string;
|
|
2249
2239
|
/**
|
|
2250
2240
|
* Callback fired when editing is completed (on blur or Enter key). Does not fire if the value is empty or the same as the previous value.
|
|
2251
2241
|
* @param value The new text content after editing
|
|
@@ -2257,53 +2247,30 @@ type EditableHeadingProps = {
|
|
|
2257
2247
|
*/
|
|
2258
2248
|
onEditingChange?: (isEditing: boolean) => void;
|
|
2259
2249
|
/**
|
|
2260
|
-
* Custom tooltip text shown when hovering over the heading.
|
|
2250
|
+
* Custom tooltip text shown when hovering over the heading.
|
|
2261
2251
|
*/
|
|
2262
2252
|
tooltipText?: string;
|
|
2263
2253
|
/**
|
|
2264
2254
|
* Sets an aria-label for the input and label for the screen reader only button.
|
|
2265
2255
|
*/
|
|
2266
|
-
ariaLabel
|
|
2267
|
-
/**
|
|
2268
|
-
* When true, prevents the heading from entering edit mode
|
|
2269
|
-
* @default false
|
|
2270
|
-
*/
|
|
2271
|
-
isEditing?: boolean | undefined;
|
|
2256
|
+
ariaLabel?: string;
|
|
2272
2257
|
/**
|
|
2273
|
-
*
|
|
2274
|
-
|
|
2275
|
-
textVariant?: VariantTypes;
|
|
2276
|
-
/**
|
|
2277
|
-
* What element to render the text as.
|
|
2278
|
-
*/
|
|
2279
|
-
renderTextAs?: VariantElementTypes;
|
|
2280
|
-
/**
|
|
2281
|
-
* Controls the width behavior of the heading and input
|
|
2282
|
-
* @default true
|
|
2283
|
-
* Pass a boolean to set both heading and input width
|
|
2284
|
-
* Pass an object to set them independently: { heading?: boolean; input?: boolean }
|
|
2285
|
-
*/
|
|
2286
|
-
fullWidth?: FullWidthConfig;
|
|
2287
|
-
/**
|
|
2288
|
-
* When true, prevents text wrapping and uses a single-line input
|
|
2289
|
-
* @default false
|
|
2290
|
-
*/
|
|
2291
|
-
singleLine?: boolean;
|
|
2292
|
-
/**
|
|
2293
|
-
* When true, the editing state will not close when the input is blurred
|
|
2294
|
-
* @default false
|
|
2258
|
+
* Force editing state for testing purposes
|
|
2259
|
+
*
|
|
2295
2260
|
*/
|
|
2296
|
-
|
|
2261
|
+
forceEditing?: boolean;
|
|
2297
2262
|
/**
|
|
2298
|
-
* When true, prevents the heading from
|
|
2263
|
+
* When true, prevents the heading from entering edit mode
|
|
2299
2264
|
* @default false
|
|
2300
2265
|
*/
|
|
2301
2266
|
editingDisabled?: boolean;
|
|
2302
2267
|
};
|
|
2303
2268
|
/**
|
|
2304
|
-
*
|
|
2269
|
+
* A special heading component that allows for inline editing. When clicked or activated via keyboard,
|
|
2270
|
+
* it transforms into an editable text field. In its default state, it renders as a heading with
|
|
2271
|
+
* an accessible button that enables editing mode. The component handles empty values, keyboard
|
|
2305
2272
|
* navigation (Enter to save, Escape to cancel), and provides callbacks for value and state changes.
|
|
2306
2273
|
*/
|
|
2307
|
-
declare const EditableHeading: ({
|
|
2274
|
+
declare const EditableHeading: ({ children, onValueChange, onEditingChange, tooltipText, ariaLabel, forceEditing, editingDisabled, }: EditableHeadingProps) => JSX.Element;
|
|
2308
2275
|
|
|
2309
2276
|
export { ActionButton, type ActionButtonProps, Avatar, type AvatarProps, type AvatarStatus, Badge, type BadgeProps, Box, type BoxProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Button, ButtonGroup, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, DataCard, type DataCardProps, DataCardTrend, type DataCardTrendProps, DataCards, type DataCardsProps, Divider, EditableHeading, type EditableHeadingProps, Ellipsis, Form, FormErrorSummary, FormField, type FormFieldProps, FormGroup, type FormGroupProps, type FormProps, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Input, type InputProps, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Modal, type ModalProps, Radio, RadioGroup, RadioMenuItem, type RadioProps, ScreenReaderOnly, SegmentedControl, SegmentedControlItem, type SegmentedControlItemProps, type SegmentedControlProps, Select, SelectOption, SelectOptionGroup, type SelectOptionGroupProps, type SelectOptionProps, type SelectProps, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, dateTime, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useBoolean, useFormState, useKey, useMq, useToast, useWindowSize };
|
package/dist/index.d.ts
CHANGED
|
@@ -1584,7 +1584,7 @@ type TextProps = ComponentPropsWithoutRef<'div'> & {
|
|
|
1584
1584
|
/**
|
|
1585
1585
|
* Used for rending paragraphs and inline text.
|
|
1586
1586
|
*/
|
|
1587
|
-
declare const Text: (<C extends ElementType = "
|
|
1587
|
+
declare const Text: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, TextProps>) => react.ReactElement | null) & UnknownRecord;
|
|
1588
1588
|
|
|
1589
1589
|
type MenuItemLabelProps = {
|
|
1590
1590
|
/**
|
|
@@ -2230,22 +2230,12 @@ type DataCardTrendProps = {
|
|
|
2230
2230
|
};
|
|
2231
2231
|
declare const DataCardTrend: ({ direction, outlook, children, ...props }: DataCardTrendProps) => JSX.Element;
|
|
2232
2232
|
|
|
2233
|
-
type VariantTypes = keyof typeof variantStyleMap$1 | keyof typeof variantStyleMap;
|
|
2234
|
-
type VariantElementTypes = (typeof variantElementMap)[keyof typeof variantElementMap];
|
|
2235
|
-
type FullWidthConfig = boolean | {
|
|
2236
|
-
heading?: boolean;
|
|
2237
|
-
input?: boolean;
|
|
2238
|
-
};
|
|
2239
|
-
declare const variantElementMap: {
|
|
2240
|
-
[x: string]: react.ElementType;
|
|
2241
|
-
};
|
|
2242
2233
|
type EditableHeadingProps = {
|
|
2243
2234
|
/**
|
|
2244
|
-
* The text content of the heading.
|
|
2245
|
-
*
|
|
2246
|
-
* If provided with onValueChange, acts as controlled value.
|
|
2235
|
+
* The initial text content of the heading.
|
|
2236
|
+
* This will be displayed and used as the starting value when editing begins.
|
|
2247
2237
|
*/
|
|
2248
|
-
|
|
2238
|
+
children: string;
|
|
2249
2239
|
/**
|
|
2250
2240
|
* Callback fired when editing is completed (on blur or Enter key). Does not fire if the value is empty or the same as the previous value.
|
|
2251
2241
|
* @param value The new text content after editing
|
|
@@ -2257,53 +2247,30 @@ type EditableHeadingProps = {
|
|
|
2257
2247
|
*/
|
|
2258
2248
|
onEditingChange?: (isEditing: boolean) => void;
|
|
2259
2249
|
/**
|
|
2260
|
-
* Custom tooltip text shown when hovering over the heading.
|
|
2250
|
+
* Custom tooltip text shown when hovering over the heading.
|
|
2261
2251
|
*/
|
|
2262
2252
|
tooltipText?: string;
|
|
2263
2253
|
/**
|
|
2264
2254
|
* Sets an aria-label for the input and label for the screen reader only button.
|
|
2265
2255
|
*/
|
|
2266
|
-
ariaLabel
|
|
2267
|
-
/**
|
|
2268
|
-
* When true, prevents the heading from entering edit mode
|
|
2269
|
-
* @default false
|
|
2270
|
-
*/
|
|
2271
|
-
isEditing?: boolean | undefined;
|
|
2256
|
+
ariaLabel?: string;
|
|
2272
2257
|
/**
|
|
2273
|
-
*
|
|
2274
|
-
|
|
2275
|
-
textVariant?: VariantTypes;
|
|
2276
|
-
/**
|
|
2277
|
-
* What element to render the text as.
|
|
2278
|
-
*/
|
|
2279
|
-
renderTextAs?: VariantElementTypes;
|
|
2280
|
-
/**
|
|
2281
|
-
* Controls the width behavior of the heading and input
|
|
2282
|
-
* @default true
|
|
2283
|
-
* Pass a boolean to set both heading and input width
|
|
2284
|
-
* Pass an object to set them independently: { heading?: boolean; input?: boolean }
|
|
2285
|
-
*/
|
|
2286
|
-
fullWidth?: FullWidthConfig;
|
|
2287
|
-
/**
|
|
2288
|
-
* When true, prevents text wrapping and uses a single-line input
|
|
2289
|
-
* @default false
|
|
2290
|
-
*/
|
|
2291
|
-
singleLine?: boolean;
|
|
2292
|
-
/**
|
|
2293
|
-
* When true, the editing state will not close when the input is blurred
|
|
2294
|
-
* @default false
|
|
2258
|
+
* Force editing state for testing purposes
|
|
2259
|
+
*
|
|
2295
2260
|
*/
|
|
2296
|
-
|
|
2261
|
+
forceEditing?: boolean;
|
|
2297
2262
|
/**
|
|
2298
|
-
* When true, prevents the heading from
|
|
2263
|
+
* When true, prevents the heading from entering edit mode
|
|
2299
2264
|
* @default false
|
|
2300
2265
|
*/
|
|
2301
2266
|
editingDisabled?: boolean;
|
|
2302
2267
|
};
|
|
2303
2268
|
/**
|
|
2304
|
-
*
|
|
2269
|
+
* A special heading component that allows for inline editing. When clicked or activated via keyboard,
|
|
2270
|
+
* it transforms into an editable text field. In its default state, it renders as a heading with
|
|
2271
|
+
* an accessible button that enables editing mode. The component handles empty values, keyboard
|
|
2305
2272
|
* navigation (Enter to save, Escape to cancel), and provides callbacks for value and state changes.
|
|
2306
2273
|
*/
|
|
2307
|
-
declare const EditableHeading: ({
|
|
2274
|
+
declare const EditableHeading: ({ children, onValueChange, onEditingChange, tooltipText, ariaLabel, forceEditing, editingDisabled, }: EditableHeadingProps) => JSX.Element;
|
|
2308
2275
|
|
|
2309
2276
|
export { ActionButton, type ActionButtonProps, Avatar, type AvatarProps, type AvatarStatus, Badge, type BadgeProps, Box, type BoxProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Button, ButtonGroup, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, DataCard, type DataCardProps, DataCardTrend, type DataCardTrendProps, DataCards, type DataCardsProps, Divider, EditableHeading, type EditableHeadingProps, Ellipsis, Form, FormErrorSummary, FormField, type FormFieldProps, FormGroup, type FormGroupProps, type FormProps, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Input, type InputProps, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Modal, type ModalProps, Radio, RadioGroup, RadioMenuItem, type RadioProps, ScreenReaderOnly, SegmentedControl, SegmentedControlItem, type SegmentedControlItemProps, type SegmentedControlProps, Select, SelectOption, SelectOptionGroup, type SelectOptionGroupProps, type SelectOptionProps, type SelectProps, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, dateTime, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useBoolean, useFormState, useKey, useMq, useToast, useWindowSize };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.5.3
|
|
3
|
+
* @license @wistia/ui v0.5.3
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -6798,15 +6798,6 @@ var variantStyleMap = {
|
|
|
6798
6798
|
heading6: heading6TextStyle
|
|
6799
6799
|
};
|
|
6800
6800
|
var DEFAULT_ELEMENT2 = "h1";
|
|
6801
|
-
var variantElementMap = {
|
|
6802
|
-
hero: DEFAULT_ELEMENT2,
|
|
6803
|
-
heading1: DEFAULT_ELEMENT2,
|
|
6804
|
-
heading2: "h2",
|
|
6805
|
-
heading3: "h3",
|
|
6806
|
-
heading4: "h4",
|
|
6807
|
-
heading5: "h5",
|
|
6808
|
-
heading6: "h6"
|
|
6809
|
-
};
|
|
6810
6801
|
var StyledHeading = styled15.div`
|
|
6811
6802
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
6812
6803
|
font-family: var(--font-family);
|
|
@@ -6830,6 +6821,15 @@ var StyledHeading = styled15.div`
|
|
|
6830
6821
|
`}
|
|
6831
6822
|
margin: 0;
|
|
6832
6823
|
`;
|
|
6824
|
+
var variantElementMap = {
|
|
6825
|
+
hero: DEFAULT_ELEMENT2,
|
|
6826
|
+
heading1: DEFAULT_ELEMENT2,
|
|
6827
|
+
heading2: "h2",
|
|
6828
|
+
heading3: "h3",
|
|
6829
|
+
heading4: "h4",
|
|
6830
|
+
heading5: "h5",
|
|
6831
|
+
heading6: "h6"
|
|
6832
|
+
};
|
|
6833
6833
|
var HeadingComponent = forwardRef6(
|
|
6834
6834
|
({
|
|
6835
6835
|
align = "left",
|
|
@@ -7422,23 +7422,6 @@ var variantStyleMap2 = {
|
|
|
7422
7422
|
label3: label3TextStyle,
|
|
7423
7423
|
label4: label4TextStyle
|
|
7424
7424
|
};
|
|
7425
|
-
var bodyElement = "p";
|
|
7426
|
-
var labelElement = "span";
|
|
7427
|
-
var DEFAULT_ELEMENT4 = bodyElement;
|
|
7428
|
-
var variantElementMap2 = {
|
|
7429
|
-
body1: bodyElement,
|
|
7430
|
-
body2: bodyElement,
|
|
7431
|
-
body3: bodyElement,
|
|
7432
|
-
body4: bodyElement,
|
|
7433
|
-
body1Mono: bodyElement,
|
|
7434
|
-
body2Mono: bodyElement,
|
|
7435
|
-
body3Mono: bodyElement,
|
|
7436
|
-
body4Mono: bodyElement,
|
|
7437
|
-
label1: labelElement,
|
|
7438
|
-
label2: labelElement,
|
|
7439
|
-
label3: labelElement,
|
|
7440
|
-
label4: labelElement
|
|
7441
|
-
};
|
|
7442
7425
|
var StyledText = styled22.div`
|
|
7443
7426
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
7444
7427
|
--text-color: ${({ $prominence, $disabled }) => {
|
|
@@ -7479,6 +7462,7 @@ var StyledText = styled22.div`
|
|
|
7479
7462
|
display: block;
|
|
7480
7463
|
`}
|
|
7481
7464
|
`;
|
|
7465
|
+
var DEFAULT_ELEMENT4 = "div";
|
|
7482
7466
|
var TextComponent = forwardRef10(
|
|
7483
7467
|
({
|
|
7484
7468
|
align = "left",
|
|
@@ -9728,72 +9712,27 @@ var DataCardTrend = ({
|
|
|
9728
9712
|
|
|
9729
9713
|
// src/components/EditableHeading/EditableHeading.tsx
|
|
9730
9714
|
import styled50, { css as css25 } from "styled-components";
|
|
9731
|
-
import { useState as useState8, useRef as useRef8
|
|
9732
|
-
import { isNotNil as isNotNil19, isNotNull as isNotNull2 } from "@wistia/type-guards";
|
|
9715
|
+
import { useState as useState8, useRef as useRef8 } from "react";
|
|
9733
9716
|
import { Fragment as Fragment5, jsx as jsx213, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
9734
|
-
var variantStyleMap3 = { ...variantStyleMap, ...variantStyleMap2 };
|
|
9735
|
-
var variantElementMap3 = {
|
|
9736
|
-
...variantElementMap,
|
|
9737
|
-
...variantElementMap2
|
|
9738
|
-
};
|
|
9739
|
-
var textStyles = css25`
|
|
9740
|
-
${({ $variant }) => variantStyleMap3[$variant]}
|
|
9741
|
-
font-family: var(--font-family);
|
|
9742
|
-
font-size: var(--font-size);
|
|
9743
|
-
font-weight: var(--font-weight);
|
|
9744
|
-
line-height: var(--line-height);
|
|
9745
|
-
`;
|
|
9746
|
-
var compactStyles = css25`
|
|
9747
|
-
padding: var(--wui-space-01);
|
|
9748
|
-
border-radius: var(--wui-border-radius-01);
|
|
9749
|
-
`;
|
|
9750
|
-
var defaultStyles = css25`
|
|
9751
|
-
padding: var(--wui-space-02);
|
|
9752
|
-
border-radius: var(--wui-border-radius-02);
|
|
9753
|
-
`;
|
|
9754
|
-
var stylesMap = {
|
|
9755
|
-
hero: "default",
|
|
9756
|
-
heading1: "default",
|
|
9757
|
-
heading2: "default",
|
|
9758
|
-
heading3: "default",
|
|
9759
|
-
heading4: "compact",
|
|
9760
|
-
heading5: "compact",
|
|
9761
|
-
heading6: "compact",
|
|
9762
|
-
body1: "default",
|
|
9763
|
-
body2: "compact",
|
|
9764
|
-
body3: "compact",
|
|
9765
|
-
body4: "compact",
|
|
9766
|
-
label1: "default",
|
|
9767
|
-
label2: "compact",
|
|
9768
|
-
label3: "compact",
|
|
9769
|
-
label4: "compact",
|
|
9770
|
-
body1Mono: "default",
|
|
9771
|
-
body2Mono: "compact",
|
|
9772
|
-
body3Mono: "compact",
|
|
9773
|
-
body4Mono: "compact"
|
|
9774
|
-
};
|
|
9775
|
-
var sharedStyles = css25`
|
|
9776
|
-
${({ $variant }) => stylesMap[$variant] === "default" ? defaultStyles : compactStyles}
|
|
9777
|
-
`;
|
|
9778
9717
|
var StyledInput = styled50(Input)`
|
|
9779
9718
|
:not([rows]) {
|
|
9780
9719
|
min-height: unset;
|
|
9781
9720
|
}
|
|
9782
9721
|
|
|
9783
|
-
|
|
9722
|
+
resize: vertical;
|
|
9723
|
+
font-size: var(--wui-typography-heading-1-size);
|
|
9724
|
+
font-weight: var(--wui-typography-heading-1-weight);
|
|
9725
|
+
line-height: var(--wui-typography-heading-1-line-height);
|
|
9726
|
+
font-family: var(--wui-typography-heading-1-family);
|
|
9727
|
+
outline: 2px solid var(--wui-color-focus-ring);
|
|
9728
|
+
outline-offset: -2px;
|
|
9729
|
+
|
|
9784
9730
|
&& {
|
|
9731
|
+
width: 100%;
|
|
9732
|
+
padding: var(--wui-space-02);
|
|
9785
9733
|
border: none;
|
|
9786
9734
|
height: ${({ $height }) => `${$height}px`};
|
|
9787
|
-
${sharedStyles}
|
|
9788
9735
|
}
|
|
9789
|
-
resize: vertical;
|
|
9790
|
-
outline: 2px solid var(--wui-color-border);
|
|
9791
|
-
outline-offset: -2px;
|
|
9792
|
-
&:focus {
|
|
9793
|
-
outline-color: var(--wui-color-focus-ring);
|
|
9794
|
-
}
|
|
9795
|
-
|
|
9796
|
-
${({ $width }) => isNotNull2($width) && `width: ${$width}`};
|
|
9797
9736
|
`;
|
|
9798
9737
|
var editableStyles = css25`
|
|
9799
9738
|
&:has(+ :focus-within) {
|
|
@@ -9805,87 +9744,47 @@ var editableStyles = css25`
|
|
|
9805
9744
|
cursor: pointer;
|
|
9806
9745
|
}
|
|
9807
9746
|
`;
|
|
9808
|
-
var
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
var StyledHeading2 = styled50.span`
|
|
9814
|
-
${textStyles}
|
|
9815
|
-
&& {
|
|
9816
|
-
margin: 0;
|
|
9817
|
-
${sharedStyles}
|
|
9818
|
-
width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
|
|
9819
|
-
${({ $singleLine }) => $singleLine && singleLineStyles}
|
|
9820
|
-
}
|
|
9821
|
-
display: block;
|
|
9822
|
-
overflow-wrap: ${({ $singleLine }) => $singleLine ? "normal" : "anywhere"};
|
|
9747
|
+
var StyledHeading2 = styled50(Heading)`
|
|
9748
|
+
width: 100%;
|
|
9749
|
+
border-radius: var(--wui-border-radius-02);
|
|
9750
|
+
padding: var(--wui-space-02);
|
|
9751
|
+
overflow-wrap: anywhere;
|
|
9823
9752
|
transition: all var(--wui-motion-duration-01) var(--wui-motion-ease);
|
|
9824
|
-
${({ $
|
|
9753
|
+
${({ $editingDisabled }) => !$editingDisabled && editableStyles}
|
|
9825
9754
|
`;
|
|
9826
|
-
var resolveFullWidth = (fullWidth) => ({
|
|
9827
|
-
heading: typeof fullWidth === "boolean" ? fullWidth : fullWidth.heading ?? true,
|
|
9828
|
-
input: typeof fullWidth === "boolean" ? fullWidth : fullWidth.input ?? true
|
|
9829
|
-
});
|
|
9830
9755
|
var EditableHeading = ({
|
|
9831
|
-
|
|
9756
|
+
children,
|
|
9832
9757
|
onValueChange,
|
|
9833
9758
|
onEditingChange,
|
|
9834
|
-
tooltipText,
|
|
9835
|
-
ariaLabel,
|
|
9836
|
-
|
|
9837
|
-
renderTextAs: passedRenderTextAs,
|
|
9838
|
-
textVariant = "heading1",
|
|
9839
|
-
fullWidth = true,
|
|
9840
|
-
singleLine = false,
|
|
9841
|
-
disableOnBlur = false,
|
|
9759
|
+
tooltipText = "Click to edit title",
|
|
9760
|
+
ariaLabel = "Edit title",
|
|
9761
|
+
forceEditing = false,
|
|
9842
9762
|
editingDisabled = false
|
|
9843
9763
|
}) => {
|
|
9844
|
-
const [
|
|
9845
|
-
const [
|
|
9846
|
-
const [previousValue, setPreviousValue] = useState8(
|
|
9764
|
+
const [isEditing, setIsEditing] = useState8(false);
|
|
9765
|
+
const [value, setValue] = useState8(children);
|
|
9766
|
+
const [previousValue, setPreviousValue] = useState8(children);
|
|
9847
9767
|
const [headingHeight, setHeadingHeight] = useState8("60");
|
|
9848
|
-
const [headingWidth, setHeadingWidth] = useState8("auto");
|
|
9849
9768
|
const headingRef = useRef8(null);
|
|
9850
|
-
const
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
const value = isValueControlled ? controlledValue : internalValue;
|
|
9854
|
-
useEffect5(() => {
|
|
9855
|
-
if (isValueControlled) {
|
|
9856
|
-
setInternalValue(controlledValue);
|
|
9857
|
-
setPreviousValue(controlledValue);
|
|
9858
|
-
}
|
|
9859
|
-
}, [controlledValue, isValueControlled]);
|
|
9860
|
-
const renderTextAs = passedRenderTextAs ?? variantElementMap3[textVariant];
|
|
9861
|
-
useEffect5(() => {
|
|
9862
|
-
if (headingRef.current) {
|
|
9769
|
+
const handleSetEditing = (editing) => {
|
|
9770
|
+
if (editingDisabled) return;
|
|
9771
|
+
if (editing && headingRef.current) {
|
|
9863
9772
|
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9864
|
-
setHeadingWidth(`${headingRef.current.offsetWidth}`);
|
|
9865
9773
|
}
|
|
9866
|
-
}, [isEditing]);
|
|
9867
|
-
const handleValueChange = (newValue) => {
|
|
9868
|
-
if (!isValueControlled) {
|
|
9869
|
-
setInternalValue(newValue);
|
|
9870
|
-
}
|
|
9871
|
-
onValueChange?.(newValue);
|
|
9872
|
-
};
|
|
9873
|
-
const handleSetEditing = (editing) => {
|
|
9874
9774
|
if (editing) {
|
|
9875
9775
|
setPreviousValue(value);
|
|
9876
9776
|
}
|
|
9877
|
-
|
|
9878
|
-
setInternalIsEditing(editing);
|
|
9879
|
-
}
|
|
9777
|
+
setIsEditing(editing);
|
|
9880
9778
|
onEditingChange?.(editing);
|
|
9881
9779
|
};
|
|
9882
9780
|
const handleFinishEditing = () => {
|
|
9883
9781
|
const trimmedValue = value.trim();
|
|
9884
|
-
if (trimmedValue === ""
|
|
9885
|
-
|
|
9886
|
-
}
|
|
9887
|
-
|
|
9888
|
-
|
|
9782
|
+
if (trimmedValue === "") {
|
|
9783
|
+
setValue(previousValue);
|
|
9784
|
+
} else if (trimmedValue !== previousValue && onValueChange) {
|
|
9785
|
+
onValueChange(trimmedValue);
|
|
9786
|
+
} else {
|
|
9787
|
+
setValue(trimmedValue);
|
|
9889
9788
|
}
|
|
9890
9789
|
handleSetEditing(false);
|
|
9891
9790
|
};
|
|
@@ -9895,50 +9794,38 @@ var EditableHeading = ({
|
|
|
9895
9794
|
handleFinishEditing();
|
|
9896
9795
|
}
|
|
9897
9796
|
if (event.key === "Escape") {
|
|
9898
|
-
|
|
9899
|
-
setInternalValue(previousValue);
|
|
9900
|
-
}
|
|
9797
|
+
setValue(previousValue);
|
|
9901
9798
|
handleSetEditing(false);
|
|
9902
9799
|
}
|
|
9903
9800
|
};
|
|
9904
|
-
const
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
$isEditingControlled: isEditingControlled || editingDisabled,
|
|
9914
|
-
$singleLine: singleLine,
|
|
9915
|
-
$variant: textVariant,
|
|
9916
|
-
as: renderTextAs,
|
|
9917
|
-
onClick: () => !editingDisabled && !isEditing && handleSetEditing(true),
|
|
9918
|
-
children: value
|
|
9919
|
-
}
|
|
9920
|
-
)
|
|
9801
|
+
const HeadingComponent2 = /* @__PURE__ */ jsx213(
|
|
9802
|
+
StyledHeading2,
|
|
9803
|
+
{
|
|
9804
|
+
ref: headingRef,
|
|
9805
|
+
$editingDisabled: editingDisabled,
|
|
9806
|
+
onClick: () => handleSetEditing(true),
|
|
9807
|
+
variant: "heading1",
|
|
9808
|
+
children: value
|
|
9809
|
+
}
|
|
9921
9810
|
);
|
|
9922
9811
|
if (editingDisabled) {
|
|
9923
9812
|
return HeadingComponent2;
|
|
9924
9813
|
}
|
|
9925
|
-
if (isEditing) {
|
|
9814
|
+
if (isEditing || forceEditing) {
|
|
9926
9815
|
return /* @__PURE__ */ jsx213(
|
|
9927
9816
|
StyledInput,
|
|
9928
9817
|
{
|
|
9929
9818
|
$height: headingHeight,
|
|
9930
|
-
$variant: textVariant,
|
|
9931
|
-
$width: resolvedFullWidth.input ? headingWidth : null,
|
|
9932
9819
|
autoFocus: true,
|
|
9933
|
-
fullWidth:
|
|
9934
|
-
onBlur:
|
|
9935
|
-
onChange: (event) =>
|
|
9820
|
+
fullWidth: true,
|
|
9821
|
+
onBlur: handleFinishEditing,
|
|
9822
|
+
onChange: (event) => setValue(event.target.value),
|
|
9936
9823
|
onFocus: (event) => {
|
|
9937
9824
|
const { length } = event.currentTarget.value;
|
|
9938
9825
|
event.currentTarget.setSelectionRange(length, length);
|
|
9939
9826
|
},
|
|
9940
9827
|
onKeyDown: handleKeyDown,
|
|
9941
|
-
type:
|
|
9828
|
+
type: "multiline",
|
|
9942
9829
|
value
|
|
9943
9830
|
}
|
|
9944
9831
|
);
|
|
@@ -9948,11 +9835,11 @@ var EditableHeading = ({
|
|
|
9948
9835
|
Tooltip,
|
|
9949
9836
|
{
|
|
9950
9837
|
compact: true,
|
|
9951
|
-
content: tooltipText
|
|
9838
|
+
content: tooltipText,
|
|
9952
9839
|
children: HeadingComponent2
|
|
9953
9840
|
}
|
|
9954
9841
|
),
|
|
9955
|
-
|
|
9842
|
+
/* @__PURE__ */ jsx213(ScreenReaderOnly, { children: /* @__PURE__ */ jsx213(
|
|
9956
9843
|
"button",
|
|
9957
9844
|
{
|
|
9958
9845
|
"aria-label": ariaLabel,
|