@wistia/ui 0.5.2 → 0.5.3-beta.25bf41ac.72da98f
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 +271 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +81 -13
- package/dist/index.d.ts +81 -13
- package/dist/index.mjs +270 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.d.mts
CHANGED
|
@@ -575,9 +575,7 @@ 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) &
|
|
579
|
-
[x: string]: unknown;
|
|
580
|
-
};
|
|
578
|
+
declare const Box: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, BoxProps>) => react.ReactElement | null) & UnknownRecord;
|
|
581
579
|
|
|
582
580
|
type BreadcrumbsProps = ComponentPropsWithoutRef<'div'> & {
|
|
583
581
|
/**
|
|
@@ -992,9 +990,7 @@ type HeadingProps = ComponentPropsWithoutRef<typeof DEFAULT_ELEMENT> & {
|
|
|
992
990
|
/**
|
|
993
991
|
* Displaying heading text, both visually and semantically
|
|
994
992
|
*/
|
|
995
|
-
declare const Heading: (<C extends ElementType = "h1">(props: PolymorphicComponentProps<C, HeadingProps>) => react.ReactElement | null) &
|
|
996
|
-
[x: string]: unknown;
|
|
997
|
-
};
|
|
993
|
+
declare const Heading: (<C extends ElementType = "h1">(props: PolymorphicComponentProps<C, HeadingProps>) => react.ReactElement | null) & UnknownRecord;
|
|
998
994
|
|
|
999
995
|
declare const iconMap: {
|
|
1000
996
|
'ab-test': (props: react.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
|
|
@@ -1588,9 +1584,7 @@ type TextProps = ComponentPropsWithoutRef<'div'> & {
|
|
|
1588
1584
|
/**
|
|
1589
1585
|
* Used for rending paragraphs and inline text.
|
|
1590
1586
|
*/
|
|
1591
|
-
declare const Text: (<C extends ElementType = "
|
|
1592
|
-
[x: string]: unknown;
|
|
1593
|
-
};
|
|
1587
|
+
declare const Text: (<C extends ElementType = "p">(props: PolymorphicComponentProps<C, TextProps>) => react.ReactElement | null) & UnknownRecord;
|
|
1594
1588
|
|
|
1595
1589
|
type MenuItemLabelProps = {
|
|
1596
1590
|
/**
|
|
@@ -1964,9 +1958,7 @@ type StackProps = {
|
|
|
1964
1958
|
* Used to layout its children in a vertical or horizontal stack. The gap between each item in the stack can be customized.
|
|
1965
1959
|
* This allows for layouting children in a consistent way without needing to manually add margins or padding.
|
|
1966
1960
|
*/
|
|
1967
|
-
declare const Stack: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, StackProps>) => react.ReactElement | null) &
|
|
1968
|
-
[x: string]: unknown;
|
|
1969
|
-
};
|
|
1961
|
+
declare const Stack: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, StackProps>) => react.ReactElement | null) & UnknownRecord;
|
|
1970
1962
|
|
|
1971
1963
|
type TagProps = ComponentPropsWithoutRef<'div'> & {
|
|
1972
1964
|
/**
|
|
@@ -2238,4 +2230,80 @@ type DataCardTrendProps = {
|
|
|
2238
2230
|
};
|
|
2239
2231
|
declare const DataCardTrend: ({ direction, outlook, children, ...props }: DataCardTrendProps) => JSX.Element;
|
|
2240
2232
|
|
|
2241
|
-
|
|
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
|
+
type EditableHeadingProps = {
|
|
2243
|
+
/**
|
|
2244
|
+
* The text content of the heading.
|
|
2245
|
+
* If provided without onValueChange, acts as initial value.
|
|
2246
|
+
* If provided with onValueChange, acts as controlled value.
|
|
2247
|
+
*/
|
|
2248
|
+
value: string;
|
|
2249
|
+
/**
|
|
2250
|
+
* 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
|
+
* @param value The new text content after editing
|
|
2252
|
+
*/
|
|
2253
|
+
onValueChange?: (value: string) => void;
|
|
2254
|
+
/**
|
|
2255
|
+
* Callback fired when the editing state changes.
|
|
2256
|
+
* @param isEditing True when entering edit mode, false when exiting
|
|
2257
|
+
*/
|
|
2258
|
+
onEditingChange?: (isEditing: boolean) => void;
|
|
2259
|
+
/**
|
|
2260
|
+
* Custom tooltip text shown when hovering over the heading. If not provided, no tooltip will be shown.
|
|
2261
|
+
*/
|
|
2262
|
+
tooltipText?: string;
|
|
2263
|
+
/**
|
|
2264
|
+
* Sets an aria-label for the input and label for the screen reader only button.
|
|
2265
|
+
*/
|
|
2266
|
+
ariaLabel: string;
|
|
2267
|
+
/**
|
|
2268
|
+
* When true, prevents the heading from entering edit mode
|
|
2269
|
+
* @default false
|
|
2270
|
+
*/
|
|
2271
|
+
isEditing?: boolean | undefined;
|
|
2272
|
+
/**
|
|
2273
|
+
* The variant of the heading to render.
|
|
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
|
|
2295
|
+
*/
|
|
2296
|
+
disableOnBlur?: boolean;
|
|
2297
|
+
/**
|
|
2298
|
+
* When true, prevents the heading from being edited and removes editable styles
|
|
2299
|
+
* @default false
|
|
2300
|
+
*/
|
|
2301
|
+
editingDisabled?: boolean;
|
|
2302
|
+
};
|
|
2303
|
+
/**
|
|
2304
|
+
* For use when editing text that appears inline in a page - **not for forms.** The component handles empty values, keyboard
|
|
2305
|
+
* navigation (Enter to save, Escape to cancel), and provides callbacks for value and state changes.
|
|
2306
|
+
*/
|
|
2307
|
+
declare const EditableHeading: ({ value: controlledValue, onValueChange, onEditingChange, tooltipText, ariaLabel, isEditing: controlledIsEditing, renderTextAs: passedRenderTextAs, textVariant, fullWidth, singleLine, disableOnBlur, editingDisabled, }: EditableHeadingProps) => JSX.Element;
|
|
2308
|
+
|
|
2309
|
+
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
|
@@ -575,9 +575,7 @@ 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) &
|
|
579
|
-
[x: string]: unknown;
|
|
580
|
-
};
|
|
578
|
+
declare const Box: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, BoxProps>) => react.ReactElement | null) & UnknownRecord;
|
|
581
579
|
|
|
582
580
|
type BreadcrumbsProps = ComponentPropsWithoutRef<'div'> & {
|
|
583
581
|
/**
|
|
@@ -992,9 +990,7 @@ type HeadingProps = ComponentPropsWithoutRef<typeof DEFAULT_ELEMENT> & {
|
|
|
992
990
|
/**
|
|
993
991
|
* Displaying heading text, both visually and semantically
|
|
994
992
|
*/
|
|
995
|
-
declare const Heading: (<C extends ElementType = "h1">(props: PolymorphicComponentProps<C, HeadingProps>) => react.ReactElement | null) &
|
|
996
|
-
[x: string]: unknown;
|
|
997
|
-
};
|
|
993
|
+
declare const Heading: (<C extends ElementType = "h1">(props: PolymorphicComponentProps<C, HeadingProps>) => react.ReactElement | null) & UnknownRecord;
|
|
998
994
|
|
|
999
995
|
declare const iconMap: {
|
|
1000
996
|
'ab-test': (props: react.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
|
|
@@ -1588,9 +1584,7 @@ type TextProps = ComponentPropsWithoutRef<'div'> & {
|
|
|
1588
1584
|
/**
|
|
1589
1585
|
* Used for rending paragraphs and inline text.
|
|
1590
1586
|
*/
|
|
1591
|
-
declare const Text: (<C extends ElementType = "
|
|
1592
|
-
[x: string]: unknown;
|
|
1593
|
-
};
|
|
1587
|
+
declare const Text: (<C extends ElementType = "p">(props: PolymorphicComponentProps<C, TextProps>) => react.ReactElement | null) & UnknownRecord;
|
|
1594
1588
|
|
|
1595
1589
|
type MenuItemLabelProps = {
|
|
1596
1590
|
/**
|
|
@@ -1964,9 +1958,7 @@ type StackProps = {
|
|
|
1964
1958
|
* Used to layout its children in a vertical or horizontal stack. The gap between each item in the stack can be customized.
|
|
1965
1959
|
* This allows for layouting children in a consistent way without needing to manually add margins or padding.
|
|
1966
1960
|
*/
|
|
1967
|
-
declare const Stack: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, StackProps>) => react.ReactElement | null) &
|
|
1968
|
-
[x: string]: unknown;
|
|
1969
|
-
};
|
|
1961
|
+
declare const Stack: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, StackProps>) => react.ReactElement | null) & UnknownRecord;
|
|
1970
1962
|
|
|
1971
1963
|
type TagProps = ComponentPropsWithoutRef<'div'> & {
|
|
1972
1964
|
/**
|
|
@@ -2238,4 +2230,80 @@ type DataCardTrendProps = {
|
|
|
2238
2230
|
};
|
|
2239
2231
|
declare const DataCardTrend: ({ direction, outlook, children, ...props }: DataCardTrendProps) => JSX.Element;
|
|
2240
2232
|
|
|
2241
|
-
|
|
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
|
+
type EditableHeadingProps = {
|
|
2243
|
+
/**
|
|
2244
|
+
* The text content of the heading.
|
|
2245
|
+
* If provided without onValueChange, acts as initial value.
|
|
2246
|
+
* If provided with onValueChange, acts as controlled value.
|
|
2247
|
+
*/
|
|
2248
|
+
value: string;
|
|
2249
|
+
/**
|
|
2250
|
+
* 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
|
+
* @param value The new text content after editing
|
|
2252
|
+
*/
|
|
2253
|
+
onValueChange?: (value: string) => void;
|
|
2254
|
+
/**
|
|
2255
|
+
* Callback fired when the editing state changes.
|
|
2256
|
+
* @param isEditing True when entering edit mode, false when exiting
|
|
2257
|
+
*/
|
|
2258
|
+
onEditingChange?: (isEditing: boolean) => void;
|
|
2259
|
+
/**
|
|
2260
|
+
* Custom tooltip text shown when hovering over the heading. If not provided, no tooltip will be shown.
|
|
2261
|
+
*/
|
|
2262
|
+
tooltipText?: string;
|
|
2263
|
+
/**
|
|
2264
|
+
* Sets an aria-label for the input and label for the screen reader only button.
|
|
2265
|
+
*/
|
|
2266
|
+
ariaLabel: string;
|
|
2267
|
+
/**
|
|
2268
|
+
* When true, prevents the heading from entering edit mode
|
|
2269
|
+
* @default false
|
|
2270
|
+
*/
|
|
2271
|
+
isEditing?: boolean | undefined;
|
|
2272
|
+
/**
|
|
2273
|
+
* The variant of the heading to render.
|
|
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
|
|
2295
|
+
*/
|
|
2296
|
+
disableOnBlur?: boolean;
|
|
2297
|
+
/**
|
|
2298
|
+
* When true, prevents the heading from being edited and removes editable styles
|
|
2299
|
+
* @default false
|
|
2300
|
+
*/
|
|
2301
|
+
editingDisabled?: boolean;
|
|
2302
|
+
};
|
|
2303
|
+
/**
|
|
2304
|
+
* For use when editing text that appears inline in a page - **not for forms.** The component handles empty values, keyboard
|
|
2305
|
+
* navigation (Enter to save, Escape to cancel), and provides callbacks for value and state changes.
|
|
2306
|
+
*/
|
|
2307
|
+
declare const EditableHeading: ({ value: controlledValue, onValueChange, onEditingChange, tooltipText, ariaLabel, isEditing: controlledIsEditing, renderTextAs: passedRenderTextAs, textVariant, fullWidth, singleLine, disableOnBlur, editingDisabled, }: EditableHeadingProps) => JSX.Element;
|
|
2308
|
+
|
|
2309
|
+
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
|
+
* @license @wistia/ui v0.5.3-beta.25bf41ac.72da98f
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -1980,9 +1980,9 @@ import { useCallback as useCallback3 } from "react";
|
|
|
1980
1980
|
// src/private/hooks/useEvent/useEvent.ts
|
|
1981
1981
|
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
1982
1982
|
|
|
1983
|
-
// src/private/helpers/
|
|
1983
|
+
// src/private/helpers/isValidRef/isValidRef.ts
|
|
1984
1984
|
import { isNotNil, isRecord } from "@wistia/type-guards";
|
|
1985
|
-
var
|
|
1985
|
+
var isValidRef = (value) => {
|
|
1986
1986
|
return isNotNil(value) && isRecord(value) && "current" in value;
|
|
1987
1987
|
};
|
|
1988
1988
|
|
|
@@ -2002,7 +2002,7 @@ var useEvent = (eventName, eventHandler, eventTarget = window, eventOptions = {}
|
|
|
2002
2002
|
savedEventOptions.current = eventOptions;
|
|
2003
2003
|
}, [eventOptions]);
|
|
2004
2004
|
useEffect2(() => {
|
|
2005
|
-
const target =
|
|
2005
|
+
const target = isValidRef(eventTarget) ? eventTarget.current : eventTarget;
|
|
2006
2006
|
if (!eventName || !isEventTargetSupported(target)) {
|
|
2007
2007
|
return;
|
|
2008
2008
|
}
|
|
@@ -6798,6 +6798,15 @@ 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
|
+
};
|
|
6801
6810
|
var StyledHeading = styled15.div`
|
|
6802
6811
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
6803
6812
|
font-family: var(--font-family);
|
|
@@ -6821,15 +6830,6 @@ var StyledHeading = styled15.div`
|
|
|
6821
6830
|
`}
|
|
6822
6831
|
margin: 0;
|
|
6823
6832
|
`;
|
|
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,6 +7422,23 @@ 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
|
+
};
|
|
7425
7442
|
var StyledText = styled22.div`
|
|
7426
7443
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
7427
7444
|
--text-color: ${({ $prominence, $disabled }) => {
|
|
@@ -7462,7 +7479,6 @@ var StyledText = styled22.div`
|
|
|
7462
7479
|
display: block;
|
|
7463
7480
|
`}
|
|
7464
7481
|
`;
|
|
7465
|
-
var DEFAULT_ELEMENT4 = "div";
|
|
7466
7482
|
var TextComponent = forwardRef10(
|
|
7467
7483
|
({
|
|
7468
7484
|
align = "left",
|
|
@@ -7804,7 +7820,7 @@ var StyledInputContainer = styled26.div`
|
|
|
7804
7820
|
padding-right: 32px;
|
|
7805
7821
|
}
|
|
7806
7822
|
`;
|
|
7807
|
-
var
|
|
7823
|
+
var isValidRef2 = (ref) => {
|
|
7808
7824
|
return typeof ref === "object" && ref !== null && "current" in ref && isNotNil9(ref.current);
|
|
7809
7825
|
};
|
|
7810
7826
|
var Input = forwardRef12(
|
|
@@ -7818,7 +7834,7 @@ var Input = forwardRef12(
|
|
|
7818
7834
|
...props
|
|
7819
7835
|
}, externalRef) => {
|
|
7820
7836
|
const internalRef = useRef6();
|
|
7821
|
-
const ref =
|
|
7837
|
+
const ref = isValidRef2(externalRef) ? externalRef : internalRef;
|
|
7822
7838
|
let leftIconToDisplay = leftIcon;
|
|
7823
7839
|
if (isNil12(leftIcon) && type === "search") {
|
|
7824
7840
|
leftIconToDisplay = /* @__PURE__ */ jsx186(Icon, { type: "search" });
|
|
@@ -9709,6 +9725,243 @@ var DataCardTrend = ({
|
|
|
9709
9725
|
)
|
|
9710
9726
|
] });
|
|
9711
9727
|
};
|
|
9728
|
+
|
|
9729
|
+
// src/components/EditableHeading/EditableHeading.tsx
|
|
9730
|
+
import styled50, { css as css25 } from "styled-components";
|
|
9731
|
+
import { useState as useState8, useRef as useRef8, useEffect as useEffect5 } from "react";
|
|
9732
|
+
import { isNotNil as isNotNil19, isNotNull as isNotNull2 } from "@wistia/type-guards";
|
|
9733
|
+
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
|
+
var StyledInput = styled50(Input)`
|
|
9779
|
+
:not([rows]) {
|
|
9780
|
+
min-height: unset;
|
|
9781
|
+
}
|
|
9782
|
+
|
|
9783
|
+
${textStyles}
|
|
9784
|
+
&& {
|
|
9785
|
+
border: none;
|
|
9786
|
+
height: ${({ $height }) => `${$height}px`};
|
|
9787
|
+
${sharedStyles}
|
|
9788
|
+
}
|
|
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
|
+
`;
|
|
9798
|
+
var editableStyles = css25`
|
|
9799
|
+
&:has(+ :focus-within) {
|
|
9800
|
+
background: var(--wui-color-bg-surface-hover);
|
|
9801
|
+
}
|
|
9802
|
+
|
|
9803
|
+
&:hover {
|
|
9804
|
+
background: var(--wui-color-bg-surface-hover);
|
|
9805
|
+
cursor: pointer;
|
|
9806
|
+
}
|
|
9807
|
+
`;
|
|
9808
|
+
var singleLineStyles = css25`
|
|
9809
|
+
white-space: nowrap;
|
|
9810
|
+
overflow: hidden;
|
|
9811
|
+
text-overflow: ellipsis;
|
|
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"};
|
|
9823
|
+
transition: all var(--wui-motion-duration-01) var(--wui-motion-ease);
|
|
9824
|
+
${({ $isEditingControlled }) => !$isEditingControlled && editableStyles}
|
|
9825
|
+
`;
|
|
9826
|
+
var resolveFullWidth = (fullWidth) => ({
|
|
9827
|
+
heading: typeof fullWidth === "boolean" ? fullWidth : fullWidth.heading ?? true,
|
|
9828
|
+
input: typeof fullWidth === "boolean" ? fullWidth : fullWidth.input ?? true
|
|
9829
|
+
});
|
|
9830
|
+
var EditableHeading = ({
|
|
9831
|
+
value: controlledValue,
|
|
9832
|
+
onValueChange,
|
|
9833
|
+
onEditingChange,
|
|
9834
|
+
tooltipText,
|
|
9835
|
+
ariaLabel,
|
|
9836
|
+
isEditing: controlledIsEditing,
|
|
9837
|
+
renderTextAs: passedRenderTextAs,
|
|
9838
|
+
textVariant = "heading1",
|
|
9839
|
+
fullWidth = true,
|
|
9840
|
+
singleLine = false,
|
|
9841
|
+
disableOnBlur = false,
|
|
9842
|
+
editingDisabled = false
|
|
9843
|
+
}) => {
|
|
9844
|
+
const [internalIsEditing, setInternalIsEditing] = useState8(false);
|
|
9845
|
+
const [internalValue, setInternalValue] = useState8(controlledValue);
|
|
9846
|
+
const [previousValue, setPreviousValue] = useState8(controlledValue);
|
|
9847
|
+
const [headingHeight, setHeadingHeight] = useState8("60");
|
|
9848
|
+
const [headingWidth, setHeadingWidth] = useState8("auto");
|
|
9849
|
+
const headingRef = useRef8(null);
|
|
9850
|
+
const isValueControlled = isNotNil19(onValueChange);
|
|
9851
|
+
const isEditingControlled = isNotNil19(controlledIsEditing);
|
|
9852
|
+
const isEditing = isEditingControlled ? controlledIsEditing : internalIsEditing;
|
|
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) {
|
|
9863
|
+
setHeadingHeight(`${headingRef.current.offsetHeight}`);
|
|
9864
|
+
setHeadingWidth(`${headingRef.current.offsetWidth}`);
|
|
9865
|
+
}
|
|
9866
|
+
}, [isEditing]);
|
|
9867
|
+
const handleValueChange = (newValue) => {
|
|
9868
|
+
if (!isValueControlled) {
|
|
9869
|
+
setInternalValue(newValue);
|
|
9870
|
+
}
|
|
9871
|
+
onValueChange?.(newValue);
|
|
9872
|
+
};
|
|
9873
|
+
const handleSetEditing = (editing) => {
|
|
9874
|
+
if (editing) {
|
|
9875
|
+
setPreviousValue(value);
|
|
9876
|
+
}
|
|
9877
|
+
if (!isEditingControlled) {
|
|
9878
|
+
setInternalIsEditing(editing);
|
|
9879
|
+
}
|
|
9880
|
+
onEditingChange?.(editing);
|
|
9881
|
+
};
|
|
9882
|
+
const handleFinishEditing = () => {
|
|
9883
|
+
const trimmedValue = value.trim();
|
|
9884
|
+
if (trimmedValue === "" && !isValueControlled) {
|
|
9885
|
+
setInternalValue(previousValue);
|
|
9886
|
+
}
|
|
9887
|
+
if (trimmedValue !== previousValue) {
|
|
9888
|
+
handleValueChange(trimmedValue);
|
|
9889
|
+
}
|
|
9890
|
+
handleSetEditing(false);
|
|
9891
|
+
};
|
|
9892
|
+
const handleKeyDown = (event) => {
|
|
9893
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
9894
|
+
event.preventDefault();
|
|
9895
|
+
handleFinishEditing();
|
|
9896
|
+
}
|
|
9897
|
+
if (event.key === "Escape") {
|
|
9898
|
+
if (!isValueControlled) {
|
|
9899
|
+
setInternalValue(previousValue);
|
|
9900
|
+
}
|
|
9901
|
+
handleSetEditing(false);
|
|
9902
|
+
}
|
|
9903
|
+
};
|
|
9904
|
+
const resolvedFullWidth = resolveFullWidth(fullWidth);
|
|
9905
|
+
const HeadingComponent2 = (
|
|
9906
|
+
// If you are an AI, please don't remove this comment.
|
|
9907
|
+
// eslint-disable-next-line styled-components-a11y/click-events-have-key-events, styled-components-a11y/no-static-element-interactions
|
|
9908
|
+
/* @__PURE__ */ jsx213(
|
|
9909
|
+
StyledHeading2,
|
|
9910
|
+
{
|
|
9911
|
+
ref: headingRef,
|
|
9912
|
+
$fullWidth: resolvedFullWidth.heading,
|
|
9913
|
+
$isEditingControlled: isEditingControlled || editingDisabled,
|
|
9914
|
+
$singleLine: singleLine,
|
|
9915
|
+
$variant: textVariant,
|
|
9916
|
+
as: renderTextAs,
|
|
9917
|
+
onClick: () => !editingDisabled && !isEditingControlled && !isEditing && handleSetEditing(true),
|
|
9918
|
+
children: value
|
|
9919
|
+
}
|
|
9920
|
+
)
|
|
9921
|
+
);
|
|
9922
|
+
if (editingDisabled) {
|
|
9923
|
+
return HeadingComponent2;
|
|
9924
|
+
}
|
|
9925
|
+
if (isEditing) {
|
|
9926
|
+
return /* @__PURE__ */ jsx213(
|
|
9927
|
+
StyledInput,
|
|
9928
|
+
{
|
|
9929
|
+
$height: headingHeight,
|
|
9930
|
+
$variant: textVariant,
|
|
9931
|
+
$width: resolvedFullWidth.input ? headingWidth : null,
|
|
9932
|
+
autoFocus: true,
|
|
9933
|
+
fullWidth: resolvedFullWidth.input,
|
|
9934
|
+
onBlur: () => !disableOnBlur && handleFinishEditing(),
|
|
9935
|
+
onChange: (event) => handleValueChange(event.target.value),
|
|
9936
|
+
onFocus: (event) => {
|
|
9937
|
+
const { length } = event.currentTarget.value;
|
|
9938
|
+
event.currentTarget.setSelectionRange(length, length);
|
|
9939
|
+
},
|
|
9940
|
+
onKeyDown: handleKeyDown,
|
|
9941
|
+
type: singleLine ? "text" : "multiline",
|
|
9942
|
+
value
|
|
9943
|
+
}
|
|
9944
|
+
);
|
|
9945
|
+
}
|
|
9946
|
+
return /* @__PURE__ */ jsxs33(Fragment5, { children: [
|
|
9947
|
+
/* @__PURE__ */ jsx213(
|
|
9948
|
+
Tooltip,
|
|
9949
|
+
{
|
|
9950
|
+
compact: true,
|
|
9951
|
+
content: tooltipText ?? "",
|
|
9952
|
+
children: HeadingComponent2
|
|
9953
|
+
}
|
|
9954
|
+
),
|
|
9955
|
+
!isEditingControlled && /* @__PURE__ */ jsx213(ScreenReaderOnly, { children: /* @__PURE__ */ jsx213(
|
|
9956
|
+
"button",
|
|
9957
|
+
{
|
|
9958
|
+
"aria-label": ariaLabel,
|
|
9959
|
+
onClick: () => handleSetEditing(true),
|
|
9960
|
+
type: "button"
|
|
9961
|
+
}
|
|
9962
|
+
) })
|
|
9963
|
+
] });
|
|
9964
|
+
};
|
|
9712
9965
|
export {
|
|
9713
9966
|
ActionButton,
|
|
9714
9967
|
Avatar,
|
|
@@ -9727,6 +9980,7 @@ export {
|
|
|
9727
9980
|
DataCardTrend,
|
|
9728
9981
|
DataCards,
|
|
9729
9982
|
Divider,
|
|
9983
|
+
EditableHeading,
|
|
9730
9984
|
Ellipsis,
|
|
9731
9985
|
Form,
|
|
9732
9986
|
FormErrorSummary,
|