@redocly/theme 0.41.0-rc.4 → 0.42.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.
Files changed (141) hide show
  1. package/lib/components/CodeBlock/CodeBlockControls.js +2 -1
  2. package/lib/components/Dropdown/DropdownMenu.d.ts +0 -2
  3. package/lib/components/Dropdown/DropdownMenu.js +1 -3
  4. package/lib/components/Dropdown/DropdownMenuItem.js +3 -3
  5. package/lib/components/Search/Search.js +1 -1
  6. package/lib/components/Search/SearchDialog.js +26 -103
  7. package/lib/components/Search/SearchHighlight.d.ts +1 -1
  8. package/lib/components/Search/SearchHighlight.js +5 -28
  9. package/lib/components/Search/SearchInput.d.ts +2 -3
  10. package/lib/components/Search/SearchInput.js +3 -11
  11. package/lib/components/Search/SearchItem.d.ts +2 -2
  12. package/lib/components/Search/SearchItem.js +15 -23
  13. package/lib/components/Search/variables.js +2 -48
  14. package/lib/components/Segmented/Segmented.d.ts +5 -2
  15. package/lib/components/Select/Select.d.ts +36 -2
  16. package/lib/components/Select/Select.js +98 -134
  17. package/lib/components/Select/variables.js +1 -11
  18. package/lib/components/Tag/Tag.d.ts +2 -4
  19. package/lib/components/Tag/Tag.js +4 -40
  20. package/lib/components/Tag/variables.dark.js +5 -20
  21. package/lib/components/Tag/variables.js +17 -49
  22. package/lib/components/VersionPicker/VersionPicker.d.ts +3 -2
  23. package/lib/components/VersionPicker/VersionPicker.js +30 -13
  24. package/lib/core/hooks/__mocks__/index.d.ts +1 -1
  25. package/lib/core/hooks/__mocks__/index.js +1 -1
  26. package/lib/core/hooks/__mocks__/use-theme-hooks.d.ts +1 -1
  27. package/lib/core/hooks/__mocks__/use-theme-hooks.js +1 -1
  28. package/lib/core/hooks/index.d.ts +1 -2
  29. package/lib/core/hooks/index.js +1 -2
  30. package/lib/core/hooks/search/use-recent-searches.js +0 -2
  31. package/lib/core/hooks/{search/use-search-dialog.d.ts → use-search.d.ts} +1 -1
  32. package/lib/core/hooks/{search/use-search-dialog.js → use-search.js} +5 -5
  33. package/lib/core/styles/dark.js +2 -1
  34. package/lib/core/styles/global.js +2 -0
  35. package/lib/core/types/hooks.d.ts +4 -16
  36. package/lib/core/types/index.d.ts +1 -1
  37. package/lib/core/types/index.js +1 -1
  38. package/lib/core/types/l10n.d.ts +2 -1
  39. package/lib/core/types/search.d.ts +2 -43
  40. package/lib/core/types/select-option.d.ts +4 -0
  41. package/lib/core/types/{select.js → select-option.js} +1 -1
  42. package/lib/index.d.ts +1 -7
  43. package/lib/index.js +1 -7
  44. package/lib/markdoc/components/Cards/Card.d.ts +15 -0
  45. package/lib/markdoc/components/Cards/Card.js +166 -0
  46. package/lib/markdoc/components/Cards/CardIcon.d.ts +7 -0
  47. package/lib/markdoc/components/Cards/CardIcon.js +46 -0
  48. package/lib/markdoc/components/Cards/CardImage.d.ts +7 -0
  49. package/lib/markdoc/components/Cards/CardImage.js +21 -0
  50. package/lib/markdoc/components/Cards/Cards.d.ts +8 -0
  51. package/lib/markdoc/components/Cards/Cards.js +44 -0
  52. package/lib/markdoc/components/Cards/variables.d.ts +1 -0
  53. package/lib/markdoc/components/Cards/variables.dark.d.ts +1 -0
  54. package/lib/markdoc/components/Cards/variables.dark.js +27 -0
  55. package/lib/markdoc/components/Cards/variables.js +71 -0
  56. package/lib/markdoc/components/default.d.ts +4 -0
  57. package/lib/markdoc/components/default.js +4 -0
  58. package/lib/markdoc/default.d.ts +5 -1
  59. package/lib/markdoc/default.js +4 -0
  60. package/lib/markdoc/tags/card.d.ts +2 -0
  61. package/lib/markdoc/tags/card.js +56 -0
  62. package/lib/markdoc/tags/cards.d.ts +2 -0
  63. package/lib/markdoc/tags/cards.js +20 -0
  64. package/lib/markdoc/tags/types.d.ts +6 -2
  65. package/package.json +2 -2
  66. package/src/components/CodeBlock/CodeBlockControls.tsx +1 -1
  67. package/src/components/Dropdown/DropdownMenu.tsx +1 -2
  68. package/src/components/Dropdown/DropdownMenuItem.tsx +5 -5
  69. package/src/components/Filter/FilterSelect.tsx +3 -3
  70. package/src/components/Search/Search.tsx +2 -2
  71. package/src/components/Search/SearchDialog.tsx +42 -168
  72. package/src/components/Search/SearchHighlight.tsx +2 -29
  73. package/src/components/Search/SearchInput.tsx +3 -17
  74. package/src/components/Search/SearchItem.tsx +24 -38
  75. package/src/components/Search/variables.ts +2 -48
  76. package/src/components/Segmented/Segmented.tsx +2 -2
  77. package/src/components/Select/Select.tsx +157 -200
  78. package/src/components/Select/variables.ts +1 -11
  79. package/src/components/Tag/Tag.tsx +6 -57
  80. package/src/components/Tag/variables.dark.ts +5 -20
  81. package/src/components/Tag/variables.ts +17 -49
  82. package/src/components/VersionPicker/VersionPicker.tsx +39 -15
  83. package/src/core/hooks/__mocks__/index.ts +1 -1
  84. package/src/core/hooks/__mocks__/use-theme-hooks.ts +1 -1
  85. package/src/core/hooks/index.ts +1 -2
  86. package/src/core/hooks/search/use-recent-searches.ts +0 -3
  87. package/src/core/hooks/{search/use-search-dialog.ts → use-search.ts} +1 -1
  88. package/src/core/styles/dark.ts +2 -1
  89. package/src/core/styles/global.ts +2 -1
  90. package/src/core/types/hooks.ts +4 -24
  91. package/src/core/types/index.ts +1 -1
  92. package/src/core/types/l10n.ts +37 -7
  93. package/src/core/types/search.ts +2 -54
  94. package/src/core/types/select-option.ts +4 -0
  95. package/src/index.ts +1 -7
  96. package/src/markdoc/components/Cards/Card.tsx +232 -0
  97. package/src/markdoc/components/Cards/CardIcon.tsx +55 -0
  98. package/src/markdoc/components/Cards/CardImage.tsx +21 -0
  99. package/src/markdoc/components/Cards/Cards.tsx +35 -0
  100. package/src/markdoc/components/Cards/variables.dark.ts +24 -0
  101. package/src/markdoc/components/Cards/variables.ts +68 -0
  102. package/src/markdoc/components/default.ts +4 -0
  103. package/src/markdoc/default.ts +4 -0
  104. package/src/markdoc/tags/card.ts +55 -0
  105. package/src/markdoc/tags/cards.ts +18 -0
  106. package/src/markdoc/tags/types.ts +4 -2
  107. package/lib/components/Loaders/SpinnerLoader.d.ts +0 -5
  108. package/lib/components/Loaders/SpinnerLoader.js +0 -32
  109. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.d.ts +0 -12
  110. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.js +0 -113
  111. package/lib/components/Search/FilterFields/SearchFilterFieldTags.d.ts +0 -10
  112. package/lib/components/Search/FilterFields/SearchFilterFieldTags.js +0 -37
  113. package/lib/components/Search/SearchFilter.d.ts +0 -11
  114. package/lib/components/Search/SearchFilter.js +0 -71
  115. package/lib/components/Search/SearchFilterField.d.ts +0 -11
  116. package/lib/components/Search/SearchFilterField.js +0 -43
  117. package/lib/components/Search/SearchGroups.d.ts +0 -9
  118. package/lib/components/Search/SearchGroups.js +0 -69
  119. package/lib/components/Select/SelectInput.d.ts +0 -23
  120. package/lib/components/Select/SelectInput.js +0 -129
  121. package/lib/core/hooks/search/use-search-filter.d.ts +0 -9
  122. package/lib/core/hooks/search/use-search-filter.js +0 -50
  123. package/lib/core/types/select.d.ts +0 -30
  124. package/lib/icons/ResetIcon/ResetIcon.d.ts +0 -9
  125. package/lib/icons/ResetIcon/ResetIcon.js +0 -22
  126. package/lib/icons/SettingsIcon/SettingsIcon.d.ts +0 -9
  127. package/lib/icons/SettingsIcon/SettingsIcon.js +0 -23
  128. package/src/components/Loaders/SpinnerLoader.tsx +0 -31
  129. package/src/components/Search/FilterFields/SearchFilterFieldSelect.tsx +0 -134
  130. package/src/components/Search/FilterFields/SearchFilterFieldTags.tsx +0 -61
  131. package/src/components/Search/SearchFilter.tsx +0 -90
  132. package/src/components/Search/SearchFilterField.tsx +0 -84
  133. package/src/components/Search/SearchGroups.tsx +0 -80
  134. package/src/components/Select/SelectInput.tsx +0 -201
  135. package/src/core/hooks/search/use-search-filter.ts +0 -57
  136. package/src/core/types/select.ts +0 -32
  137. package/src/icons/ResetIcon/ResetIcon.tsx +0 -26
  138. package/src/icons/SettingsIcon/SettingsIcon.tsx +0 -30
  139. /package/lib/components/{Loaders → Loading}/Loading.d.ts +0 -0
  140. /package/lib/components/{Loaders → Loading}/Loading.js +0 -0
  141. /package/src/components/{Loaders → Loading}/Loading.tsx +0 -0
