@redocly/theme 0.42.2 → 0.43.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/lib/components/Dropdown/DropdownMenu.d.ts +2 -0
- package/lib/components/Dropdown/DropdownMenu.js +3 -1
- package/lib/components/Loaders/SpinnerLoader.d.ts +5 -0
- package/lib/components/Loaders/SpinnerLoader.js +32 -0
- package/lib/components/Search/FilterFields/SearchFilterFieldSelect.d.ts +12 -0
- package/lib/components/Search/FilterFields/SearchFilterFieldSelect.js +113 -0
- package/lib/components/Search/FilterFields/SearchFilterFieldTags.d.ts +10 -0
- package/lib/components/Search/FilterFields/SearchFilterFieldTags.js +37 -0
- package/lib/components/Search/Search.js +1 -1
- package/lib/components/Search/SearchDialog.js +109 -27
- package/lib/components/Search/SearchFilter.d.ts +11 -0
- package/lib/components/Search/SearchFilter.js +71 -0
- package/lib/components/Search/SearchFilterField.d.ts +11 -0
- package/lib/components/Search/SearchFilterField.js +43 -0
- package/lib/components/Search/SearchGroups.d.ts +9 -0
- package/lib/components/Search/SearchGroups.js +69 -0
- package/lib/components/Search/SearchHighlight.d.ts +1 -1
- package/lib/components/Search/SearchHighlight.js +28 -5
- package/lib/components/Search/SearchInput.d.ts +1 -1
- package/lib/components/Search/SearchInput.js +5 -2
- package/lib/components/Search/SearchItem.d.ts +2 -2
- package/lib/components/Search/SearchItem.js +24 -15
- package/lib/components/Search/variables.js +48 -2
- package/lib/components/Segmented/Segmented.d.ts +2 -5
- package/lib/components/Select/Select.d.ts +2 -36
- package/lib/components/Select/Select.js +136 -98
- package/lib/components/Select/SelectInput.d.ts +23 -0
- package/lib/components/Select/SelectInput.js +129 -0
- package/lib/components/Select/variables.js +12 -1
- package/lib/components/Tag/Tag.d.ts +4 -2
- package/lib/components/Tag/Tag.js +40 -4
- package/lib/components/Tag/variables.dark.js +20 -5
- package/lib/components/Tag/variables.js +49 -17
- package/lib/components/VersionPicker/VersionPicker.d.ts +2 -3
- package/lib/components/VersionPicker/VersionPicker.js +13 -30
- package/lib/core/hooks/__mocks__/index.d.ts +2 -1
- package/lib/core/hooks/__mocks__/index.js +2 -1
- package/lib/core/hooks/__mocks__/search/use-search-filter.d.ts +9 -0
- package/lib/core/hooks/__mocks__/search/use-search-filter.js +14 -0
- package/lib/core/hooks/__mocks__/use-theme-hooks.d.ts +6 -1
- package/lib/core/hooks/__mocks__/use-theme-hooks.js +6 -1
- package/lib/core/hooks/index.d.ts +2 -1
- package/lib/core/hooks/index.js +2 -1
- package/lib/core/hooks/search/use-recent-searches.js +2 -0
- package/lib/core/hooks/{use-search.d.ts → search/use-search-dialog.d.ts} +1 -1
- package/lib/core/hooks/{use-search.js → search/use-search-dialog.js} +5 -5
- package/lib/core/hooks/search/use-search-filter.d.ts +9 -0
- package/lib/core/hooks/search/use-search-filter.js +50 -0
- package/lib/core/types/hooks.d.ts +17 -4
- package/lib/core/types/index.d.ts +1 -1
- package/lib/core/types/index.js +1 -1
- package/lib/core/types/l10n.d.ts +1 -2
- package/lib/core/types/search.d.ts +42 -2
- package/lib/core/types/select.d.ts +31 -0
- package/lib/core/types/{select-option.js → select.js} +1 -1
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/core/utils/text-trimmer.d.ts +1 -0
- package/lib/core/utils/text-trimmer.js +16 -0
- package/lib/icons/ResetIcon/ResetIcon.d.ts +9 -0
- package/lib/icons/ResetIcon/ResetIcon.js +22 -0
- package/lib/icons/SettingsIcon/SettingsIcon.d.ts +9 -0
- package/lib/icons/SettingsIcon/SettingsIcon.js +23 -0
- package/lib/index.d.ts +8 -1
- package/lib/index.js +8 -1
- package/lib/markdoc/components/Cards/Card.js +6 -6
- package/package.json +3 -3
- package/src/components/Dropdown/DropdownMenu.tsx +2 -1
- package/src/components/Filter/FilterSelect.tsx +3 -3
- package/src/components/Loaders/SpinnerLoader.tsx +31 -0
- package/src/components/Search/FilterFields/SearchFilterFieldSelect.tsx +135 -0
- package/src/components/Search/FilterFields/SearchFilterFieldTags.tsx +61 -0
- package/src/components/Search/Search.tsx +2 -2
- package/src/components/Search/SearchDialog.tsx +183 -41
- package/src/components/Search/SearchFilter.tsx +90 -0
- package/src/components/Search/SearchFilterField.tsx +84 -0
- package/src/components/Search/SearchGroups.tsx +81 -0
- package/src/components/Search/SearchHighlight.tsx +29 -2
- package/src/components/Search/SearchInput.tsx +9 -3
- package/src/components/Search/SearchItem.tsx +39 -24
- package/src/components/Search/variables.ts +48 -2
- package/src/components/Segmented/Segmented.tsx +2 -2
- package/src/components/Select/Select.tsx +208 -157
- package/src/components/Select/SelectInput.tsx +201 -0
- package/src/components/Select/variables.ts +12 -1
- package/src/components/Tag/Tag.tsx +57 -6
- package/src/components/Tag/variables.dark.ts +20 -5
- package/src/components/Tag/variables.ts +49 -17
- package/src/components/VersionPicker/VersionPicker.tsx +15 -39
- package/src/core/hooks/__mocks__/index.ts +2 -1
- package/src/core/hooks/__mocks__/search/use-search-filter.ts +10 -0
- package/src/core/hooks/__mocks__/use-theme-hooks.ts +6 -1
- package/src/core/hooks/index.ts +2 -1
- package/src/core/hooks/search/use-recent-searches.ts +3 -0
- package/src/core/hooks/{use-search.ts → search/use-search-dialog.ts} +1 -1
- package/src/core/hooks/search/use-search-filter.ts +57 -0
- package/src/core/types/hooks.ts +25 -4
- package/src/core/types/index.ts +1 -1
- package/src/core/types/l10n.ts +110 -38
- package/src/core/types/search.ts +53 -2
- package/src/core/types/select.ts +33 -0
- package/src/core/utils/index.ts +1 -0
- package/src/core/utils/text-trimmer.ts +7 -0
- package/src/icons/ResetIcon/ResetIcon.tsx +26 -0
- package/src/icons/SettingsIcon/SettingsIcon.tsx +30 -0
- package/src/index.ts +8 -1
- package/src/markdoc/components/Cards/Card.tsx +15 -15
- package/lib/core/types/select-option.d.ts +0 -4
- package/src/core/types/select-option.ts +0 -4
- /package/lib/components/{Loading → Loaders}/Loading.d.ts +0 -0
- /package/lib/components/{Loading → Loaders}/Loading.js +0 -0
- /package/src/components/{Loading → Loaders}/Loading.tsx +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { SelectOption } from '@redocly/theme/core/types/select';
|
|
5
|
+
|
|
6
|
+
import { Tag } from '@redocly/theme/components/Tag/Tag';
|
|
7
|
+
import { CloseIcon } from '@redocly/theme/icons/CloseIcon/CloseIcon';
|
|
8
|
+
import { Button } from '@redocly/theme/components/Button/Button';
|
|
9
|
+
|
|
10
|
+
type SelectInputProps<T> = {
|
|
11
|
+
id?: string;
|
|
12
|
+
selectedOptions: SelectOption<T>[];
|
|
13
|
+
searchValue: any;
|
|
14
|
+
stickyValue: any;
|
|
15
|
+
onlyIcon?: boolean;
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
customIcon?: React.ReactNode;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
searchable?: boolean;
|
|
21
|
+
clearable?: boolean;
|
|
22
|
+
clearHandler?: (value?: any) => void;
|
|
23
|
+
inputBlurHandler?: (e?: any) => void;
|
|
24
|
+
inputFocusHandler?: (e?: any) => void;
|
|
25
|
+
searchHandler?: (e?: any) => void;
|
|
26
|
+
clickHandler?: (e?: any) => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function SelectInput<T>(props: SelectInputProps<T>): React.ReactNode {
|
|
30
|
+
const {
|
|
31
|
+
id,
|
|
32
|
+
onlyIcon,
|
|
33
|
+
icon,
|
|
34
|
+
customIcon,
|
|
35
|
+
selectedOptions,
|
|
36
|
+
placeholder,
|
|
37
|
+
stickyValue,
|
|
38
|
+
multiple,
|
|
39
|
+
searchable,
|
|
40
|
+
clearable,
|
|
41
|
+
clearHandler,
|
|
42
|
+
searchHandler,
|
|
43
|
+
clickHandler,
|
|
44
|
+
searchValue,
|
|
45
|
+
inputBlurHandler,
|
|
46
|
+
inputFocusHandler,
|
|
47
|
+
} = props;
|
|
48
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
49
|
+
|
|
50
|
+
const onChangeHandler = (e: any) => {
|
|
51
|
+
searchHandler?.(e);
|
|
52
|
+
inputRef.current?.focus();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const onKeyDownHandler = (e: any) => {
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
if (e.key === 'Backspace' && !searchValue && selectedOptions.length) {
|
|
58
|
+
clearHandler?.(selectedOptions[selectedOptions.length - 1]);
|
|
59
|
+
inputRef.current?.focus();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const onClickHandler = (e: React.MouseEvent) => {
|
|
64
|
+
clickHandler?.(e);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const onFocusHandler = (e: React.FocusEvent<HTMLDivElement>) => {
|
|
68
|
+
inputFocusHandler?.(e);
|
|
69
|
+
inputRef.current?.focus();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const onBlurHandler = (e: React.FocusEvent<HTMLDivElement>) => {
|
|
73
|
+
inputBlurHandler?.(e);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const onClearAllHandler = (e: React.MouseEvent) => {
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
clearHandler?.();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const selectTags = selectedOptions.map((option, index) => (
|
|
82
|
+
<SelectInputTag
|
|
83
|
+
closable
|
|
84
|
+
key={index}
|
|
85
|
+
onClose={() => {
|
|
86
|
+
clearHandler?.(option);
|
|
87
|
+
inputRef.current?.focus();
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
{option.label || (option.value as string) || option.element}
|
|
91
|
+
</SelectInputTag>
|
|
92
|
+
));
|
|
93
|
+
|
|
94
|
+
const selectInput = (
|
|
95
|
+
<SelectInternalInput
|
|
96
|
+
value={
|
|
97
|
+
searchValue ||
|
|
98
|
+
(!multiple && !stickyValue && selectedOptions.length
|
|
99
|
+
? selectedOptions[0].label || selectedOptions[0].value
|
|
100
|
+
: '')
|
|
101
|
+
}
|
|
102
|
+
placeholder={
|
|
103
|
+
searchValue || (multiple && selectedOptions.length) ? '' : stickyValue || placeholder
|
|
104
|
+
}
|
|
105
|
+
onChange={onChangeHandler}
|
|
106
|
+
onKeyDown={onKeyDownHandler}
|
|
107
|
+
onBlur={onBlurHandler}
|
|
108
|
+
ref={inputRef}
|
|
109
|
+
width={multiple ? (!searchValue && selectedOptions.length ? '10px' : 'auto') : '100%'}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const simpleValue = selectedOptions.length ? (
|
|
114
|
+
selectedOptions[0].label || selectedOptions[0].element || (selectedOptions[0].value as string)
|
|
115
|
+
) : (
|
|
116
|
+
<SelectInternalInputPlaceholder>{placeholder}</SelectInternalInputPlaceholder>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const multipleValues = selectedOptions.length ? (
|
|
120
|
+
selectTags
|
|
121
|
+
) : (
|
|
122
|
+
<SelectInternalInputPlaceholder>{placeholder}</SelectInternalInputPlaceholder>
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<SelectInputWrapper {...props} id={id} onFocus={onFocusHandler} onClick={onClickHandler}>
|
|
127
|
+
{!onlyIcon && (
|
|
128
|
+
<>
|
|
129
|
+
<SelectInputValue>
|
|
130
|
+
{multiple ? (
|
|
131
|
+
searchable ? (
|
|
132
|
+
<>
|
|
133
|
+
{selectTags}
|
|
134
|
+
{selectInput}
|
|
135
|
+
</>
|
|
136
|
+
) : (
|
|
137
|
+
multipleValues
|
|
138
|
+
)
|
|
139
|
+
) : searchable ? (
|
|
140
|
+
selectInput
|
|
141
|
+
) : (
|
|
142
|
+
simpleValue
|
|
143
|
+
)}
|
|
144
|
+
</SelectInputValue>
|
|
145
|
+
{!!(clearable && selectedOptions.length) && (
|
|
146
|
+
<Button size="small" variant="text" icon={<CloseIcon />} onClick={onClearAllHandler} />
|
|
147
|
+
)}
|
|
148
|
+
</>
|
|
149
|
+
)}
|
|
150
|
+
{customIcon || icon}
|
|
151
|
+
</SelectInputWrapper>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const SelectInputWrapper = styled.div`
|
|
156
|
+
width: 100%;
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
justify-content: space-between;
|
|
160
|
+
border-radius: var(--select-input-border-radius);
|
|
161
|
+
padding: var(--select-input-padding);
|
|
162
|
+
cursor: pointer;
|
|
163
|
+
gap: var(--select-input-gap);
|
|
164
|
+
`;
|
|
165
|
+
|
|
166
|
+
const SelectInputValue = styled.div`
|
|
167
|
+
width: calc(100% - 20px);
|
|
168
|
+
display: flex;
|
|
169
|
+
min-width: 0;
|
|
170
|
+
text-overflow: ellipsis;
|
|
171
|
+
overflow: hidden;
|
|
172
|
+
flex-wrap: wrap;
|
|
173
|
+
gap: var(--select-input-value-gap);
|
|
174
|
+
`;
|
|
175
|
+
|
|
176
|
+
const SelectInputTag = styled(Tag)`
|
|
177
|
+
--tag-content-padding: 0;
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
const SelectInternalInput = styled.input.attrs(() => ({
|
|
181
|
+
type: 'text',
|
|
182
|
+
}))<{ width?: string }>`
|
|
183
|
+
outline: none;
|
|
184
|
+
border-radius: var(--select-input-border-radius);
|
|
185
|
+
border: none;
|
|
186
|
+
font-size: var(--select-input-font-size);
|
|
187
|
+
font-weight: var(--select-input-font-weight);
|
|
188
|
+
line-height: var(--select-input-line-height);
|
|
189
|
+
background-color: var(--select-input-bg-color);
|
|
190
|
+
|
|
191
|
+
&::placeholder {
|
|
192
|
+
color: var(--select-input-placeholder-color);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
width: ${({ width }) => width || 'auto'};
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
const SelectInternalInputPlaceholder = styled.div`
|
|
199
|
+
color: var(--select-input-placeholder-color);
|
|
200
|
+
padding-left: 8px;
|
|
201
|
+
`;
|
|
@@ -9,10 +9,19 @@ export const select = css`
|
|
|
9
9
|
--select-line-height: var(--line-height-base); // @presenter LineHeight
|
|
10
10
|
--select-text-color: var(--text-color-secondary); // @presenter Color
|
|
11
11
|
--select-border-radius: var(--border-radius); // @presenter BorderRadius
|
|
12
|
+
--select-border: var(--border-width) var(--border-style) var(--border-color-primary); // @presenter Border
|
|
13
|
+
|
|
12
14
|
--select-input-padding-vertical: 6px; // @presenter Spacing
|
|
13
|
-
--select-input-padding-horizontal:
|
|
15
|
+
--select-input-padding-horizontal: 6px; // @presenter Spacing
|
|
14
16
|
--select-input-padding: var(--select-input-padding-vertical) var(--select-input-padding-horizontal);
|
|
17
|
+
--select-input-gap: var(--spacing-xs); // @presenter Spacing
|
|
18
|
+
--select-input-value-gap: var(--spacing-unit); // @presenter Spacing
|
|
15
19
|
--select-input-border-radius: var(--border-radius); // @presenter BorderRadius
|
|
20
|
+
--select-input-font-size: var(--font-size-base); // @presenter FontSize
|
|
21
|
+
--select-input-font-weight: var(--font-weight-regular); // @presenter FontWeight
|
|
22
|
+
--select-input-line-height: var(--line-height-base); // @presenter LineHeight
|
|
23
|
+
--select-input-bg-color: var(--bg-color); // @presenter Color
|
|
24
|
+
--select-input-placeholder-color: var(--input-content-placeholder-color); // @presenter Color
|
|
16
25
|
|
|
17
26
|
--select-list-min-width: 100px;
|
|
18
27
|
--select-list-max-width: 300px;
|
|
@@ -30,5 +39,7 @@ export const select = css`
|
|
|
30
39
|
--select-list-item-bg-color-active: transparent; // @presenter Color
|
|
31
40
|
--select-list-item-bg-color-hover: var(--menu-item-bg-color-hover); // @presenter Color
|
|
32
41
|
--select-list-item-font-weight-active: var(--font-weight-medium); // @presenter Color
|
|
42
|
+
|
|
43
|
+
--select-placeholder-color: var(--color-warm-grey-6); // @presenter Color
|
|
33
44
|
// @tokens End
|
|
34
45
|
`;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
+
import { CloseIcon } from '@redocly/theme/icons/CloseIcon/CloseIcon';
|
|
5
|
+
import { CheckmarkFilledIcon } from '@redocly/theme/icons/CheckmarkFilledIcon/CheckmarkFilledIcon';
|
|
6
|
+
|
|
4
7
|
type DefaultStatusColor = 'success' | 'processing' | 'error' | 'warning' | 'default';
|
|
5
8
|
type ActionStatusColor = 'approved' | 'declined' | 'pending';
|
|
6
9
|
type SubjectStatusColor = 'active' | 'draft' | 'deprecated' | 'product';
|
|
@@ -35,14 +38,19 @@ export type TagProps = {
|
|
|
35
38
|
statusDotColor?: string;
|
|
36
39
|
size?: string;
|
|
37
40
|
icon?: React.ReactNode;
|
|
38
|
-
|
|
41
|
+
active?: boolean;
|
|
42
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
43
|
+
onClose?: (event: React.MouseEvent) => void;
|
|
39
44
|
};
|
|
40
45
|
|
|
41
46
|
export function Tag({
|
|
42
47
|
children,
|
|
43
48
|
color,
|
|
44
49
|
icon,
|
|
50
|
+
active,
|
|
51
|
+
closable,
|
|
45
52
|
onClick,
|
|
53
|
+
onClose,
|
|
46
54
|
size,
|
|
47
55
|
borderless,
|
|
48
56
|
withStatusDot,
|
|
@@ -50,31 +58,66 @@ export function Tag({
|
|
|
50
58
|
...otherProps
|
|
51
59
|
}: TagProps): JSX.Element {
|
|
52
60
|
return (
|
|
53
|
-
<
|
|
61
|
+
<TagWrapper
|
|
54
62
|
data-component-name="Tag/Tag"
|
|
55
63
|
borderless={borderless}
|
|
56
64
|
color={color}
|
|
57
65
|
size={size}
|
|
58
66
|
onClick={onClick}
|
|
67
|
+
hasCloseButton={closable}
|
|
59
68
|
{...otherProps}
|
|
60
69
|
>
|
|
61
70
|
{withStatusDot ? <StatusDot color={statusDotColor} /> : icon ? icon : null}
|
|
62
|
-
{children}
|
|
63
|
-
|
|
71
|
+
<ContentWrapper>{children}</ContentWrapper>
|
|
72
|
+
{closable && (
|
|
73
|
+
<CloseButton
|
|
74
|
+
onClick={(event) => {
|
|
75
|
+
onClose?.(event);
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<CloseIcon />
|
|
79
|
+
</CloseButton>
|
|
80
|
+
)}
|
|
81
|
+
{active && <ActiveIcon />}
|
|
82
|
+
</TagWrapper>
|
|
64
83
|
);
|
|
65
84
|
}
|
|
66
85
|
|
|
67
|
-
const
|
|
86
|
+
const ContentWrapper = styled.div`
|
|
87
|
+
display: inline-flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
text-wrap: nowrap;
|
|
91
|
+
|
|
92
|
+
padding: var(--tag-content-padding);
|
|
93
|
+
gap: var(--tag-content-gap);
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
const CloseButton = styled.div`
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
align-self: stretch;
|
|
101
|
+
border-radius: 0 var(--tag-border-radius) var(--tag-border-radius) 0;
|
|
102
|
+
|
|
103
|
+
&:hover {
|
|
104
|
+
background: var(--tag-close-button-bg-color-hover);
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
const TagWrapper = styled.div.attrs(({ className, color, size }: TagProps) => ({
|
|
68
109
|
className:
|
|
69
110
|
(className || '') +
|
|
70
111
|
` tag-default ${color ? `tag-${color}` : ''} ${size ? `tag-size-${size}` : ''}`,
|
|
71
|
-
}))<TagProps>`
|
|
112
|
+
}))<TagProps & { hasCloseButton?: boolean }>`
|
|
72
113
|
display: inline-flex;
|
|
73
114
|
align-items: center;
|
|
74
115
|
justify-content: center;
|
|
75
116
|
text-wrap: nowrap;
|
|
117
|
+
position: relative;
|
|
76
118
|
|
|
77
119
|
padding: var(--tag-padding);
|
|
120
|
+
${({ hasCloseButton }) => (hasCloseButton ? 'padding-right: 0;' : '')};
|
|
78
121
|
margin: var(--tag-margin);
|
|
79
122
|
|
|
80
123
|
&:last-child {
|
|
@@ -107,3 +150,11 @@ const StatusDot = styled.div<{ color: string }>`
|
|
|
107
150
|
border-radius: 50%;
|
|
108
151
|
background-color: ${({ color }) => color};
|
|
109
152
|
`;
|
|
153
|
+
|
|
154
|
+
const ActiveIcon = styled(CheckmarkFilledIcon)`
|
|
155
|
+
width: 12px;
|
|
156
|
+
height: 12px;
|
|
157
|
+
position: absolute;
|
|
158
|
+
right: -4px;
|
|
159
|
+
top: -4px;
|
|
160
|
+
`;
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { css } from 'styled-components';
|
|
2
2
|
|
|
3
3
|
export const tagDarkMode = css`
|
|
4
|
-
--tag-operation-color-delete: #fa82a2;
|
|
5
|
-
--tag-operation-color-
|
|
6
|
-
|
|
7
|
-
--tag-operation-color-
|
|
8
|
-
--tag-operation-color-
|
|
4
|
+
--tag-operation-color-delete: #fa82a2; // @presenter Color
|
|
5
|
+
--tag-operation-bg-color-delete: #77214C; // @presenter Color
|
|
6
|
+
|
|
7
|
+
--tag-operation-color-get: #68cc97; // @presenter Color
|
|
8
|
+
--tag-operation-bg-color-get: #1F4D2D; // @presenter Color
|
|
9
|
+
|
|
10
|
+
--tag-operation-color-post: #90b0f0; // @presenter Color
|
|
11
|
+
--tag-operation-bg-color-post: #233061; // @presenter Color
|
|
12
|
+
|
|
13
|
+
--tag-operation-color-put: #e0a663; // @presenter Color
|
|
14
|
+
--tag-operation-bg-color-put: #612729; // @presenter Color
|
|
15
|
+
|
|
16
|
+
--tag-operation-color-patch: #e0c363; // @presenter Color
|
|
17
|
+
--tag-operation-bg-color-patch: #5C3721; // @presenter Color
|
|
18
|
+
|
|
19
|
+
--tag-operation-color-head: #e6e1fe; // @presenter Color
|
|
20
|
+
--tag-operation-bg-color-head: #5b4ccc; // @presenter Color
|
|
21
|
+
|
|
22
|
+
--tag-operation-color-options: #1a1c21; // @presenter Color
|
|
23
|
+
--tag-operation-bg-color-options: #2a2b33; // @presenter Color
|
|
9
24
|
|
|
10
25
|
.tag-grey,
|
|
11
26
|
.tag-draft,
|
|
@@ -7,7 +7,7 @@ export const tag = css`
|
|
|
7
7
|
|
|
8
8
|
--tag-border-width: 1px; //@presenter Border
|
|
9
9
|
--tag-border-style: solid; //@presenter Border
|
|
10
|
-
--tag-border-radius: var(--border-radius
|
|
10
|
+
--tag-border-radius: var(--border-radius); // @presenter BorderRadius
|
|
11
11
|
--tag-box-shadow: none; // @presenter Shadow
|
|
12
12
|
|
|
13
13
|
--tag-status-dot-color-default: var(--color-persian-green-7);
|
|
@@ -20,8 +20,17 @@ export const tag = css`
|
|
|
20
20
|
* @tokens Tag spacing
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
--tag-padding: 1px
|
|
24
|
-
--tag-
|
|
23
|
+
--tag-padding-vertical: 1px; //@presenter Spacing
|
|
24
|
+
--tag-padding-horizontal: 8px; //@presenter Spacing
|
|
25
|
+
--tag-padding: 0 var(--tag-padding-horizontal); //@presenter Spacing
|
|
26
|
+
--tag-content-padding: var(--tag-padding-vertical) 0; //@presenter Spacing
|
|
27
|
+
--tag-content-gap: 4px; //@presenter Spacing
|
|
28
|
+
|
|
29
|
+
--tag-large-padding-vertical: 4px; //@presenter Spacing
|
|
30
|
+
--tag-large-padding-horizontal: 16px; //@presenter Spacing
|
|
31
|
+
--tag-large-padding: 0 var(--tag-large-padding-horizontal); //@presenter Spacing
|
|
32
|
+
--tag-large-content-padding: var(--tag-large-padding-vertical); //@presenter Spacing
|
|
33
|
+
|
|
25
34
|
--tag-margin: 0 5px 0 0; //@presenter Spacing
|
|
26
35
|
--tag-gap: 5px; //@presenter Spacing
|
|
27
36
|
|
|
@@ -31,6 +40,7 @@ export const tag = css`
|
|
|
31
40
|
|
|
32
41
|
.tag-size-large {
|
|
33
42
|
--tag-padding: var(--tag-large-padding);
|
|
43
|
+
--tag-content-padding: var(--tag-large-content-padding);
|
|
34
44
|
--tag-font-size: var(--font-size-base);
|
|
35
45
|
}
|
|
36
46
|
|
|
@@ -65,6 +75,7 @@ export const tag = css`
|
|
|
65
75
|
--tag-color: var(--text-color-primary); // @presenter Color
|
|
66
76
|
--tag-bg-color: var(--color-warm-grey-2); // @presenter Color
|
|
67
77
|
--tag-border-color: var(--border-color-primary); // @presenter Color
|
|
78
|
+
--tag-close-button-bg-color-hover: var(--color-warm-grey-3); // @presenter Color
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
.tag-green,
|
|
@@ -73,6 +84,7 @@ export const tag = css`
|
|
|
73
84
|
--tag-color: var(--color-success-active); // @presenter Color
|
|
74
85
|
--tag-bg-color: var(--color-success-bg); // @presenter Color
|
|
75
86
|
--tag-border-color: var(--color-success-active); // @presenter Color
|
|
87
|
+
--tag-close-button-bg-color-hover: var(--color-success-bg-hover); // @presenter Color
|
|
76
88
|
}
|
|
77
89
|
|
|
78
90
|
.tag-red,
|
|
@@ -81,6 +93,7 @@ export const tag = css`
|
|
|
81
93
|
--tag-color: var(--color-error-active); // @presenter Color
|
|
82
94
|
--tag-bg-color: var(--color-error-bg); // @presenter Color
|
|
83
95
|
--tag-border-color: var(--color-error-active); // @presenter Color
|
|
96
|
+
--tag-close-button-bg-color-hover: var(--color-error-hover); // @presenter Color
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
.tag-gold,
|
|
@@ -89,6 +102,7 @@ export const tag = css`
|
|
|
89
102
|
--tag-color: var(--color-warning-active); // @presenter Color
|
|
90
103
|
--tag-bg-color: var(--color-warning-bg); // @presenter Color
|
|
91
104
|
--tag-border-color: var(--color-warning-active); // @presenter Color
|
|
105
|
+
--tag-close-button-bg-color-hover: var(--color-warning-hover); // @presenter Color
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
.tag-blue,
|
|
@@ -96,6 +110,7 @@ export const tag = css`
|
|
|
96
110
|
--tag-color: var(--color-info-active); // @presenter Color
|
|
97
111
|
--tag-bg-color: var(--color-info-bg); // @presenter Color
|
|
98
112
|
--tag-border-color: var(--color-info-active); // @presenter Color
|
|
113
|
+
--tag-close-button-bg-color-hover: var(--color-info-hover); // @presenter Color
|
|
99
114
|
}
|
|
100
115
|
|
|
101
116
|
.tag-purple,
|
|
@@ -103,26 +118,24 @@ export const tag = css`
|
|
|
103
118
|
--tag-color: var(--color-purple-7); // @presenter Color
|
|
104
119
|
--tag-bg-color: var(--color-purple-1); // @presenter Color
|
|
105
120
|
--tag-border-color: var(--color-purple-7); // @presenter Color
|
|
121
|
+
--tag-close-button-bg-color-hover: var(--color-purple-3); // @presenter Color
|
|
106
122
|
}
|
|
107
123
|
|
|
108
124
|
.tag-cyan,
|
|
109
|
-
.tag-option
|
|
125
|
+
.tag-option,
|
|
126
|
+
.tag-geekblue,
|
|
127
|
+
.tag-link {
|
|
110
128
|
--tag-color: var(--color-turquoise-7); // @presenter Color
|
|
111
129
|
--tag-bg-color: var(--color-turquoise-1); // @presenter Color
|
|
112
130
|
--tag-border-color: var(--color-turquoise-7); // @presenter Color
|
|
131
|
+
--tag-close-button-bg-color-hover: var(--color-turquoise-3); // @presenter Color
|
|
113
132
|
}
|
|
114
133
|
|
|
115
134
|
.tag-yellow {
|
|
116
135
|
--tag-color: var(--color-carrot-7); // @presenter Color
|
|
117
136
|
--tag-bg-color: var(--color-carrot-1); // @presenter Color
|
|
118
137
|
--tag-border-color: var(--color-carrot-7); // @presenter Color
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.tag-geekblue,
|
|
122
|
-
.tag-link {
|
|
123
|
-
--tag-color: var(--color-turquoise-7); // @presenter Color
|
|
124
|
-
--tag-bg-color: var(--color-turquoise-1); // @presenter Color
|
|
125
|
-
--tag-border-color: var(--color-turquoise-7); // @presenter Color
|
|
138
|
+
--tag-close-button-bg-color-hover: var(--color-carrot-3); // @presenter Color
|
|
126
139
|
}
|
|
127
140
|
|
|
128
141
|
.tag-magenta,
|
|
@@ -130,18 +143,21 @@ export const tag = css`
|
|
|
130
143
|
--tag-color: var(--color-magenta-7); // @presenter Color
|
|
131
144
|
--tag-bg-color: var(--color-magenta-1); // @presenter Color
|
|
132
145
|
--tag-border-color: var(--color-magenta-7); // @presenter Color
|
|
146
|
+
--tag-close-button-bg-color-hover: var(--color-magenta-3); // @presenter Color
|
|
133
147
|
}
|
|
134
148
|
|
|
135
149
|
.tag-lime {
|
|
136
150
|
--tag-color: var(--color-green-7); // @presenter Color
|
|
137
151
|
--tag-bg-color: none; // @presenter Color
|
|
138
152
|
--tag-border-color: var(--color-green-7); // @presenter Color
|
|
153
|
+
--tag-close-button-bg-color-hover: var(--color-green-3); // @presenter Color
|
|
139
154
|
}
|
|
140
155
|
|
|
141
156
|
.tag-product {
|
|
142
157
|
--tag-color: var(--color-warm-grey-7); // @presenter Color
|
|
143
158
|
--tag-bg-color: transparent; // @presenter Color
|
|
144
159
|
--tag-border-color: var(--color-warm-grey-4); // @presenter Color
|
|
160
|
+
--tag-close-button-bg-color-hover: var(--color-warm-grey-3); // @presenter Color
|
|
145
161
|
}
|
|
146
162
|
|
|
147
163
|
/**
|
|
@@ -156,12 +172,28 @@ export const tag = css`
|
|
|
156
172
|
* @tokens Operation tag colors
|
|
157
173
|
*/
|
|
158
174
|
|
|
159
|
-
--tag-operation-color-delete: #
|
|
160
|
-
--tag-operation-color-
|
|
161
|
-
|
|
162
|
-
--tag-operation-color-
|
|
163
|
-
--tag-operation-color-
|
|
164
|
-
|
|
175
|
+
--tag-operation-color-delete: #e70b46; // @presenter Color
|
|
176
|
+
--tag-operation-bg-color-delete: #fee2e9; // @presenter Color
|
|
177
|
+
|
|
178
|
+
--tag-operation-color-get: #25b869; // @presenter Color
|
|
179
|
+
--tag-operation-bg-color-get: #e5faef; // @presenter Color
|
|
180
|
+
|
|
181
|
+
--tag-operation-color-post: #1e65f5; // @presenter Color
|
|
182
|
+
--tag-operation-bg-color-post: #e2ebfe; // @presenter Color
|
|
183
|
+
|
|
184
|
+
--tag-operation-color-put: #f5901d; // @presenter Color
|
|
185
|
+
--tag-operation-bg-color-put: #fef1e2; // @presenter Color
|
|
186
|
+
|
|
187
|
+
--tag-operation-color-patch: #f5c31d; // @presenter Color
|
|
188
|
+
--tag-operation-bg-color-patch: #fdf6dd; // @presenter Color
|
|
189
|
+
|
|
190
|
+
--tag-operation-color-head: #5b4ccc; // @presenter Color
|
|
191
|
+
--tag-operation-bg-color-head: #e6e1fe; // @presenter Color
|
|
192
|
+
|
|
193
|
+
--tag-operation-color-options: #1a1c21; // @presenter Color
|
|
194
|
+
--tag-operation-bg-color-options: #ededf2; // @presenter Color
|
|
195
|
+
|
|
196
|
+
--tag-operation-color-deprecated: var(--text-color-disabled); // @presenter Color
|
|
165
197
|
|
|
166
198
|
.tag-delete {
|
|
167
199
|
--tag-color: var(--tag-operation-color-delete); // @presenter Color
|
|
@@ -2,17 +2,11 @@ import * as React from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import type { Version } from '@redocly/config';
|
|
5
|
+
import type { SelectProps } from '@redocly/theme/core/types/select';
|
|
5
6
|
|
|
6
7
|
import { useThemeHooks, useThemeConfig } from '@redocly/theme/core/hooks';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
SelectInput,
|
|
10
|
-
SelectList,
|
|
11
|
-
SelectListItem,
|
|
12
|
-
type SelectProps,
|
|
13
|
-
} from '@redocly/theme/components/Select/Select';
|
|
14
|
-
|
|
15
|
-
export interface VersionPickerProps extends SelectProps {}
|
|
8
|
+
import { Select } from '@redocly/theme/components/Select/Select';
|
|
9
|
+
import { SelectInputWrapper } from '@redocly/theme/components/Select/SelectInput';
|
|
16
10
|
|
|
17
11
|
export function VersionPicker(props: { versions?: Version[]; onChange: (v: Version) => void }) {
|
|
18
12
|
const themeConfig = useThemeConfig();
|
|
@@ -22,19 +16,21 @@ export function VersionPicker(props: { versions?: Version[]; onChange: (v: Versi
|
|
|
22
16
|
const { translate } = useTranslate();
|
|
23
17
|
|
|
24
18
|
const { versions = [], onChange } = props;
|
|
25
|
-
const options = versions.map((version) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
19
|
+
const options = versions.map(({ label, version, active }) => ({
|
|
20
|
+
element: label || version,
|
|
21
|
+
value: version,
|
|
22
|
+
active: active,
|
|
23
|
+
}));
|
|
24
|
+
const value = options.find((item) => item.active)?.value;
|
|
32
25
|
|
|
33
26
|
if (versionPicker?.hide) {
|
|
34
27
|
return null;
|
|
35
28
|
}
|
|
36
29
|
|
|
37
|
-
const
|
|
30
|
+
const handleOnChange = (value: SelectProps['value']) => {
|
|
31
|
+
const selectedVersion = versions.find((v) => v.version === value);
|
|
32
|
+
onChange(selectedVersion as Version);
|
|
33
|
+
};
|
|
38
34
|
|
|
39
35
|
if (!options.length && !versionPicker?.showForUnversioned) return null;
|
|
40
36
|
|
|
@@ -48,7 +44,7 @@ export function VersionPicker(props: { versions?: Version[]; onChange: (v: Versi
|
|
|
48
44
|
disabled={!options.length}
|
|
49
45
|
options={options}
|
|
50
46
|
value={value}
|
|
51
|
-
onChange={
|
|
47
|
+
onChange={handleOnChange}
|
|
52
48
|
/>
|
|
53
49
|
</VersionsPickerWrapper>
|
|
54
50
|
);
|
|
@@ -71,32 +67,12 @@ export const VersionPickerSelect = styled(Select)<SelectProps>`
|
|
|
71
67
|
line-height: var(--version-picker-line-height);
|
|
72
68
|
color: var(--version-picker-text-color);
|
|
73
69
|
|
|
74
|
-
${
|
|
70
|
+
${SelectInputWrapper} {
|
|
75
71
|
border: var(--version-picker-input-border);
|
|
76
72
|
border-radius: var(--version-picker-input-border-radius);
|
|
77
73
|
padding: var(--version-picker-input-padding-vertical)
|
|
78
74
|
var(--version-picker-input-padding-horizontal);
|
|
79
75
|
}
|
|
80
|
-
|
|
81
|
-
${SelectList} {
|
|
82
|
-
right: 0;
|
|
83
|
-
width: 100%;
|
|
84
|
-
min-width: var(--version-picker-list-min-width);
|
|
85
|
-
max-width: var(--version-picker-list-max-width);
|
|
86
|
-
padding: var(--version-picker-list-padding);
|
|
87
|
-
background-color: var(--version-picker-list-bg-color);
|
|
88
|
-
border-radius: var(--version-picker-list-border-radius);
|
|
89
|
-
box-shadow: var(--version-picker-list-box-shadow);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
${SelectListItem} {
|
|
93
|
-
border-radius: var(--version-picker-list-item-border-radius);
|
|
94
|
-
|
|
95
|
-
& > * {
|
|
96
|
-
padding: var(--version-picker-list-item-vertical-padding)
|
|
97
|
-
var(--version-picker-list-item-horizontal-padding);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
76
|
`;
|
|
101
77
|
|
|
102
78
|
const VersionsPickerWrapper = styled.div`
|
|
@@ -4,6 +4,7 @@ export * from '@redocly/theme/core/hooks/__mocks__/use-mobile-menu';
|
|
|
4
4
|
export * from '@redocly/theme/core/hooks/__mocks__/use-controlled-state';
|
|
5
5
|
export * from '@redocly/theme/core/hooks/__mocks__/search/use-recent-searches';
|
|
6
6
|
export * from '@redocly/theme/core/hooks/__mocks__/search/use-suggested-pages';
|
|
7
|
+
export * from '@redocly/theme/core/hooks/__mocks__/search/use-search-filter';
|
|
7
8
|
export * from '@redocly/theme/core/hooks/menu/__mocks__/use-mobile-menu-items';
|
|
8
9
|
export * from '@redocly/theme/core/hooks/menu/use-collapse';
|
|
9
10
|
export * from '@redocly/theme/core/hooks/use-active-heading';
|
|
@@ -20,5 +21,5 @@ export * from '@redocly/theme/core/hooks/menu/use-menu-item-expanded';
|
|
|
20
21
|
export * from '@redocly/theme/core/hooks/menu/use-mobile-menu-levels';
|
|
21
22
|
export * from '@redocly/theme/core/hooks/feedback/use-report-dialog';
|
|
22
23
|
export * from '@redocly/theme/core/hooks/use-product-picker';
|
|
23
|
-
export * from '@redocly/theme/core/hooks/use-search';
|
|
24
|
+
export * from '@redocly/theme/core/hooks/search/use-search-dialog';
|
|
24
25
|
export * from '@redocly/theme/core/hooks/use-language-picker';
|
|
@@ -36,12 +36,17 @@ export const useThemeHooks = jest.fn(() => ({
|
|
|
36
36
|
})),
|
|
37
37
|
useCurrentProduct: jest.fn(),
|
|
38
38
|
useProducts: jest.fn(() => []),
|
|
39
|
-
|
|
39
|
+
useSearch: jest.fn(() => ({
|
|
40
40
|
query: jest.fn().mockReturnValue(''),
|
|
41
41
|
setQuery: jest.fn(),
|
|
42
42
|
items: [],
|
|
43
43
|
isLoading: false,
|
|
44
44
|
})),
|
|
45
|
+
useFacetQuery: jest.fn(() => ({
|
|
46
|
+
searchFacet: null,
|
|
47
|
+
setSearchFacet: jest.fn(),
|
|
48
|
+
setSearchFacetQuery: jest.fn(),
|
|
49
|
+
})),
|
|
45
50
|
useUserMenu: jest.fn(() => ({
|
|
46
51
|
userData: {
|
|
47
52
|
isAuthenticated: true,
|