@pushwoosh/dumb-components 4.4.0 → 4.5.0
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/PageHeader/components/AutosizeInput/styles.js +1 -1
- package/PageHeader/components/PageHeader/styles.js +2 -2
- package/PageHeader/components/PageHeaderEditable/PageHeaderEditable.d.ts +2 -5
- package/PageHeader/components/PageHeaderEditable/PageHeaderEditable.js +23 -72
- package/PageHeader/components/PageHeaderEditable/styles.d.ts +26 -26
- package/PageHeader/components/PageHeaderEditable/styles.js +6 -30
- package/PageHeader/components/Rename/Rename.d.ts +4 -0
- package/PageHeader/components/Rename/Rename.js +73 -0
- package/PageHeader/components/Rename/index.d.ts +1 -0
- package/PageHeader/components/Rename/index.js +1 -0
- package/PageHeader/components/Rename/styles.d.ts +48 -0
- package/PageHeader/components/Rename/styles.js +31 -0
- package/PageHeader/components/Rename/types.d.ts +11 -0
- package/PageHeader/components/Rename/types.js +1 -0
- package/PageHeader/constants.d.ts +1 -0
- package/PageHeader/constants.js +2 -1
- package/PageHeader/index.d.ts +1 -0
- package/PageHeader/index.js +2 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/shared/dropdownField/useAsyncItems.js +51 -23
|
@@ -17,4 +17,4 @@ export const InputStyled = styled.input.withConfig({
|
|
|
17
17
|
export const RootBox = styled.div.withConfig({
|
|
18
18
|
displayName: "RootBox",
|
|
19
19
|
componentId: "sc-191i2ot-3"
|
|
20
|
-
})(["display:flex;align-items:center;overflow:hidden;flex-grow:1;& > ", " > span{position:absolute;visibility:hidden;}&:focus-within{", " > div{display:none;}", " > span{display:block;white-space:nowrap;}", "{color:", ";}}"], InputBox, PromptBox, PromptBox, InputStyled, Color.MAIN);
|
|
20
|
+
})(["display:flex;align-items:center;overflow:hidden;flex-grow:1;& > ", " > span{position:absolute;visibility:hidden;white-space:pre;}&:focus-within{", " > div{display:none;}", " > span{display:block;white-space:nowrap;}", "{color:", ";}}"], InputBox, PromptBox, PromptBox, InputStyled, Color.MAIN);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { FontSize, LineHeight, UnitSize } from '@pushwoosh/kit-constants';
|
|
3
3
|
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
4
|
-
import { PAGE_HEADER_INSET_ATTRIBUTE, STEP_CELL_INSET } from '../../constants';
|
|
4
|
+
import { PAGE_HEADER_INSET_ATTRIBUTE, PAGE_HEADER_RENAME_ATTRIBUTE, STEP_CELL_INSET } from '../../constants';
|
|
5
5
|
export const RootBox = styled.div.withConfig({
|
|
6
6
|
displayName: "RootBox",
|
|
7
7
|
componentId: "sc-1qwo99q-0"
|
|
@@ -22,7 +22,7 @@ export const TitleWithExtraBox = styled(TitleBox).withConfig({
|
|
|
22
22
|
export const TitleWrapBox = styled.div.withConfig({
|
|
23
23
|
displayName: "TitleWrapBox",
|
|
24
24
|
componentId: "sc-1qwo99q-4"
|
|
25
|
-
})(["display:flex;flex-wrap:wrap;align-items:center;column-gap:8px;row-gap:calc(8px - (", " - ", ") / 2);min-width:0;&:has([", "]){--page-header-extra-inset:", "px;}"], UnitSize.FIELD_HEIGHT, TITLE_LINE_HEIGHT, PAGE_HEADER_INSET_ATTRIBUTE, STEP_CELL_INSET);
|
|
25
|
+
})(["display:flex;flex-wrap:wrap;align-items:center;column-gap:8px;row-gap:calc(8px - (", " - ", ") / 2);min-width:0;&:has([", "]){--page-header-extra-inset:", "px;}&:has([", "]){flex-wrap:nowrap;}"], UnitSize.FIELD_HEIGHT, TITLE_LINE_HEIGHT, PAGE_HEADER_INSET_ATTRIBUTE, STEP_CELL_INSET, PAGE_HEADER_RENAME_ATTRIBUTE);
|
|
26
26
|
export const TitleExtraBox = styled.div.withConfig({
|
|
27
27
|
displayName: "TitleExtraBox",
|
|
28
28
|
componentId: "sc-1qwo99q-5"
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { PageHeaderEditableProps } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* {@link PageHeader}
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* <PageHeaderEditable title="Name:" value={name} onChange={setName} onSubmit={save} />
|
|
4
|
+
* {@link PageHeader} with the legacy `AutosizeInput` name next to the title; shows a skeleton while `isLoading`.
|
|
5
|
+
* @deprecated Compose `PageHeader` with `titleExtra={<Rename />}` instead.
|
|
9
6
|
*/
|
|
10
7
|
export declare function PageHeaderEditable(props: PageHeaderEditableProps): ReactElement;
|
|
@@ -1,91 +1,42 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import { ArrowRoundIcon } from '@pushwoosh/kit-icons';
|
|
4
|
-
import { Button } from '../../../Button';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PAGE_HEADER_RENAME_ATTRIBUTE } from '../../constants';
|
|
5
3
|
import { AutosizeInput } from '../AutosizeInput';
|
|
6
|
-
import {
|
|
4
|
+
import { PageHeader } from '../PageHeader';
|
|
7
5
|
import { PageHeaderSkeleton } from '../PageHeaderSkeleton';
|
|
8
|
-
import {
|
|
6
|
+
import { LegacyNameBox } from './styles';
|
|
7
|
+
const LEGACY_NAME_MARK = {
|
|
8
|
+
[PAGE_HEADER_RENAME_ATTRIBUTE]: true
|
|
9
|
+
};
|
|
9
10
|
/**
|
|
10
|
-
* {@link PageHeader}
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* <PageHeaderEditable title="Name:" value={name} onChange={setName} onSubmit={save} />
|
|
11
|
+
* {@link PageHeader} with the legacy `AutosizeInput` name next to the title; shows a skeleton while `isLoading`.
|
|
12
|
+
* @deprecated Compose `PageHeader` with `titleExtra={<Rename />}` instead.
|
|
15
13
|
*/
|
|
16
14
|
export function PageHeaderEditable(props) {
|
|
17
15
|
const {
|
|
18
|
-
title,
|
|
19
|
-
description,
|
|
20
|
-
error,
|
|
21
|
-
resolveErrorText,
|
|
22
16
|
value,
|
|
23
17
|
maxLength,
|
|
24
18
|
placeholder,
|
|
25
|
-
submitText,
|
|
26
|
-
cancelText,
|
|
27
19
|
isLoading,
|
|
28
|
-
isLoadingSubmit,
|
|
29
|
-
moreActions,
|
|
30
|
-
onBack,
|
|
31
20
|
onChange,
|
|
32
21
|
onComplete,
|
|
33
22
|
onSubmit,
|
|
34
|
-
|
|
35
|
-
onResolveError
|
|
23
|
+
...headerProps
|
|
36
24
|
} = props;
|
|
37
25
|
if (isLoading) {
|
|
38
26
|
return _jsx(PageHeaderSkeleton, {});
|
|
39
27
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
direction: "left",
|
|
54
|
-
size: "medium",
|
|
55
|
-
view: "filled"
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
}), _jsxs(AutosizeInputBox, {
|
|
59
|
-
children: [title, value !== undefined && _jsx(AutosizeInput, {
|
|
60
|
-
placeholder: placeholder,
|
|
61
|
-
maxLength: maxLength,
|
|
62
|
-
value: value,
|
|
63
|
-
onChange: onChange,
|
|
64
|
-
onComplete: onComplete
|
|
65
|
-
})]
|
|
66
|
-
})]
|
|
67
|
-
}), hasActionsBox && _jsxs(ActionsBox, {
|
|
68
|
-
children: [!!moreActions && _jsx(MoreActionsBox, {
|
|
69
|
-
"$hasActions": hasActions,
|
|
70
|
-
children: moreActions
|
|
71
|
-
}), onCancel && _jsx(Button, {
|
|
72
|
-
color: "secondary",
|
|
73
|
-
onClick: onCancel,
|
|
74
|
-
children: cancelText || 'Cancel'
|
|
75
|
-
}), onSubmit && _jsx(Button, {
|
|
76
|
-
color: "primary",
|
|
77
|
-
type: "submit",
|
|
78
|
-
onClick: () => value ? onSubmit(value) : null,
|
|
79
|
-
isLoading: !!isLoadingSubmit,
|
|
80
|
-
children: submitText || 'Create'
|
|
81
|
-
})]
|
|
82
|
-
})]
|
|
83
|
-
}), !!error && _jsx(PageHeaderError, {
|
|
84
|
-
error: error,
|
|
85
|
-
resolveErrorText: resolveErrorText,
|
|
86
|
-
onResolveError: onResolveError
|
|
87
|
-
}), !!description && _jsx(DescriptionBox, {
|
|
88
|
-
children: description
|
|
89
|
-
})]
|
|
28
|
+
return _jsx(PageHeader, {
|
|
29
|
+
...headerProps,
|
|
30
|
+
titleExtra: value !== undefined && _jsx(LegacyNameBox, {
|
|
31
|
+
...LEGACY_NAME_MARK,
|
|
32
|
+
children: _jsx(AutosizeInput, {
|
|
33
|
+
value: value,
|
|
34
|
+
maxLength: maxLength,
|
|
35
|
+
placeholder: placeholder,
|
|
36
|
+
onChange: onChange,
|
|
37
|
+
onComplete: onComplete
|
|
38
|
+
})
|
|
39
|
+
}),
|
|
40
|
+
onSubmit: onSubmit && (() => value ? onSubmit(value) : null)
|
|
90
41
|
});
|
|
91
42
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const RootBox: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
1
|
+
export declare const LegacyNameBox: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<Omit<import("styled-components").FastOmit<import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
3
2
|
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}> &
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly children: import("react").ReactNode;
|
|
14
|
-
readonly $textTransform?: import("react").CSSProperties["textTransform"];
|
|
3
|
+
}, {
|
|
4
|
+
$color?: string;
|
|
5
|
+
$textAlign?: import("react").CSSProperties["textAlign"];
|
|
6
|
+
$textTransform?: import("react").CSSProperties["textTransform"];
|
|
7
|
+
$ellipsis?: boolean;
|
|
8
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant;
|
|
9
|
+
}>, "as" | "forwardedAs"> & {
|
|
10
|
+
as?: import("styled-components").WebTarget | undefined;
|
|
11
|
+
forwardedAs?: import("styled-components").WebTarget | undefined;
|
|
15
12
|
}, "style"> & {
|
|
16
|
-
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars |
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}> & string;
|
|
21
|
-
export declare const MoreActionsBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
13
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | (import("react").CSSProperties & {
|
|
14
|
+
[key: `--${string}`]: string | number | undefined;
|
|
15
|
+
}) | undefined;
|
|
16
|
+
}, "children" | "key" | "slot" | "style" | "title" | "ref" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "$color" | "$variant" | "as" | "forwardedAs" | "$textTransform" | "$textAlign" | "$ellipsis"> & Partial<Pick<Omit<import("styled-components").FastOmit<import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
22
17
|
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
23
18
|
}, {
|
|
24
|
-
$
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
$color?: string;
|
|
20
|
+
$textAlign?: import("react").CSSProperties["textAlign"];
|
|
21
|
+
$textTransform?: import("react").CSSProperties["textTransform"];
|
|
22
|
+
$ellipsis?: boolean;
|
|
23
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant;
|
|
24
|
+
}>, "as" | "forwardedAs"> & {
|
|
25
|
+
as?: import("styled-components").WebTarget | undefined;
|
|
26
|
+
forwardedAs?: import("styled-components").WebTarget | undefined;
|
|
29
27
|
}, "style"> & {
|
|
30
|
-
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars |
|
|
31
|
-
}
|
|
28
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | (import("react").CSSProperties & {
|
|
29
|
+
[key: `--${string}`]: string | number | undefined;
|
|
30
|
+
}) | undefined;
|
|
31
|
+
}, "children" | "key" | "slot" | "style" | "title" | "ref" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "$color" | "$variant" | "as" | "forwardedAs" | "$textTransform" | "$textAlign" | "$ellipsis">>> & string;
|
|
@@ -1,32 +1,8 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import {
|
|
3
|
-
export const
|
|
4
|
-
|
|
2
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
3
|
+
export const LegacyNameBox = styled(Text).attrs({
|
|
4
|
+
$variant: 'h1'
|
|
5
|
+
}).withConfig({
|
|
6
|
+
displayName: "LegacyNameBox",
|
|
5
7
|
componentId: "sc-19rm2yr-0"
|
|
6
|
-
})(["display:flex;
|
|
7
|
-
export const BackButton = styled.div.withConfig({
|
|
8
|
-
displayName: "BackButton",
|
|
9
|
-
componentId: "sc-19rm2yr-1"
|
|
10
|
-
})(["min-width:36px;max-width:36px;& button{border:0;padding:0;}"]);
|
|
11
|
-
export const TitleBox = styled.div.withConfig({
|
|
12
|
-
displayName: "TitleBox",
|
|
13
|
-
componentId: "sc-19rm2yr-2"
|
|
14
|
-
})(["display:flex;align-items:center;justify-content:start;flex-shrink:0;gap:8px;"]);
|
|
15
|
-
export const AutosizeInputBox = styled(H1).withConfig({
|
|
16
|
-
displayName: "AutosizeInputBox",
|
|
17
|
-
componentId: "sc-19rm2yr-3"
|
|
18
|
-
})(["display:flex;align-items:center;justify-content:start;overflow:hidden;gap:8px;"]);
|
|
19
|
-
export const ActionsBox = styled.div.withConfig({
|
|
20
|
-
displayName: "ActionsBox",
|
|
21
|
-
componentId: "sc-19rm2yr-4"
|
|
22
|
-
})(["display:flex;justify-content:flex-end;gap:8px;"]);
|
|
23
|
-
export const MoreActionsBox = styled.div.withConfig({
|
|
24
|
-
displayName: "MoreActionsBox",
|
|
25
|
-
componentId: "sc-19rm2yr-5"
|
|
26
|
-
})(["display:flex;margin-right:", ";"], ({
|
|
27
|
-
$hasActions
|
|
28
|
-
}) => $hasActions ? '16px' : '0');
|
|
29
|
-
export const DescriptionBox = styled(Paragraph).withConfig({
|
|
30
|
-
displayName: "DescriptionBox",
|
|
31
|
-
componentId: "sc-19rm2yr-6"
|
|
32
|
-
})(["margin-top:16px;"]);
|
|
8
|
+
})(["display:flex;align-items:center;min-width:0;"]);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { EditIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
import { RenameBox, RenameButton, RenameField, RenameInput, RenameMeasure, RenameText } from './styles';
|
|
5
|
+
import { PAGE_HEADER_RENAME_ATTRIBUTE } from '../../constants';
|
|
6
|
+
const RENAME_MARK = {
|
|
7
|
+
[PAGE_HEADER_RENAME_ATTRIBUTE]: true
|
|
8
|
+
};
|
|
9
|
+
/** Editable name for `PageHeader` `titleExtra`: click to edit in place, Enter or blur commits, Escape reverts. */
|
|
10
|
+
export function Rename(props) {
|
|
11
|
+
const {
|
|
12
|
+
value,
|
|
13
|
+
placeholder,
|
|
14
|
+
maxLength,
|
|
15
|
+
onChange
|
|
16
|
+
} = props;
|
|
17
|
+
const [draft, setDraft] = useState(null);
|
|
18
|
+
const inputRef = useRef(null);
|
|
19
|
+
const isEditing = draft !== null;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (isEditing) {
|
|
22
|
+
inputRef.current?.select();
|
|
23
|
+
}
|
|
24
|
+
}, [isEditing]);
|
|
25
|
+
const commit = () => {
|
|
26
|
+
const name = (draft ?? '').trim();
|
|
27
|
+
if (name && name !== value) {
|
|
28
|
+
onChange(name);
|
|
29
|
+
}
|
|
30
|
+
setDraft(null);
|
|
31
|
+
};
|
|
32
|
+
const onKeyDown = event => {
|
|
33
|
+
if (event.key === 'Enter') {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
inputRef.current?.blur();
|
|
36
|
+
}
|
|
37
|
+
if (event.key === 'Escape') {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
setDraft(value);
|
|
40
|
+
inputRef.current?.blur();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const onInput = event => {
|
|
44
|
+
setDraft(event.currentTarget.value.replace(/\n/g, ''));
|
|
45
|
+
};
|
|
46
|
+
return _jsx(RenameBox, {
|
|
47
|
+
...RENAME_MARK,
|
|
48
|
+
children: isEditing ? _jsxs(RenameField, {
|
|
49
|
+
children: [_jsx(RenameMeasure, {
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
children: draft || placeholder
|
|
52
|
+
}), _jsx(RenameInput, {
|
|
53
|
+
ref: inputRef,
|
|
54
|
+
value: draft,
|
|
55
|
+
placeholder: placeholder,
|
|
56
|
+
maxLength: maxLength,
|
|
57
|
+
onChange: onInput,
|
|
58
|
+
onKeyDown: onKeyDown,
|
|
59
|
+
onBlur: commit
|
|
60
|
+
})]
|
|
61
|
+
}) : _jsxs(RenameButton, {
|
|
62
|
+
type: "button",
|
|
63
|
+
"$isEmpty": !value,
|
|
64
|
+
onClick: () => setDraft(value),
|
|
65
|
+
children: [_jsx(RenameText, {
|
|
66
|
+
children: value || placeholder
|
|
67
|
+
}), _jsx(EditIcon, {
|
|
68
|
+
size: "small",
|
|
69
|
+
view: "filled"
|
|
70
|
+
})]
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Rename } from './Rename';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Rename } from './Rename';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const RenameBox: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<Omit<import("styled-components").FastOmit<import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
2
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
3
|
+
}, {
|
|
4
|
+
$color?: string;
|
|
5
|
+
$textAlign?: import("react").CSSProperties["textAlign"];
|
|
6
|
+
$textTransform?: import("react").CSSProperties["textTransform"];
|
|
7
|
+
$ellipsis?: boolean;
|
|
8
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant;
|
|
9
|
+
}>, "as" | "forwardedAs"> & {
|
|
10
|
+
as?: import("styled-components").WebTarget | undefined;
|
|
11
|
+
forwardedAs?: import("styled-components").WebTarget | undefined;
|
|
12
|
+
}, "style"> & {
|
|
13
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | (import("react").CSSProperties & {
|
|
14
|
+
[key: `--${string}`]: string | number | undefined;
|
|
15
|
+
}) | undefined;
|
|
16
|
+
}, "children" | "key" | "slot" | "style" | "title" | "ref" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "$color" | "$variant" | "as" | "forwardedAs" | "$textTransform" | "$textAlign" | "$ellipsis"> & Partial<Pick<Omit<import("styled-components").FastOmit<import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
17
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
$color?: string;
|
|
20
|
+
$textAlign?: import("react").CSSProperties["textAlign"];
|
|
21
|
+
$textTransform?: import("react").CSSProperties["textTransform"];
|
|
22
|
+
$ellipsis?: boolean;
|
|
23
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant;
|
|
24
|
+
}>, "as" | "forwardedAs"> & {
|
|
25
|
+
as?: import("styled-components").WebTarget | undefined;
|
|
26
|
+
forwardedAs?: import("styled-components").WebTarget | undefined;
|
|
27
|
+
}, "style"> & {
|
|
28
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | (import("react").CSSProperties & {
|
|
29
|
+
[key: `--${string}`]: string | number | undefined;
|
|
30
|
+
}) | undefined;
|
|
31
|
+
}, "children" | "key" | "slot" | "style" | "title" | "ref" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "$color" | "$variant" | "as" | "forwardedAs" | "$textTransform" | "$textAlign" | "$ellipsis">>> & string;
|
|
32
|
+
export declare const RenameButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "style"> & {
|
|
33
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
$isEmpty: boolean;
|
|
36
|
+
}>> & string;
|
|
37
|
+
export declare const RenameText: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
38
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
39
|
+
}> & string;
|
|
40
|
+
export declare const RenameField: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
41
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
42
|
+
}> & string;
|
|
43
|
+
export declare const RenameInput: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "style"> & {
|
|
44
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
45
|
+
}> & string;
|
|
46
|
+
export declare const RenameMeasure: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
47
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
48
|
+
}> & string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
4
|
+
export const RenameBox = styled(Text).attrs({
|
|
5
|
+
$variant: 'h1'
|
|
6
|
+
}).withConfig({
|
|
7
|
+
displayName: "RenameBox",
|
|
8
|
+
componentId: "sc-rgc26r-0"
|
|
9
|
+
})(["display:flex;align-items:center;min-width:0;"]);
|
|
10
|
+
export const RenameButton = styled.button.withConfig({
|
|
11
|
+
displayName: "RenameButton",
|
|
12
|
+
componentId: "sc-rgc26r-1"
|
|
13
|
+
})(["display:flex;align-items:center;gap:4px;min-width:0;margin:0;padding:0;border:0;background:none;font:inherit;color:", ";cursor:text;&:hover{color:", ";}&:focus-visible{outline:1px solid ", ";outline-offset:2px;}"], ({
|
|
14
|
+
$isEmpty
|
|
15
|
+
}) => $isEmpty ? Color.PHANTOM : Color.PRIMARY, Color.PRIMARY_HOVER, Color.BRIGHT);
|
|
16
|
+
export const RenameText = styled.span.withConfig({
|
|
17
|
+
displayName: "RenameText",
|
|
18
|
+
componentId: "sc-rgc26r-2"
|
|
19
|
+
})(["min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-bottom:1px dashed ", ";"], Color.PHANTOM);
|
|
20
|
+
export const RenameField = styled.span.withConfig({
|
|
21
|
+
displayName: "RenameField",
|
|
22
|
+
componentId: "sc-rgc26r-3"
|
|
23
|
+
})(["display:inline-grid;grid-template-columns:minmax(0,max-content);max-width:100%;min-width:0;"]);
|
|
24
|
+
export const RenameInput = styled.input.withConfig({
|
|
25
|
+
displayName: "RenameInput",
|
|
26
|
+
componentId: "sc-rgc26r-4"
|
|
27
|
+
})(["grid-area:1 / 1;width:0;min-width:100%;margin:0;padding:0;border:0;border-bottom:1px dashed ", ";background:none;font:inherit;color:", ";outline:0;&::placeholder{color:", ";}"], Color.PHANTOM, Color.MAIN, Color.PHANTOM);
|
|
28
|
+
export const RenameMeasure = styled.span.withConfig({
|
|
29
|
+
displayName: "RenameMeasure",
|
|
30
|
+
componentId: "sc-rgc26r-5"
|
|
31
|
+
})(["grid-area:1 / 1;min-width:0;overflow:hidden;visibility:hidden;white-space:pre;padding-right:2px;"]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Props of {@link Rename}. */
|
|
2
|
+
export interface RenameProps {
|
|
3
|
+
/** Saved name; the field edits a draft and reports it through `onChange` only when it is committed. */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Shown while the name is empty. */
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
/** Maximum number of characters. */
|
|
8
|
+
maxLength?: number;
|
|
9
|
+
/** Fires with the new name on Enter or when the field loses focus; never with an empty name. */
|
|
10
|
+
onChange: (value: string) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/PageHeader/constants.js
CHANGED
package/PageHeader/index.d.ts
CHANGED
package/PageHeader/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { AutosizeInput } from './components/AutosizeInput';
|
|
2
2
|
export { PageHeader } from './components/PageHeader';
|
|
3
|
-
export { PageHeaderEditable } from './components/PageHeaderEditable';
|
|
3
|
+
export { PageHeaderEditable } from './components/PageHeaderEditable';
|
|
4
|
+
export { Rename } from './components/Rename';
|
package/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export { InboxPreview, resolveInboxLayout, MAX_CAROUSEL_SLIDES, type InboxLayout
|
|
|
38
38
|
export { WhatsAppPreview } from './WhatsAppPreview';
|
|
39
39
|
export type { WhatsAppAttachment, WhatsAppAttachmentKind, WhatsAppMessage, WhatsAppPreviewProps, } from './WhatsAppPreview';
|
|
40
40
|
export { Toast, ToastProvider, useToast } from './Toast';
|
|
41
|
-
export { AutosizeInput, PageHeader, PageHeaderEditable } from './PageHeader';
|
|
41
|
+
export { AutosizeInput, PageHeader, PageHeaderEditable, Rename, } from './PageHeader';
|
|
42
42
|
export { Steps, useSteps } from './Steps';
|
|
43
43
|
export type { StepId, StepItem, StepProgress, StepsProps, UseStepsOptions, UseStepsResult, } from './Steps';
|
|
44
44
|
export { ExportResult } from './ExportResult';
|
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ export { PushStoriesPreview, hasStoryButton, normalizeStoryDuration, PUSH_STORIE
|
|
|
37
37
|
export { InboxPreview, resolveInboxLayout, MAX_CAROUSEL_SLIDES } from './InboxPreview';
|
|
38
38
|
export { WhatsAppPreview } from './WhatsAppPreview';
|
|
39
39
|
export { Toast, ToastProvider, useToast } from './Toast';
|
|
40
|
-
export { AutosizeInput, PageHeader, PageHeaderEditable } from './PageHeader';
|
|
40
|
+
export { AutosizeInput, PageHeader, PageHeaderEditable, Rename } from './PageHeader';
|
|
41
41
|
export { Steps, useSteps } from './Steps';
|
|
42
42
|
export { ExportResult } from './ExportResult';
|
|
43
43
|
export { ExternalImagePreview } from './ExternalImagePreview';
|
package/package.json
CHANGED
|
@@ -12,9 +12,12 @@ export function useAsyncItems({
|
|
|
12
12
|
debounceMs = DEFAULT_DEBOUNCE_MS,
|
|
13
13
|
minChars = 0
|
|
14
14
|
}) {
|
|
15
|
-
const [
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const [state, setState] = useState({
|
|
16
|
+
session: 0,
|
|
17
|
+
items: [],
|
|
18
|
+
loading: false,
|
|
19
|
+
loadingMore: false
|
|
20
|
+
});
|
|
18
21
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
19
22
|
const loadItemsRef = useRef(loadItems);
|
|
20
23
|
loadItemsRef.current = loadItems;
|
|
@@ -23,60 +26,85 @@ export function useAsyncItems({
|
|
|
23
26
|
const queryRef = useRef('');
|
|
24
27
|
const loadingRef = useRef(false);
|
|
25
28
|
const hasMoreRef = useRef(false);
|
|
29
|
+
const sessionDeps = [debouncedQuery, isOpen, minChars];
|
|
30
|
+
const [prevSessionDeps, setPrevSessionDeps] = useState(null);
|
|
31
|
+
if (prevSessionDeps === null || sessionDeps.some((dep, index) => dep !== prevSessionDeps[index])) {
|
|
32
|
+
setPrevSessionDeps(sessionDeps);
|
|
33
|
+
const belowMin = debouncedQuery.trim().length < minChars;
|
|
34
|
+
setState(prev => ({
|
|
35
|
+
session: prev.session + 1,
|
|
36
|
+
items: !loadItems || belowMin ? [] : prev.items,
|
|
37
|
+
loading: Boolean(loadItems) && isOpen && !belowMin,
|
|
38
|
+
loadingMore: false
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
const {
|
|
42
|
+
session
|
|
43
|
+
} = state;
|
|
26
44
|
useEffect(() => {
|
|
27
45
|
const loader = loadItemsRef.current;
|
|
28
46
|
const belowMin = debouncedQuery.trim().length < minChars;
|
|
29
|
-
sessionRef.current
|
|
47
|
+
sessionRef.current = session;
|
|
30
48
|
pageRef.current = 0;
|
|
31
49
|
loadingRef.current = false;
|
|
32
50
|
hasMoreRef.current = false;
|
|
33
|
-
setLoadingMore(false);
|
|
34
51
|
if (!loader || !isOpen || belowMin) {
|
|
35
|
-
setLoading(false);
|
|
36
|
-
if (!loader || belowMin) setItems([]);
|
|
37
52
|
return undefined;
|
|
38
53
|
}
|
|
39
|
-
const session = sessionRef.current;
|
|
40
54
|
queryRef.current = debouncedQuery;
|
|
41
55
|
loadingRef.current = true;
|
|
42
|
-
setLoading(true);
|
|
43
56
|
Promise.resolve(loader(debouncedQuery, 0)).then(result => {
|
|
44
57
|
if (session !== sessionRef.current) return;
|
|
45
|
-
setItems(result.items);
|
|
46
58
|
hasMoreRef.current = result.hasMore ?? false;
|
|
47
59
|
loadingRef.current = false;
|
|
48
|
-
|
|
60
|
+
setState(prev => prev.session === session ? {
|
|
61
|
+
...prev,
|
|
62
|
+
items: result.items,
|
|
63
|
+
loading: false
|
|
64
|
+
} : prev);
|
|
49
65
|
}).catch(() => {
|
|
50
66
|
if (session !== sessionRef.current) return;
|
|
51
67
|
loadingRef.current = false;
|
|
52
|
-
|
|
68
|
+
setState(prev => prev.session === session ? {
|
|
69
|
+
...prev,
|
|
70
|
+
loading: false
|
|
71
|
+
} : prev);
|
|
53
72
|
});
|
|
54
73
|
return undefined;
|
|
55
|
-
}, [debouncedQuery, isOpen, minChars]);
|
|
74
|
+
}, [session, debouncedQuery, isOpen, minChars]);
|
|
56
75
|
const loadMore = useCallback(() => {
|
|
57
76
|
const loader = loadItemsRef.current;
|
|
58
77
|
if (!loader || loadingRef.current || !hasMoreRef.current) return;
|
|
59
|
-
const
|
|
78
|
+
const loadSession = sessionRef.current;
|
|
60
79
|
const nextPage = pageRef.current + 1;
|
|
61
80
|
loadingRef.current = true;
|
|
62
|
-
|
|
81
|
+
setState(prev => prev.session === loadSession ? {
|
|
82
|
+
...prev,
|
|
83
|
+
loadingMore: true
|
|
84
|
+
} : prev);
|
|
63
85
|
Promise.resolve(loader(queryRef.current, nextPage)).then(result => {
|
|
64
|
-
if (
|
|
86
|
+
if (loadSession !== sessionRef.current) return;
|
|
65
87
|
pageRef.current = nextPage;
|
|
66
|
-
setItems(prev => [...prev, ...result.items]);
|
|
67
88
|
hasMoreRef.current = result.hasMore ?? false;
|
|
68
89
|
loadingRef.current = false;
|
|
69
|
-
|
|
90
|
+
setState(prev => prev.session === loadSession ? {
|
|
91
|
+
...prev,
|
|
92
|
+
items: [...prev.items, ...result.items],
|
|
93
|
+
loadingMore: false
|
|
94
|
+
} : prev);
|
|
70
95
|
}).catch(() => {
|
|
71
|
-
if (
|
|
96
|
+
if (loadSession !== sessionRef.current) return;
|
|
72
97
|
loadingRef.current = false;
|
|
73
|
-
|
|
98
|
+
setState(prev => prev.session === loadSession ? {
|
|
99
|
+
...prev,
|
|
100
|
+
loadingMore: false
|
|
101
|
+
} : prev);
|
|
74
102
|
});
|
|
75
103
|
}, []);
|
|
76
104
|
return {
|
|
77
|
-
items,
|
|
78
|
-
loading,
|
|
79
|
-
loadingMore,
|
|
105
|
+
items: state.items,
|
|
106
|
+
loading: state.loading,
|
|
107
|
+
loadingMore: state.loadingMore,
|
|
80
108
|
loadMore
|
|
81
109
|
};
|
|
82
110
|
}
|