@wistia/ui 0.5.2-beta.e9c9ab1e.5bceb43 → 0.5.2
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 +1 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +13 -60
- package/dist/index.d.ts +13 -60
- package/dist/index.mjs +1 -148
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.d.mts
CHANGED
|
@@ -575,7 +575,9 @@ type BoxProps = ComponentPropsWithoutRef<typeof DEFAULT_ELEMENT$1> & {
|
|
|
575
575
|
/**
|
|
576
576
|
* Box is a layout container using [CSS Flexbox](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox).
|
|
577
577
|
*/
|
|
578
|
-
declare const Box: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, BoxProps>) => react.ReactElement | null) &
|
|
578
|
+
declare const Box: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, BoxProps>) => react.ReactElement | null) & {
|
|
579
|
+
[x: string]: unknown;
|
|
580
|
+
};
|
|
579
581
|
|
|
580
582
|
type BreadcrumbsProps = ComponentPropsWithoutRef<'div'> & {
|
|
581
583
|
/**
|
|
@@ -990,7 +992,9 @@ type HeadingProps = ComponentPropsWithoutRef<typeof DEFAULT_ELEMENT> & {
|
|
|
990
992
|
/**
|
|
991
993
|
* Displaying heading text, both visually and semantically
|
|
992
994
|
*/
|
|
993
|
-
declare const Heading: (<C extends ElementType = "h1">(props: PolymorphicComponentProps<C, HeadingProps>) => react.ReactElement | null) &
|
|
995
|
+
declare const Heading: (<C extends ElementType = "h1">(props: PolymorphicComponentProps<C, HeadingProps>) => react.ReactElement | null) & {
|
|
996
|
+
[x: string]: unknown;
|
|
997
|
+
};
|
|
994
998
|
|
|
995
999
|
declare const iconMap: {
|
|
996
1000
|
'ab-test': (props: react.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
|
|
@@ -1584,7 +1588,9 @@ type TextProps = ComponentPropsWithoutRef<'div'> & {
|
|
|
1584
1588
|
/**
|
|
1585
1589
|
* Used for rending paragraphs and inline text.
|
|
1586
1590
|
*/
|
|
1587
|
-
declare const Text: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, TextProps>) => react.ReactElement | null) &
|
|
1591
|
+
declare const Text: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, TextProps>) => react.ReactElement | null) & {
|
|
1592
|
+
[x: string]: unknown;
|
|
1593
|
+
};
|
|
1588
1594
|
|
|
1589
1595
|
type MenuItemLabelProps = {
|
|
1590
1596
|
/**
|
|
@@ -1958,7 +1964,9 @@ type StackProps = {
|
|
|
1958
1964
|
* Used to layout its children in a vertical or horizontal stack. The gap between each item in the stack can be customized.
|
|
1959
1965
|
* This allows for layouting children in a consistent way without needing to manually add margins or padding.
|
|
1960
1966
|
*/
|
|
1961
|
-
declare const Stack: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, StackProps>) => react.ReactElement | null) &
|
|
1967
|
+
declare const Stack: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, StackProps>) => react.ReactElement | null) & {
|
|
1968
|
+
[x: string]: unknown;
|
|
1969
|
+
};
|
|
1962
1970
|
|
|
1963
1971
|
type TagProps = ComponentPropsWithoutRef<'div'> & {
|
|
1964
1972
|
/**
|
|
@@ -2230,59 +2238,4 @@ type DataCardTrendProps = {
|
|
|
2230
2238
|
};
|
|
2231
2239
|
declare const DataCardTrend: ({ direction, outlook, children, ...props }: DataCardTrendProps) => JSX.Element;
|
|
2232
2240
|
|
|
2233
|
-
type
|
|
2234
|
-
/**
|
|
2235
|
-
* The initial text content of the heading.
|
|
2236
|
-
* This will be displayed and used as the starting value when editing begins.
|
|
2237
|
-
*/
|
|
2238
|
-
children: string;
|
|
2239
|
-
/**
|
|
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.
|
|
2241
|
-
* @param value The new text content after editing
|
|
2242
|
-
*/
|
|
2243
|
-
onValueChange?: (value: string) => void;
|
|
2244
|
-
/**
|
|
2245
|
-
* Callback fired when the editing state changes.
|
|
2246
|
-
* @param isEditing True when entering edit mode, false when exiting
|
|
2247
|
-
*/
|
|
2248
|
-
onEditingChange?: (isEditing: boolean) => void;
|
|
2249
|
-
/**
|
|
2250
|
-
* Custom tooltip text shown when hovering over the heading.
|
|
2251
|
-
*/
|
|
2252
|
-
tooltipText?: string;
|
|
2253
|
-
/**
|
|
2254
|
-
* Sets an aria-label for the input and label for the screen reader only button.
|
|
2255
|
-
*/
|
|
2256
|
-
ariaLabel?: string;
|
|
2257
|
-
/**
|
|
2258
|
-
* Force editing state for testing purposes
|
|
2259
|
-
*
|
|
2260
|
-
*/
|
|
2261
|
-
forceEditing?: boolean;
|
|
2262
|
-
/**
|
|
2263
|
-
* When true, prevents the heading from entering edit mode
|
|
2264
|
-
* @default false
|
|
2265
|
-
*/
|
|
2266
|
-
editingDisabled?: boolean;
|
|
2267
|
-
/**
|
|
2268
|
-
* Additional props for the heading element
|
|
2269
|
-
*/
|
|
2270
|
-
headingProps?: HeadingProps;
|
|
2271
|
-
/**
|
|
2272
|
-
* Additional props for the textarea element
|
|
2273
|
-
*/
|
|
2274
|
-
inputProps?: InputProps;
|
|
2275
|
-
/**
|
|
2276
|
-
* Optional data-testid attribute for testing purposes
|
|
2277
|
-
*/
|
|
2278
|
-
'data-testid'?: string;
|
|
2279
|
-
};
|
|
2280
|
-
/**
|
|
2281
|
-
* A special heading component that allows for inline editing. When clicked or activated via keyboard,
|
|
2282
|
-
* it transforms into an editable text field. In its default state, it renders as a heading with
|
|
2283
|
-
* an accessible button that enables editing mode. The component handles empty values, keyboard
|
|
2284
|
-
* navigation (Enter to save, Escape to cancel), and provides callbacks for value and state changes.
|
|
2285
|
-
*/
|
|
2286
|
-
declare const EditableHeading: ({ children, onValueChange, onEditingChange, tooltipText, ariaLabel, forceEditing, editingDisabled, inputProps, headingProps, "data-testid": dataTestId, }: EditableHeadingProps) => JSX.Element;
|
|
2287
|
-
|
|
2288
|
-
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 };
|
|
2241
|
+
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, 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
|
@@ -575,7 +575,9 @@ type BoxProps = ComponentPropsWithoutRef<typeof DEFAULT_ELEMENT$1> & {
|
|
|
575
575
|
/**
|
|
576
576
|
* Box is a layout container using [CSS Flexbox](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox).
|
|
577
577
|
*/
|
|
578
|
-
declare const Box: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, BoxProps>) => react.ReactElement | null) &
|
|
578
|
+
declare const Box: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, BoxProps>) => react.ReactElement | null) & {
|
|
579
|
+
[x: string]: unknown;
|
|
580
|
+
};
|
|
579
581
|
|
|
580
582
|
type BreadcrumbsProps = ComponentPropsWithoutRef<'div'> & {
|
|
581
583
|
/**
|
|
@@ -990,7 +992,9 @@ type HeadingProps = ComponentPropsWithoutRef<typeof DEFAULT_ELEMENT> & {
|
|
|
990
992
|
/**
|
|
991
993
|
* Displaying heading text, both visually and semantically
|
|
992
994
|
*/
|
|
993
|
-
declare const Heading: (<C extends ElementType = "h1">(props: PolymorphicComponentProps<C, HeadingProps>) => react.ReactElement | null) &
|
|
995
|
+
declare const Heading: (<C extends ElementType = "h1">(props: PolymorphicComponentProps<C, HeadingProps>) => react.ReactElement | null) & {
|
|
996
|
+
[x: string]: unknown;
|
|
997
|
+
};
|
|
994
998
|
|
|
995
999
|
declare const iconMap: {
|
|
996
1000
|
'ab-test': (props: react.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
|
|
@@ -1584,7 +1588,9 @@ type TextProps = ComponentPropsWithoutRef<'div'> & {
|
|
|
1584
1588
|
/**
|
|
1585
1589
|
* Used for rending paragraphs and inline text.
|
|
1586
1590
|
*/
|
|
1587
|
-
declare const Text: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, TextProps>) => react.ReactElement | null) &
|
|
1591
|
+
declare const Text: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, TextProps>) => react.ReactElement | null) & {
|
|
1592
|
+
[x: string]: unknown;
|
|
1593
|
+
};
|
|
1588
1594
|
|
|
1589
1595
|
type MenuItemLabelProps = {
|
|
1590
1596
|
/**
|
|
@@ -1958,7 +1964,9 @@ type StackProps = {
|
|
|
1958
1964
|
* Used to layout its children in a vertical or horizontal stack. The gap between each item in the stack can be customized.
|
|
1959
1965
|
* This allows for layouting children in a consistent way without needing to manually add margins or padding.
|
|
1960
1966
|
*/
|
|
1961
|
-
declare const Stack: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, StackProps>) => react.ReactElement | null) &
|
|
1967
|
+
declare const Stack: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, StackProps>) => react.ReactElement | null) & {
|
|
1968
|
+
[x: string]: unknown;
|
|
1969
|
+
};
|
|
1962
1970
|
|
|
1963
1971
|
type TagProps = ComponentPropsWithoutRef<'div'> & {
|
|
1964
1972
|
/**
|
|
@@ -2230,59 +2238,4 @@ type DataCardTrendProps = {
|
|
|
2230
2238
|
};
|
|
2231
2239
|
declare const DataCardTrend: ({ direction, outlook, children, ...props }: DataCardTrendProps) => JSX.Element;
|
|
2232
2240
|
|
|
2233
|
-
type
|
|
2234
|
-
/**
|
|
2235
|
-
* The initial text content of the heading.
|
|
2236
|
-
* This will be displayed and used as the starting value when editing begins.
|
|
2237
|
-
*/
|
|
2238
|
-
children: string;
|
|
2239
|
-
/**
|
|
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.
|
|
2241
|
-
* @param value The new text content after editing
|
|
2242
|
-
*/
|
|
2243
|
-
onValueChange?: (value: string) => void;
|
|
2244
|
-
/**
|
|
2245
|
-
* Callback fired when the editing state changes.
|
|
2246
|
-
* @param isEditing True when entering edit mode, false when exiting
|
|
2247
|
-
*/
|
|
2248
|
-
onEditingChange?: (isEditing: boolean) => void;
|
|
2249
|
-
/**
|
|
2250
|
-
* Custom tooltip text shown when hovering over the heading.
|
|
2251
|
-
*/
|
|
2252
|
-
tooltipText?: string;
|
|
2253
|
-
/**
|
|
2254
|
-
* Sets an aria-label for the input and label for the screen reader only button.
|
|
2255
|
-
*/
|
|
2256
|
-
ariaLabel?: string;
|
|
2257
|
-
/**
|
|
2258
|
-
* Force editing state for testing purposes
|
|
2259
|
-
*
|
|
2260
|
-
*/
|
|
2261
|
-
forceEditing?: boolean;
|
|
2262
|
-
/**
|
|
2263
|
-
* When true, prevents the heading from entering edit mode
|
|
2264
|
-
* @default false
|
|
2265
|
-
*/
|
|
2266
|
-
editingDisabled?: boolean;
|
|
2267
|
-
/**
|
|
2268
|
-
* Additional props for the heading element
|
|
2269
|
-
*/
|
|
2270
|
-
headingProps?: HeadingProps;
|
|
2271
|
-
/**
|
|
2272
|
-
* Additional props for the textarea element
|
|
2273
|
-
*/
|
|
2274
|
-
inputProps?: InputProps;
|
|
2275
|
-
/**
|
|
2276
|
-
* Optional data-testid attribute for testing purposes
|
|
2277
|
-
*/
|
|
2278
|
-
'data-testid'?: string;
|
|
2279
|
-
};
|
|
2280
|
-
/**
|
|
2281
|
-
* A special heading component that allows for inline editing. When clicked or activated via keyboard,
|
|
2282
|
-
* it transforms into an editable text field. In its default state, it renders as a heading with
|
|
2283
|
-
* an accessible button that enables editing mode. The component handles empty values, keyboard
|
|
2284
|
-
* navigation (Enter to save, Escape to cancel), and provides callbacks for value and state changes.
|
|
2285
|
-
*/
|
|
2286
|
-
declare const EditableHeading: ({ children, onValueChange, onEditingChange, tooltipText, ariaLabel, forceEditing, editingDisabled, inputProps, headingProps, "data-testid": dataTestId, }: EditableHeadingProps) => JSX.Element;
|
|
2287
|
-
|
|
2288
|
-
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 };
|
|
2241
|
+
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, 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.2
|
|
3
|
+
* @license @wistia/ui v0.5.2
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -9709,152 +9709,6 @@ var DataCardTrend = ({
|
|
|
9709
9709
|
)
|
|
9710
9710
|
] });
|
|
9711
9711
|
};
|
|
9712
|
-
|
|
9713
|
-
// src/components/EditableHeading/EditableHeading.tsx
|
|
9714
|
-
import styled50, { css as css25 } from "styled-components";
|
|
9715
|
-
import { useState as useState8, useRef as useRef8 } from "react";
|
|
9716
|
-
import { Fragment as Fragment5, jsx as jsx213, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
9717
|
-
var StyledInput = styled50(Input)`
|
|
9718
|
-
:not([rows]) {
|
|
9719
|
-
min-height: unset;
|
|
9720
|
-
}
|
|
9721
|
-
|
|
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
|
-
|
|
9730
|
-
&& {
|
|
9731
|
-
width: 100%;
|
|
9732
|
-
padding: var(--wui-space-02);
|
|
9733
|
-
border: none;
|
|
9734
|
-
height: ${({ $height }) => `${$height}px`};
|
|
9735
|
-
}
|
|
9736
|
-
`;
|
|
9737
|
-
var editableStyles = css25`
|
|
9738
|
-
&:has(+ :focus-within) {
|
|
9739
|
-
background: var(--wui-color-bg-surface-hover);
|
|
9740
|
-
}
|
|
9741
|
-
|
|
9742
|
-
&:hover {
|
|
9743
|
-
background: var(--wui-color-bg-surface-hover);
|
|
9744
|
-
cursor: pointer;
|
|
9745
|
-
}
|
|
9746
|
-
`;
|
|
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;
|
|
9752
|
-
transition: all var(--wui-motion-duration-01) var(--wui-motion-ease);
|
|
9753
|
-
${({ $editingDisabled }) => !$editingDisabled && editableStyles}
|
|
9754
|
-
`;
|
|
9755
|
-
var EditableHeading = ({
|
|
9756
|
-
children,
|
|
9757
|
-
onValueChange,
|
|
9758
|
-
onEditingChange,
|
|
9759
|
-
tooltipText = "Click to edit title",
|
|
9760
|
-
ariaLabel = "Edit title",
|
|
9761
|
-
forceEditing = false,
|
|
9762
|
-
editingDisabled = false,
|
|
9763
|
-
inputProps,
|
|
9764
|
-
headingProps,
|
|
9765
|
-
"data-testid": dataTestId
|
|
9766
|
-
}) => {
|
|
9767
|
-
const [isEditing, setIsEditing] = useState8(false);
|
|
9768
|
-
const [value, setValue] = useState8(children);
|
|
9769
|
-
const [previousValue, setPreviousValue] = useState8(children);
|
|
9770
|
-
const [headingHeight, setHeadingHeight] = useState8("60");
|
|
9771
|
-
const headingRef = useRef8(null);
|
|
9772
|
-
const handleSetEditing = (editing) => {
|
|
9773
|
-
if (editingDisabled) return;
|
|
9774
|
-
if (editing && headingRef.current) {
|
|
9775
|
-
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9776
|
-
}
|
|
9777
|
-
if (editing) {
|
|
9778
|
-
setPreviousValue(value);
|
|
9779
|
-
}
|
|
9780
|
-
setIsEditing(editing);
|
|
9781
|
-
onEditingChange?.(editing);
|
|
9782
|
-
};
|
|
9783
|
-
const handleFinishEditing = () => {
|
|
9784
|
-
const trimmedValue = value.trim();
|
|
9785
|
-
if (trimmedValue === "") {
|
|
9786
|
-
setValue(previousValue);
|
|
9787
|
-
} else if (trimmedValue !== previousValue && onValueChange) {
|
|
9788
|
-
onValueChange(trimmedValue);
|
|
9789
|
-
} else {
|
|
9790
|
-
setValue(trimmedValue);
|
|
9791
|
-
}
|
|
9792
|
-
handleSetEditing(false);
|
|
9793
|
-
};
|
|
9794
|
-
const handleKeyDown = (event) => {
|
|
9795
|
-
if (event.key === "Enter" && !event.shiftKey) {
|
|
9796
|
-
event.preventDefault();
|
|
9797
|
-
handleFinishEditing();
|
|
9798
|
-
}
|
|
9799
|
-
if (event.key === "Escape") {
|
|
9800
|
-
setValue(previousValue);
|
|
9801
|
-
handleSetEditing(false);
|
|
9802
|
-
}
|
|
9803
|
-
};
|
|
9804
|
-
const HeadingComponent2 = /* @__PURE__ */ jsx213(
|
|
9805
|
-
StyledHeading2,
|
|
9806
|
-
{
|
|
9807
|
-
...headingProps,
|
|
9808
|
-
ref: headingRef,
|
|
9809
|
-
$editingDisabled: editingDisabled,
|
|
9810
|
-
"data-testid": `${dataTestId} ${dataTestId}-heading`,
|
|
9811
|
-
onClick: () => handleSetEditing(true),
|
|
9812
|
-
variant: "heading1",
|
|
9813
|
-
children: value
|
|
9814
|
-
}
|
|
9815
|
-
);
|
|
9816
|
-
if (editingDisabled) {
|
|
9817
|
-
return HeadingComponent2;
|
|
9818
|
-
}
|
|
9819
|
-
if (isEditing || forceEditing) {
|
|
9820
|
-
return /* @__PURE__ */ jsx213(
|
|
9821
|
-
StyledInput,
|
|
9822
|
-
{
|
|
9823
|
-
...inputProps,
|
|
9824
|
-
$height: headingHeight,
|
|
9825
|
-
autoFocus: true,
|
|
9826
|
-
fullWidth: true,
|
|
9827
|
-
onBlur: handleFinishEditing,
|
|
9828
|
-
onChange: (event) => setValue(event.target.value),
|
|
9829
|
-
onFocus: (event) => {
|
|
9830
|
-
const { length } = event.currentTarget.value;
|
|
9831
|
-
event.currentTarget.setSelectionRange(length, length);
|
|
9832
|
-
},
|
|
9833
|
-
onKeyDown: handleKeyDown,
|
|
9834
|
-
type: "multiline",
|
|
9835
|
-
value
|
|
9836
|
-
}
|
|
9837
|
-
);
|
|
9838
|
-
}
|
|
9839
|
-
return /* @__PURE__ */ jsxs33(Fragment5, { children: [
|
|
9840
|
-
/* @__PURE__ */ jsx213(
|
|
9841
|
-
Tooltip,
|
|
9842
|
-
{
|
|
9843
|
-
compact: true,
|
|
9844
|
-
content: tooltipText,
|
|
9845
|
-
children: HeadingComponent2
|
|
9846
|
-
}
|
|
9847
|
-
),
|
|
9848
|
-
/* @__PURE__ */ jsx213(ScreenReaderOnly, { children: /* @__PURE__ */ jsx213(
|
|
9849
|
-
"button",
|
|
9850
|
-
{
|
|
9851
|
-
"aria-label": ariaLabel,
|
|
9852
|
-
onClick: () => handleSetEditing(true),
|
|
9853
|
-
type: "button"
|
|
9854
|
-
}
|
|
9855
|
-
) })
|
|
9856
|
-
] });
|
|
9857
|
-
};
|
|
9858
9712
|
export {
|
|
9859
9713
|
ActionButton,
|
|
9860
9714
|
Avatar,
|
|
@@ -9873,7 +9727,6 @@ export {
|
|
|
9873
9727
|
DataCardTrend,
|
|
9874
9728
|
DataCards,
|
|
9875
9729
|
Divider,
|
|
9876
|
-
EditableHeading,
|
|
9877
9730
|
Ellipsis,
|
|
9878
9731
|
Form,
|
|
9879
9732
|
FormErrorSummary,
|