@@ -1,201 +0,0 @@
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
- `;
@@ -1,57 +0,0 @@
1
- import { useCallback, useState } from 'react';
2
-
3
- import type { SearchFilterItem } from '@redocly/theme/core/types';
4
-
5
- export function useSearchFilter(
6
- filter: SearchFilterItem[],
7
- setFilter: React.Dispatch<React.SetStateAction<SearchFilterItem[]>>,
8
- ) {
9
- const [isFilterOpen, setIsFilterOpen] = useState(false);
10
-
11
- const onFilterToggle = useCallback(() => {
12
- setIsFilterOpen(!isFilterOpen);
13
- }, [isFilterOpen]);
14
-
15
- const onFilterChange = (field: string, value: string | string[] | undefined, isTop?: boolean) => {
16
- const values = value ? (Array.isArray(value) ? value : [value]) : [];
17
-
18
- const _filter = [...filter];
19
- const fieldIndex = _filter.findIndex((filter) => filter.field === field);
20
- if (fieldIndex > -1) {
21
- // filter field already exists
22
- _filter[fieldIndex].values = values;
23
- } else {
24
- if (!values.length) return;
25
- _filter.push({ field, values, isTop });
26
- }
27
-
28
- setFilter(_filter.filter((item) => item.values.length));
29
- };
30
-
31
- const onFilterReset = () => {
32
- setFilter([]);
33
- };
34
-
35
- const onTopFacetsReset = () => {
36
- const _filter = [...filter];
37
- setFilter(_filter.filter((item) => !item.isTop));
38
- };
39
-
40
- const onFacetReset = (field: string) => {
41
- const _filter = [...filter];
42
- const fieldIndex = _filter.findIndex((filter) => filter.field === field);
43
- if (fieldIndex !== -1) {
44
- _filter[fieldIndex].values = [];
45
- }
46
- setFilter(_filter.filter((item) => item.values.length));
47
- };
48
-
49
- return {
50
- onFacetReset,
51
- onTopFacetsReset,
52
- onFilterChange,
53
- onFilterReset,
54
- onFilterToggle,
55
- isFilterOpen,
56
- };
57
- }
@@ -1,32 +0,0 @@
1
- import type React from 'react';
2
-
3
- export type SelectOption<T> = {
4
- value: T;
5
- element?: React.ReactNode | JSX.Element | string;
6
- label?: string;
7
- };
8
-
9
- export type SelectProps<T = any> = {
10
- value?: SelectOption<T> | SelectOption<T>[] | T | T[];
11
- options: SelectOption<T>[];
12
- multiple?: boolean;
13
- searchable?: boolean;
14
- clearable?: boolean;
15
- dataAttributes?: Record<string, string>;
16
- className?: string;
17
- withArrow?: boolean;
18
- triggerEvent?: 'click' | 'hover';
19
- placement?: 'top' | 'bottom';
20
- alignment?: 'start' | 'end';
21
- onlyIcon?: boolean;
22
- placeholder?: string;
23
- disabled?: boolean;
24
- hideCheckmarkIcon?: boolean;
25
- dataTestId?: string;
26
- icon?: React.ReactNode;
27
- footer?: React.ReactNode;
28
- onChange?: (value: T | T[]) => void;
29
- renderInput?: () => React.ReactElement;
30
- renderDivider?: () => React.ReactElement;
31
- onSearch?: (value: T | null) => void;
32
- };
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
-
4
- import type { IconProps } from '@redocly/theme/icons/types';
5
-
6
- import { getCssColorVariable } from '@redocly/theme/core/utils';
7
-
8
- const Icon = (props: IconProps) => (
9
- <svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
10
- <path
11
- d="M9 14C10.1867 14 11.3467 13.6481 12.3334 12.9888C13.3201 12.3295 14.0892 11.3925 14.5433 10.2961C14.9974 9.19975 15.1162 7.99335 14.8847 6.82946C14.6532 5.66558 14.0818 4.59648 13.2426 3.75736C12.4035 2.91825 11.3344 2.3468 10.1705 2.11529C9.00666 1.88378 7.80026 2.0026 6.7039 2.45673C5.60754 2.91085 4.67047 3.67989 4.01118 4.66658C3.35189 5.65328 3 6.81331 3 8V11.1L1.2 9.3L0.5 10L3.5 13L6.5 10L5.8 9.3L4 11.1V8C4 7.0111 4.29324 6.0444 4.84265 5.22215C5.39206 4.39991 6.17295 3.75904 7.08658 3.38061C8.00021 3.00217 9.00555 2.90315 9.97545 3.09608C10.9454 3.289 11.8363 3.76521 12.5355 4.46447C13.2348 5.16373 13.711 6.05465 13.9039 7.02455C14.0969 7.99446 13.9978 8.99979 13.6194 9.91342C13.241 10.8271 12.6001 11.6079 11.7779 12.1574C10.9556 12.7068 9.98891 13 9 13V14Z"
12
- fill="#1A1C21"
13
- />
14
- </svg>
15
- );
16
-
17
- export const ResetIcon = styled(Icon).attrs(() => ({
18
- 'data-component-name': 'icons/ResetIcon/ResetIcon',
19
- }))<IconProps>`
20
- path {
21
- fill: ${({ color }) => getCssColorVariable(color)};
22
- }
23
-
24
- height: ${({ size }) => size || '16px'};
25
- width: ${({ size }) => size || '16px'};
26
- `;
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
-
4
- import type { IconProps } from '@redocly/theme/icons/types';
5
-
6
- import { getCssColorVariable } from '@redocly/theme/core/utils';
7
-
8
- const Icon = (props: IconProps) => (
9
- <svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
10
- <path
11
- d="M15.875 2.5H13.5687C13.2875 1.20625 12.1625 0.25 10.8125 0.25C9.4625 0.25 8.3375 1.20625 8.05625 2.5H0.125V3.625H8.05625C8.3375 4.91875 9.4625 5.875 10.8125 5.875C12.1625 5.875 13.2875 4.91875 13.5687 3.625H15.875V2.5ZM10.8125 4.75C9.85625 4.75 9.125 4.01875 9.125 3.0625C9.125 2.10625 9.85625 1.375 10.8125 1.375C11.7688 1.375 12.5 2.10625 12.5 3.0625C12.5 4.01875 11.7688 4.75 10.8125 4.75Z"
12
- fill="#22242B"
13
- />
14
- <path
15
- d="M0.125 11.5H2.43125C2.7125 12.7937 3.8375 13.75 5.1875 13.75C6.5375 13.75 7.6625 12.7937 7.94375 11.5H15.875V10.375H7.94375C7.6625 9.08125 6.5375 8.125 5.1875 8.125C3.8375 8.125 2.7125 9.08125 2.43125 10.375H0.125V11.5ZM5.1875 9.25C6.14375 9.25 6.875 9.98125 6.875 10.9375C6.875 11.8938 6.14375 12.625 5.1875 12.625C4.23125 12.625 3.5 11.8938 3.5 10.9375C3.5 9.98125 4.23125 9.25 5.1875 9.25Z"
16
- fill="#22242B"
17
- />
18
- </svg>
19
- );
20
-
21
- export const SettingsIcon = styled(Icon).attrs(() => ({
22
- 'data-component-name': 'icons/SettingsIcon/SettingsIcon',
23
- }))<IconProps>`
24
- path {
25
- fill: ${({ color }) => getCssColorVariable(color)};
26
- }
27
-
28
- height: ${({ size }) => size || '16px'};
29
- width: ${({ size }) => size || '16px'};
30
- `;
File without changes
File without changes