@pushwoosh/dumb-components 4.10.2 → 4.11.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/Combobox/Combobox.js +8 -3
- package/Combobox/types.d.ts +4 -0
- package/RichMessageEditor/RichMessageEditor.js +2 -0
- package/RichMessageEditor/RichMessageEditor.types.d.ts +2 -0
- package/RichMessageEditor/slate/SlateEditor.d.ts +1 -0
- package/RichMessageEditor/slate/SlateEditor.js +4 -2
- package/RichMessageEditor/slate/styles.d.ts +1 -0
- package/RichMessageEditor/slate/styles.js +5 -3
- package/package.json +1 -1
- package/shared/dropdownField/SuggestionsDropdown.js +1 -0
- package/shared/dropdownField/styles.d.ts +1 -0
- package/shared/dropdownField/styles.js +6 -2
- package/shared/dropdownField/types.d.ts +2 -0
package/Combobox/Combobox.js
CHANGED
|
@@ -171,7 +171,9 @@ function SelectCombobox({
|
|
|
171
171
|
hasError,
|
|
172
172
|
width,
|
|
173
173
|
minWidth,
|
|
174
|
-
fullWidth
|
|
174
|
+
fullWidth,
|
|
175
|
+
searchable = true,
|
|
176
|
+
selectedTone = 'soft'
|
|
175
177
|
}) {
|
|
176
178
|
const inputRef = useRef(null);
|
|
177
179
|
const baseId = useId();
|
|
@@ -200,7 +202,7 @@ function SelectCombobox({
|
|
|
200
202
|
const hasValue = value !== null && value !== undefined;
|
|
201
203
|
const valueLabel = hasValue ? getLabel(value) : '';
|
|
202
204
|
const selectedKey = hasValue ? getKey(value) : null;
|
|
203
|
-
const inputValue = isOpen ? query : valueLabel;
|
|
205
|
+
const inputValue = isOpen && searchable ? query : valueLabel;
|
|
204
206
|
const userMovedRef = useRef(false);
|
|
205
207
|
const selectedIndex = sourceItems.findIndex(it => getKey(it) === selectedKey);
|
|
206
208
|
const activateSelected = useCallback(() => {
|
|
@@ -222,6 +224,7 @@ function SelectCombobox({
|
|
|
222
224
|
setActiveIndex(next);
|
|
223
225
|
}, [setActiveIndex]);
|
|
224
226
|
const search = event => {
|
|
227
|
+
if (!searchable) return;
|
|
225
228
|
setQuery(event.target.value);
|
|
226
229
|
if (event.target.value) moveActive(0);else activateSelected();
|
|
227
230
|
};
|
|
@@ -269,9 +272,10 @@ function SelectCombobox({
|
|
|
269
272
|
label: renderItem ? renderItem(item, state) : getLabel(item),
|
|
270
273
|
active: state.active,
|
|
271
274
|
selected,
|
|
275
|
+
selectedTone,
|
|
272
276
|
onSelect: () => commit(item)
|
|
273
277
|
};
|
|
274
|
-
}), [filteredItems, activeIndex, selectedKey, getLabel, getKey, renderItem, commit, baseId]);
|
|
278
|
+
}), [filteredItems, activeIndex, selectedKey, getLabel, getKey, renderItem, commit, baseId, selectedTone]);
|
|
275
279
|
const activeDescendant = activeIndex >= 0 && activeIndex < filteredItems.length ? optionId(getKey(filteredItems[activeIndex])) : undefined;
|
|
276
280
|
return _jsx(FieldShell, {
|
|
277
281
|
isOpen: isOpen,
|
|
@@ -303,6 +307,7 @@ function SelectCombobox({
|
|
|
303
307
|
autosize: autosize,
|
|
304
308
|
value: inputValue,
|
|
305
309
|
onChange: search,
|
|
310
|
+
readOnly: !searchable,
|
|
306
311
|
onKeyDown: onInputKeyDown,
|
|
307
312
|
onFocus: open,
|
|
308
313
|
onClick: open,
|
package/Combobox/types.d.ts
CHANGED
|
@@ -85,6 +85,10 @@ export type SelectComboboxProps<T> = ComboboxSource<T> & GetKeyProp<T> & CommonP
|
|
|
85
85
|
onChange: (value: T | null) => void;
|
|
86
86
|
/** Map an item to its display label (required). */
|
|
87
87
|
getLabel: (item: T) => string;
|
|
88
|
+
/** Typing filters the items (default `true`); `false` keeps the selected label in the field while the list is open. */
|
|
89
|
+
searchable?: boolean;
|
|
90
|
+
/** Highlight of the selected row: `soft` (default) or `solid` (bright fill, white text). */
|
|
91
|
+
selectedTone?: 'soft' | 'solid';
|
|
88
92
|
};
|
|
89
93
|
/** Props of {@link Combobox} — free-text by default, strict single-select with `select`. */
|
|
90
94
|
export type ComboboxProps<T> = FreeComboboxProps | SelectComboboxProps<T>;
|
|
@@ -25,6 +25,7 @@ export const RichMessageEditor = ({
|
|
|
25
25
|
title,
|
|
26
26
|
initialValue,
|
|
27
27
|
minHeight,
|
|
28
|
+
compact,
|
|
28
29
|
placeholder,
|
|
29
30
|
error,
|
|
30
31
|
isErrored,
|
|
@@ -129,6 +130,7 @@ export const RichMessageEditor = ({
|
|
|
129
130
|
}),
|
|
130
131
|
children: [_jsx(SlateEditable, {
|
|
131
132
|
minHeight: minHeight,
|
|
133
|
+
compact: compact,
|
|
132
134
|
placeholder: placeholder,
|
|
133
135
|
isErrored: isErrored || !!error,
|
|
134
136
|
onFocus: () => {
|
|
@@ -24,6 +24,8 @@ export type RichMessageEditorProps = {
|
|
|
24
24
|
onChange: (value: string) => void;
|
|
25
25
|
/** Minimum editor height (CSS value). */
|
|
26
26
|
minHeight?: string;
|
|
27
|
+
/** Size a one-line editor like a text input, 36px high (default `false`). */
|
|
28
|
+
compact?: boolean;
|
|
27
29
|
/** Hint shown while the editor is empty. */
|
|
28
30
|
placeholder?: string;
|
|
29
31
|
/** Error message; switches the field to the error state. */
|
|
@@ -26,6 +26,7 @@ export const SlateEditor = ({
|
|
|
26
26
|
};
|
|
27
27
|
export const SlateEditable = ({
|
|
28
28
|
minHeight,
|
|
29
|
+
compact,
|
|
29
30
|
placeholder,
|
|
30
31
|
isErrored,
|
|
31
32
|
onFocus,
|
|
@@ -35,10 +36,11 @@ export const SlateEditable = ({
|
|
|
35
36
|
return renderElement(props, onDelete);
|
|
36
37
|
});
|
|
37
38
|
return _jsx(EditableStyled, {
|
|
38
|
-
style: minHeight ? {
|
|
39
|
-
minHeight
|
|
39
|
+
style: minHeight || compact ? {
|
|
40
|
+
minHeight: minHeight ?? '36px'
|
|
40
41
|
} : undefined,
|
|
41
42
|
"$isErrored": isErrored,
|
|
43
|
+
"$compact": compact,
|
|
42
44
|
placeholder: placeholder,
|
|
43
45
|
renderElement: renderElementPersistent,
|
|
44
46
|
onFocus: onFocus
|
|
@@ -17,6 +17,7 @@ export declare const EditableStyled: import("styled-components/dist/types").ISty
|
|
|
17
17
|
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
18
18
|
}, {
|
|
19
19
|
$isErrored?: boolean;
|
|
20
|
+
$compact?: boolean;
|
|
20
21
|
}>> & string & Omit<import("react").ForwardRefExoticComponent<{
|
|
21
22
|
decorate?: ((entry: import("slate").NodeEntry) => import("slate").DecoratedRange[]) | undefined;
|
|
22
23
|
onDOMBeforeInput?: ((event: InputEvent) => void) | undefined;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Editable } from 'slate-react';
|
|
2
|
-
import styled from 'styled-components';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
3
|
import { Color, FontSize, FontWeight, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
4
4
|
export const EditableStyled = styled(Editable).withConfig({
|
|
5
5
|
displayName: "EditableStyled",
|
|
6
6
|
componentId: "sc-16lukqt-0"
|
|
7
|
-
})(["font-weight:", ";font-size:", ";line-height:140%;padding:8px;color:", ";background:", ";caret-color:", ";border:1px solid ", ";border-radius:", ";overflow-x:auto
|
|
7
|
+
})(["font-weight:", ";font-size:", ";line-height:140%;padding:8px;color:", ";background:", ";caret-color:", ";border:1px solid ", ";border-radius:", ";overflow-x:auto;", " & [data-slate-placeholder='true']{color:", ";opacity:1 !important;}&:focus{border-color:", ";outline:none;}& > p{position:relative;margin:4px 0;&:first-child{margin-top:0;}&:last-child{margin-bottom:0;}}"], FontWeight.REGULAR, FontSize.REGULAR, Color.MAIN, Color.CLEAR, Color.BRIGHT, ({
|
|
8
8
|
$isErrored
|
|
9
|
-
}) => $isErrored ? Color.DANGER : Color.FORM, ShapeRadius.CONTROL,
|
|
9
|
+
}) => $isErrored ? Color.DANGER : Color.FORM, ShapeRadius.CONTROL, ({
|
|
10
|
+
$compact
|
|
11
|
+
}) => $compact && css(["box-sizing:border-box;padding-top:7px;padding-bottom:7px;"]), Color.PHANTOM, Color.BRIGHT);
|
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ export declare const DropdownItem: import("styled-components/dist/types").IStyle
|
|
|
35
35
|
}, {
|
|
36
36
|
$active?: boolean;
|
|
37
37
|
$selected?: boolean;
|
|
38
|
+
$solid?: boolean;
|
|
38
39
|
}>> & string;
|
|
39
40
|
export declare const DropdownEmpty: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
40
41
|
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
@@ -63,7 +63,7 @@ export const Dropdown = styled.div.withConfig({
|
|
|
63
63
|
export const DropdownItem = styled.div.withConfig({
|
|
64
64
|
displayName: "DropdownItem",
|
|
65
65
|
componentId: "sc-1pvwhhw-7"
|
|
66
|
-
})(["display:flex;align-items:center;gap:6px;padding:6px 12px;overflow-wrap:anywhere;", ";& > *{min-width:0;}background:", ";cursor:pointer;&:hover{background:", ";}"], textBase, ({
|
|
66
|
+
})(["display:flex;align-items:center;gap:6px;padding:6px 12px;overflow-wrap:anywhere;", ";& > *{min-width:0;}background:", ";cursor:pointer;&:hover{background:", ";}", ""], textBase, ({
|
|
67
67
|
$active,
|
|
68
68
|
$selected
|
|
69
69
|
}) => {
|
|
@@ -72,7 +72,11 @@ export const DropdownItem = styled.div.withConfig({
|
|
|
72
72
|
return 'transparent';
|
|
73
73
|
}, ({
|
|
74
74
|
$selected
|
|
75
|
-
}) => $selected ? Color.BRIGHT_LIGHT_HOVER : Color.ROW_HOVER
|
|
75
|
+
}) => $selected ? Color.BRIGHT_LIGHT_HOVER : Color.ROW_HOVER, ({
|
|
76
|
+
$selected,
|
|
77
|
+
$solid,
|
|
78
|
+
$active
|
|
79
|
+
}) => $selected && $solid && css(["background:", ";color:", ";&:hover{background:", ";}"], $active ? Color.BRIGHT_HOVER : Color.BRIGHT, Color.CLEAR, Color.BRIGHT_HOVER));
|
|
76
80
|
export const DropdownEmpty = styled.div.withConfig({
|
|
77
81
|
displayName: "DropdownEmpty",
|
|
78
82
|
componentId: "sc-1pvwhhw-8"
|
|
@@ -66,6 +66,8 @@ export type DropdownItemDescriptor = {
|
|
|
66
66
|
active?: boolean;
|
|
67
67
|
/** Row is the selected value. */
|
|
68
68
|
selected?: boolean;
|
|
69
|
+
/** Highlight of the selected row: `soft` (default) or `solid` (bright fill, white text). */
|
|
70
|
+
selectedTone?: 'soft' | 'solid';
|
|
69
71
|
/** Called when the row is chosen. */
|
|
70
72
|
onSelect?: () => void;
|
|
71
73
|
};
|