@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.
Files changed (112) hide show
  1. package/lib/components/Dropdown/DropdownMenu.d.ts +2 -0
  2. package/lib/components/Dropdown/DropdownMenu.js +3 -1
  3. package/lib/components/Loaders/SpinnerLoader.d.ts +5 -0
  4. package/lib/components/Loaders/SpinnerLoader.js +32 -0
  5. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.d.ts +12 -0
  6. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.js +113 -0
  7. package/lib/components/Search/FilterFields/SearchFilterFieldTags.d.ts +10 -0
  8. package/lib/components/Search/FilterFields/SearchFilterFieldTags.js +37 -0
  9. package/lib/components/Search/Search.js +1 -1
  10. package/lib/components/Search/SearchDialog.js +109 -27
  11. package/lib/components/Search/SearchFilter.d.ts +11 -0
  12. package/lib/components/Search/SearchFilter.js +71 -0
  13. package/lib/components/Search/SearchFilterField.d.ts +11 -0
  14. package/lib/components/Search/SearchFilterField.js +43 -0
  15. package/lib/components/Search/SearchGroups.d.ts +9 -0
  16. package/lib/components/Search/SearchGroups.js +69 -0
  17. package/lib/components/Search/SearchHighlight.d.ts +1 -1
  18. package/lib/components/Search/SearchHighlight.js +28 -5
  19. package/lib/components/Search/SearchInput.d.ts +1 -1
  20. package/lib/components/Search/SearchInput.js +5 -2
  21. package/lib/components/Search/SearchItem.d.ts +2 -2
  22. package/lib/components/Search/SearchItem.js +24 -15
  23. package/lib/components/Search/variables.js +48 -2
  24. package/lib/components/Segmented/Segmented.d.ts +2 -5
  25. package/lib/components/Select/Select.d.ts +2 -36
  26. package/lib/components/Select/Select.js +136 -98
  27. package/lib/components/Select/SelectInput.d.ts +23 -0
  28. package/lib/components/Select/SelectInput.js +129 -0
  29. package/lib/components/Select/variables.js +12 -1
  30. package/lib/components/Tag/Tag.d.ts +4 -2
  31. package/lib/components/Tag/Tag.js +40 -4
  32. package/lib/components/Tag/variables.dark.js +20 -5
  33. package/lib/components/Tag/variables.js +49 -17
  34. package/lib/components/VersionPicker/VersionPicker.d.ts +2 -3
  35. package/lib/components/VersionPicker/VersionPicker.js +13 -30
  36. package/lib/core/hooks/__mocks__/index.d.ts +2 -1
  37. package/lib/core/hooks/__mocks__/index.js +2 -1
  38. package/lib/core/hooks/__mocks__/search/use-search-filter.d.ts +9 -0
  39. package/lib/core/hooks/__mocks__/search/use-search-filter.js +14 -0
  40. package/lib/core/hooks/__mocks__/use-theme-hooks.d.ts +6 -1
  41. package/lib/core/hooks/__mocks__/use-theme-hooks.js +6 -1
  42. package/lib/core/hooks/index.d.ts +2 -1
  43. package/lib/core/hooks/index.js +2 -1
  44. package/lib/core/hooks/search/use-recent-searches.js +2 -0
  45. package/lib/core/hooks/{use-search.d.ts → search/use-search-dialog.d.ts} +1 -1
  46. package/lib/core/hooks/{use-search.js → search/use-search-dialog.js} +5 -5
  47. package/lib/core/hooks/search/use-search-filter.d.ts +9 -0
  48. package/lib/core/hooks/search/use-search-filter.js +50 -0
  49. package/lib/core/types/hooks.d.ts +17 -4
  50. package/lib/core/types/index.d.ts +1 -1
  51. package/lib/core/types/index.js +1 -1
  52. package/lib/core/types/l10n.d.ts +1 -2
  53. package/lib/core/types/search.d.ts +42 -2
  54. package/lib/core/types/select.d.ts +31 -0
  55. package/lib/core/types/{select-option.js → select.js} +1 -1
  56. package/lib/core/utils/index.d.ts +1 -0
  57. package/lib/core/utils/index.js +1 -0
  58. package/lib/core/utils/text-trimmer.d.ts +1 -0
  59. package/lib/core/utils/text-trimmer.js +16 -0
  60. package/lib/icons/ResetIcon/ResetIcon.d.ts +9 -0
  61. package/lib/icons/ResetIcon/ResetIcon.js +22 -0
  62. package/lib/icons/SettingsIcon/SettingsIcon.d.ts +9 -0
  63. package/lib/icons/SettingsIcon/SettingsIcon.js +23 -0
  64. package/lib/index.d.ts +8 -1
  65. package/lib/index.js +8 -1
  66. package/lib/markdoc/components/Cards/Card.js +6 -6
  67. package/package.json +3 -3
  68. package/src/components/Dropdown/DropdownMenu.tsx +2 -1
  69. package/src/components/Filter/FilterSelect.tsx +3 -3
  70. package/src/components/Loaders/SpinnerLoader.tsx +31 -0
  71. package/src/components/Search/FilterFields/SearchFilterFieldSelect.tsx +135 -0
  72. package/src/components/Search/FilterFields/SearchFilterFieldTags.tsx +61 -0
  73. package/src/components/Search/Search.tsx +2 -2
  74. package/src/components/Search/SearchDialog.tsx +183 -41
  75. package/src/components/Search/SearchFilter.tsx +90 -0
  76. package/src/components/Search/SearchFilterField.tsx +84 -0
  77. package/src/components/Search/SearchGroups.tsx +81 -0
  78. package/src/components/Search/SearchHighlight.tsx +29 -2
  79. package/src/components/Search/SearchInput.tsx +9 -3
  80. package/src/components/Search/SearchItem.tsx +39 -24
  81. package/src/components/Search/variables.ts +48 -2
  82. package/src/components/Segmented/Segmented.tsx +2 -2
  83. package/src/components/Select/Select.tsx +208 -157
  84. package/src/components/Select/SelectInput.tsx +201 -0
  85. package/src/components/Select/variables.ts +12 -1
  86. package/src/components/Tag/Tag.tsx +57 -6
  87. package/src/components/Tag/variables.dark.ts +20 -5
  88. package/src/components/Tag/variables.ts +49 -17
  89. package/src/components/VersionPicker/VersionPicker.tsx +15 -39
  90. package/src/core/hooks/__mocks__/index.ts +2 -1
  91. package/src/core/hooks/__mocks__/search/use-search-filter.ts +10 -0
  92. package/src/core/hooks/__mocks__/use-theme-hooks.ts +6 -1
  93. package/src/core/hooks/index.ts +2 -1
  94. package/src/core/hooks/search/use-recent-searches.ts +3 -0
  95. package/src/core/hooks/{use-search.ts → search/use-search-dialog.ts} +1 -1
  96. package/src/core/hooks/search/use-search-filter.ts +57 -0
  97. package/src/core/types/hooks.ts +25 -4
  98. package/src/core/types/index.ts +1 -1
  99. package/src/core/types/l10n.ts +110 -38
  100. package/src/core/types/search.ts +53 -2
  101. package/src/core/types/select.ts +33 -0
  102. package/src/core/utils/index.ts +1 -0
  103. package/src/core/utils/text-trimmer.ts +7 -0
  104. package/src/icons/ResetIcon/ResetIcon.tsx +26 -0
  105. package/src/icons/SettingsIcon/SettingsIcon.tsx +30 -0
  106. package/src/index.ts +8 -1
  107. package/src/markdoc/components/Cards/Card.tsx +15 -15
  108. package/lib/core/types/select-option.d.ts +0 -4
  109. package/src/core/types/select-option.ts +0 -4
  110. /package/lib/components/{Loading → Loaders}/Loading.d.ts +0 -0
  111. /package/lib/components/{Loading → Loaders}/Loading.js +0 -0
  112. /package/src/components/{Loading → Loaders}/Loading.tsx +0 -0
@@ -26,60 +26,150 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.SelectListItem = exports.SelectList = exports.SelectInputValue = exports.SelectInput = exports.SelectContainer = exports.Select = void 0;
29
+ exports.SelectWrapper = exports.Select = void 0;
30
30
  const react_1 = __importStar(require("react"));
31
31
  const styled_components_1 = __importDefault(require("styled-components"));
32
- const hooks_1 = require("../../core/hooks");
33
- const ChevronDownIcon_1 = require("../../icons/ChevronDownIcon/ChevronDownIcon");
34
- const ChevronUpIcon_1 = require("../../icons/ChevronUpIcon/ChevronUpIcon");
35
32
  const CheckmarkIcon_1 = require("../../icons/CheckmarkIcon/CheckmarkIcon");
33
+ const SelectInput_1 = require("../../components/Select/SelectInput");
34
+ const Dropdown_1 = require("../../components/Dropdown/Dropdown");
35
+ const DropdownMenu_1 = require("../../components/Dropdown/DropdownMenu");
36
+ const DropdownMenuItem_1 = require("../../components/Dropdown/DropdownMenuItem");
37
+ const hooks_1 = require("../../core/hooks");
36
38
  function Select(props) {
37
- const { className, value, options, dataAttributes, withArrow = true, triggerEvent = 'click', onChange, placement, alignment, icon, onlyIcon, disabled, placeholder, hideCheckmarkIcon, renderInput, renderDivider, dataTestId = 'select', } = props;
38
- const containerRef = (0, react_1.useRef)(null);
39
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
40
- // const [selectedIdx, setSelectedIdx] = useState<React.ReactNode | string>(selected);
41
- const handleOpen = () => {
42
- setIsOpen(true);
39
+ const { className, value, options, dataAttributes, withArrow = true, triggerEvent = 'click', placement, alignment, icon, onlyIcon, disabled, placeholder, hideCheckmarkIcon, checkmarkIconPosition, dataTestId = 'select', multiple, searchable, clearable, footer, onChange, onSearch, renderInput, renderDivider, } = props;
40
+ const getSelectedOptionsFromPropsValue = () => {
41
+ const values = Array.isArray(value) ? value : [value];
42
+ return values
43
+ .map((value) => {
44
+ const selectedOption = options.find((option) => option.value === value);
45
+ return selectedOption || typeof value === 'string'
46
+ ? { value }
47
+ : value;
48
+ })
49
+ .filter((option) => !!option);
50
+ };
51
+ const [selectedOptions, setSelectedOptions] = (0, react_1.useState)(getSelectedOptionsFromPropsValue());
52
+ const selectRef = (0, react_1.useRef)(null);
53
+ const [searchValue, setSearchValue] = (0, react_1.useState)(null);
54
+ const [dropdownActive, setDropdownActive] = (0, react_1.useState)(false);
55
+ const [filteredOptions, setFilteredOptions] = (0, react_1.useState)(options);
56
+ const [stickyInputValue, setStickyInputValue] = (0, react_1.useState)(placeholder || '');
57
+ const inputId = (0, react_1.useId)();
58
+ (0, hooks_1.useOutsideClick)(selectRef, () => {
59
+ setDropdownActive(false);
60
+ });
61
+ (0, react_1.useEffect)(() => {
62
+ setFilteredOptions(options);
63
+ }, [options]);
64
+ (0, react_1.useEffect)(() => {
65
+ setSelectedOptions(getSelectedOptionsFromPropsValue());
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps
67
+ }, [multiple, value]);
68
+ (0, react_1.useEffect)(() => {
69
+ if (onSearch) {
70
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchValue);
71
+ }
72
+ else {
73
+ if (typeof searchValue === 'string') {
74
+ const filteredOptions = options.filter((option) => {
75
+ var _a, _b;
76
+ const valueForSearch = String((_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.value) !== null && _b !== void 0 ? _b : '');
77
+ return (!valueForSearch || valueForSearch.toLowerCase().indexOf(searchValue.toLowerCase()) > -1);
78
+ });
79
+ setFilteredOptions(filteredOptions);
80
+ }
81
+ else {
82
+ setFilteredOptions(options);
83
+ }
84
+ }
85
+ // eslint-disable-next-line react-hooks/exhaustive-deps
86
+ }, [searchValue]);
87
+ const selectHandler = (selectedOption) => {
88
+ const newSelectedOptions = multiple
89
+ ? isSelected(selectedOption)
90
+ ? selectedOptions.filter((option) => option.value !== selectedOption.value)
91
+ : [...selectedOptions, selectedOption]
92
+ : [selectedOption];
93
+ const newSelectedValues = newSelectedOptions.length
94
+ ? multiple
95
+ ? newSelectedOptions.map((o) => o.value)
96
+ : newSelectedOptions[0].value
97
+ : multiple
98
+ ? []
99
+ : '';
100
+ setSelectedOptions(newSelectedOptions);
101
+ onChange === null || onChange === void 0 ? void 0 : onChange(newSelectedValues);
102
+ setSearchValue(null);
103
+ setDropdownActive(false);
104
+ if (!multiple) {
105
+ setStickyInputValue('');
106
+ }
107
+ };
108
+ const searchHandler = (e) => {
109
+ const targetValue = e.target.value;
110
+ setSearchValue(targetValue);
111
+ setDropdownActive(true);
112
+ };
113
+ const clearHandler = (option) => {
114
+ if (option) {
115
+ selectHandler(option);
116
+ }
117
+ else {
118
+ if (!multiple) {
119
+ setStickyInputValue('');
120
+ }
121
+ setSelectedOptions([]);
122
+ onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? [] : '');
123
+ }
43
124
  };
44
- const handleClose = () => {
45
- setIsOpen(false);
125
+ const inputBlurHandler = (e) => {
126
+ var _a, _b;
127
+ const relatedTarget = e.relatedTarget;
128
+ const isDropdownItem = ((_a = relatedTarget === null || relatedTarget === void 0 ? void 0 : relatedTarget.attributes.getNamedItem('data-component-name')) === null || _a === void 0 ? void 0 : _a.value) ===
129
+ 'Dropdown/DropdownMenuItem';
130
+ if (!isDropdownItem) {
131
+ if (!e.relatedTarget || ((_b = e.relatedTarget) === null || _b === void 0 ? void 0 : _b.id) !== inputId) {
132
+ setDropdownActive(false);
133
+ }
134
+ setSearchValue(null);
135
+ setStickyInputValue('');
136
+ }
46
137
  };
47
- const handleToggle = () => {
48
- setIsOpen(!isOpen);
138
+ const inputFocusHandler = () => {
139
+ if (!multiple && selectedOptions.length) {
140
+ setStickyInputValue(selectedOptions[0].label || selectedOptions[0].value);
141
+ }
49
142
  };
50
- const handleSelect = (value) => {
51
- // setSelectedIdx(options.findIndex(o => o.value === value));
52
- setIsOpen(false);
53
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
143
+ const inputClickHandler = () => {
144
+ setDropdownActive(!dropdownActive);
54
145
  };
55
- (0, hooks_1.useOutsideClick)(containerRef, handleClose);
56
- // useEffect(() => {
57
- // handleSelect(selected);
58
- // // eslint-disable-next-line react-hooks/exhaustive-deps
59
- // }, [selected]);
60
- const selectedOption = options.find((option) => option.value === value);
61
- const renderDefaultInput = () => (react_1.default.createElement(exports.SelectInput, null,
62
- !onlyIcon && (react_1.default.createElement(exports.SelectInputValue, null, (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.element) || placeholder)),
63
- icon,
64
- withArrow ? isOpen ? react_1.default.createElement(ChevronUpIcon_1.ChevronUpIcon, { size: "14px" }) : react_1.default.createElement(ChevronDownIcon_1.ChevronDownIcon, { size: "14px" }) : null));
65
- return (react_1.default.createElement(exports.SelectContainer, Object.assign({ "data-component-name": "Select/Select" }, dataAttributes, { disabled: disabled, "data-testid": dataTestId, className: className, ref: containerRef, onPointerEnter: triggerEvent === 'hover' ? handleOpen : undefined, onPointerLeave: triggerEvent === 'hover' ? handleClose : undefined, onClick: triggerEvent === 'click' ? handleToggle : undefined }),
66
- renderInput ? renderInput({ isOpen }) : renderDefaultInput(),
67
- isOpen && (react_1.default.createElement(exports.SelectList, { placement: placement, alignment: alignment }, options.map((option, index) => {
68
- const selected = option.value === value;
69
- return (react_1.default.createElement(react_1.default.Fragment, null,
70
- react_1.default.createElement(exports.SelectListItem, { key: index, onClick: () => handleSelect(option.value), selected: selected },
71
- typeof option.element === 'string' ? (react_1.default.createElement("div", null, option.element)) : (option.element),
72
- !hideCheckmarkIcon && selected && react_1.default.createElement(CheckmarkIcon_1.CheckmarkIcon, null)),
73
- renderDivider && index !== options.length - 1 ? renderDivider() : null));
74
- })))));
146
+ const isSelected = (option) => {
147
+ return !!selectedOptions.find((selectOption) => selectOption.value === option.value || selectOption.value === option.label);
148
+ };
149
+ const renderDefaultInput = () => {
150
+ return (react_1.default.createElement(SelectInput_1.SelectInput, { id: inputId, selectedOptions: selectedOptions, searchValue: searchValue, placeholder: placeholder, stickyValue: stickyInputValue, multiple: multiple, searchable: searchable, clearable: clearable, customIcon: icon, onlyIcon: onlyIcon, clearHandler: clearHandler, searchHandler: searchHandler, inputBlurHandler: inputBlurHandler, inputFocusHandler: inputFocusHandler, clickHandler: inputClickHandler }));
151
+ };
152
+ return (react_1.default.createElement(exports.SelectWrapper, Object.assign({ "data-component-name": "Select/Select", ref: selectRef }, dataAttributes, { disabled: disabled, "data-testid": dataTestId, className: className }),
153
+ react_1.default.createElement(SelectDropdown, { closeOnClick: !multiple, withArrow: withArrow, trigger: renderInput ? renderInput() : renderDefaultInput(), triggerEvent: triggerEvent, placement: placement, alignment: alignment, active: !renderInput ? dropdownActive : undefined },
154
+ react_1.default.createElement(SelectDropdownMenu, { footer: footer }, filteredOptions.length === 0 ? (react_1.default.createElement(DropdownMenuItem_1.DropdownMenuItem, { disabled: true }, "No results")) : (filteredOptions.map((option, index) => {
155
+ return (react_1.default.createElement(react_1.Fragment, { key: index },
156
+ react_1.default.createElement(DropdownMenuItem_1.DropdownMenuItem, { onAction: () => selectHandler(option), prefix: !hideCheckmarkIcon &&
157
+ (checkmarkIconPosition ? checkmarkIconPosition === 'start' : false) &&
158
+ isSelected(option) && react_1.default.createElement(CheckmarkIcon_1.CheckmarkIcon, null), suffix: !hideCheckmarkIcon &&
159
+ (checkmarkIconPosition ? checkmarkIconPosition === 'end' : true) &&
160
+ isSelected(option) && react_1.default.createElement(CheckmarkIcon_1.CheckmarkIcon, null) }, typeof option.element === 'string' ? (react_1.default.createElement("div", null, option.element)) : (option.element)),
161
+ renderDivider && index !== options.length - 1 ? renderDivider() : null));
162
+ }) || 'No results')))));
75
163
  }
76
164
  exports.Select = Select;
77
- exports.SelectContainer = styled_components_1.default.div `
165
+ exports.SelectWrapper = styled_components_1.default.div `
166
+ display: flex;
78
167
  position: relative;
79
168
  font-size: var(--select-font-size);
80
169
  font-weight: var(--select-font-weight);
81
170
  line-height: var(--select-line-height);
82
171
  border-radius: var(--select-border-radius);
172
+ border: var(--select-border);
83
173
  color: var(--select-text-color);
84
174
  min-width: 0;
85
175
 
@@ -88,67 +178,15 @@ exports.SelectContainer = styled_components_1.default.div `
88
178
  opacity: 0.59;
89
179
  pointer-events: none;
90
180
  `}
91
- a {
92
- display: block;
93
- text-decoration: none;
94
- color: var(--select-text-color);
95
- }
96
181
  `;
97
- exports.SelectInput = styled_components_1.default.div `
98
- display: flex;
99
- align-items: center;
100
- justify-content: space-between;
101
- border-radius: var(--select-input-border-radius);
102
- padding: var(--select-input-padding);
103
- cursor: pointer;
104
- gap: 8px;
105
- `;
106
- exports.SelectInputValue = styled_components_1.default.div `
107
- pointer-events: none;
108
- min-width: 0;
109
- text-overflow: ellipsis;
110
- overflow: hidden;
111
- `;
112
- exports.SelectList = styled_components_1.default.ul `
113
- position: absolute;
114
- top: ${({ placement }) => (placement === 'top' ? 'auto' : '100%')};
115
- bottom: ${({ placement }) => (placement === 'top' ? '100%' : 'auto')};
116
- left: ${({ alignment }) => (alignment === 'start' ? '0' : 'auto')};
117
- right: ${({ alignment }) => (alignment === 'end' ? '0' : 'auto')};
118
- margin: 0;
119
- min-width: var(--select-list-min-width);
120
- max-width: var(--select-list-max-width);
121
- padding: var(--select-list-padding);
122
- background-color: var(--select-list-bg-color);
123
- border-radius: var(--select-list-border-radius);
124
- box-shadow: var(--select-list-box-shadow);
125
- list-style-type: none;
126
- cursor: pointer;
127
- white-space: nowrap;
128
- overflow: hidden;
129
- z-index: 1;
130
- `;
131
- exports.SelectListItem = styled_components_1.default.li `
132
- display: flex;
133
- align-items: center;
134
- justify-content: space-between;
135
- border-radius: var(--select-list-item-border-radius);
136
- gap: var(--select-list-item-gap);
137
- padding: var(--select-list-item-padding);
138
- ${({ selected }) => selected &&
139
- `
140
- font-weight: var(--select-list-item-font-weight-active);
141
- background-color: var(--select-list-item-bg-color-active);
142
- &:hover { background-color: var(--select-list-item-bg-color-active)};
143
- `}
144
-
145
- & > * {
146
- overflow: hidden;
147
- text-overflow: ellipsis;
148
- }
182
+ const SelectDropdown = (0, styled_components_1.default)(Dropdown_1.Dropdown) `
183
+ width: 100%;
149
184
 
150
- &:hover {
151
- background-color: var(--select-list-item-bg-color-hover);
185
+ > * {
186
+ width: 100%;
152
187
  }
153
188
  `;
189
+ const SelectDropdownMenu = (0, styled_components_1.default)(DropdownMenu_1.DropdownMenu) `
190
+ width: 100%;
191
+ `;
154
192
  //# sourceMappingURL=Select.js.map
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import type { SelectOption } from '../../core/types/select';
3
+ type SelectInputProps<T> = {
4
+ id?: string;
5
+ selectedOptions: SelectOption<T>[];
6
+ searchValue: any;
7
+ stickyValue: any;
8
+ onlyIcon?: boolean;
9
+ icon?: React.ReactNode;
10
+ customIcon?: React.ReactNode;
11
+ placeholder?: string;
12
+ multiple?: boolean;
13
+ searchable?: boolean;
14
+ clearable?: boolean;
15
+ clearHandler?: (value?: any) => void;
16
+ inputBlurHandler?: (e?: any) => void;
17
+ inputFocusHandler?: (e?: any) => void;
18
+ searchHandler?: (e?: any) => void;
19
+ clickHandler?: (e?: any) => void;
20
+ };
21
+ export declare function SelectInput<T>(props: SelectInputProps<T>): React.ReactNode;
22
+ export declare const SelectInputWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
23
+ export {};
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.SelectInputWrapper = exports.SelectInput = void 0;
30
+ const styled_components_1 = __importDefault(require("styled-components"));
31
+ const react_1 = __importStar(require("react"));
32
+ const Tag_1 = require("../../components/Tag/Tag");
33
+ const CloseIcon_1 = require("../../icons/CloseIcon/CloseIcon");
34
+ const Button_1 = require("../../components/Button/Button");
35
+ function SelectInput(props) {
36
+ const { id, onlyIcon, icon, customIcon, selectedOptions, placeholder, stickyValue, multiple, searchable, clearable, clearHandler, searchHandler, clickHandler, searchValue, inputBlurHandler, inputFocusHandler, } = props;
37
+ const inputRef = (0, react_1.useRef)(null);
38
+ const onChangeHandler = (e) => {
39
+ var _a;
40
+ searchHandler === null || searchHandler === void 0 ? void 0 : searchHandler(e);
41
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
42
+ };
43
+ const onKeyDownHandler = (e) => {
44
+ var _a;
45
+ e.stopPropagation();
46
+ if (e.key === 'Backspace' && !searchValue && selectedOptions.length) {
47
+ clearHandler === null || clearHandler === void 0 ? void 0 : clearHandler(selectedOptions[selectedOptions.length - 1]);
48
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
49
+ }
50
+ };
51
+ const onClickHandler = (e) => {
52
+ clickHandler === null || clickHandler === void 0 ? void 0 : clickHandler(e);
53
+ };
54
+ const onFocusHandler = (e) => {
55
+ var _a;
56
+ inputFocusHandler === null || inputFocusHandler === void 0 ? void 0 : inputFocusHandler(e);
57
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
58
+ };
59
+ const onBlurHandler = (e) => {
60
+ inputBlurHandler === null || inputBlurHandler === void 0 ? void 0 : inputBlurHandler(e);
61
+ };
62
+ const onClearAllHandler = (e) => {
63
+ e.stopPropagation();
64
+ clearHandler === null || clearHandler === void 0 ? void 0 : clearHandler();
65
+ };
66
+ const selectTags = selectedOptions.map((option, index) => (react_1.default.createElement(SelectInputTag, { closable: true, key: index, onClose: () => {
67
+ var _a;
68
+ clearHandler === null || clearHandler === void 0 ? void 0 : clearHandler(option);
69
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
70
+ } }, option.label || option.value || option.element)));
71
+ const selectInput = (react_1.default.createElement(SelectInternalInput, { value: searchValue ||
72
+ (!multiple && !stickyValue && selectedOptions.length
73
+ ? selectedOptions[0].label || selectedOptions[0].value
74
+ : ''), placeholder: searchValue || (multiple && selectedOptions.length) ? '' : stickyValue || placeholder, onChange: onChangeHandler, onKeyDown: onKeyDownHandler, onBlur: onBlurHandler, ref: inputRef, width: multiple ? (!searchValue && selectedOptions.length ? '10px' : 'auto') : '100%' }));
75
+ const simpleValue = selectedOptions.length ? (selectedOptions[0].label || selectedOptions[0].element || selectedOptions[0].value) : (react_1.default.createElement(SelectInternalInputPlaceholder, null, placeholder));
76
+ const multipleValues = selectedOptions.length ? (selectTags) : (react_1.default.createElement(SelectInternalInputPlaceholder, null, placeholder));
77
+ return (react_1.default.createElement(exports.SelectInputWrapper, Object.assign({}, props, { id: id, onFocus: onFocusHandler, onClick: onClickHandler }),
78
+ !onlyIcon && (react_1.default.createElement(react_1.default.Fragment, null,
79
+ react_1.default.createElement(SelectInputValue, null, multiple ? (searchable ? (react_1.default.createElement(react_1.default.Fragment, null,
80
+ selectTags,
81
+ selectInput)) : (multipleValues)) : searchable ? (selectInput) : (simpleValue)),
82
+ !!(clearable && selectedOptions.length) && (react_1.default.createElement(Button_1.Button, { size: "small", variant: "text", icon: react_1.default.createElement(CloseIcon_1.CloseIcon, null), onClick: onClearAllHandler })))),
83
+ customIcon || icon));
84
+ }
85
+ exports.SelectInput = SelectInput;
86
+ exports.SelectInputWrapper = styled_components_1.default.div `
87
+ width: 100%;
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: space-between;
91
+ border-radius: var(--select-input-border-radius);
92
+ padding: var(--select-input-padding);
93
+ cursor: pointer;
94
+ gap: var(--select-input-gap);
95
+ `;
96
+ const SelectInputValue = styled_components_1.default.div `
97
+ width: calc(100% - 20px);
98
+ display: flex;
99
+ min-width: 0;
100
+ text-overflow: ellipsis;
101
+ overflow: hidden;
102
+ flex-wrap: wrap;
103
+ gap: var(--select-input-value-gap);
104
+ `;
105
+ const SelectInputTag = (0, styled_components_1.default)(Tag_1.Tag) `
106
+ --tag-content-padding: 0;
107
+ `;
108
+ const SelectInternalInput = styled_components_1.default.input.attrs(() => ({
109
+ type: 'text',
110
+ })) `
111
+ outline: none;
112
+ border-radius: var(--select-input-border-radius);
113
+ border: none;
114
+ font-size: var(--select-input-font-size);
115
+ font-weight: var(--select-input-font-weight);
116
+ line-height: var(--select-input-line-height);
117
+ background-color: var(--select-input-bg-color);
118
+
119
+ &::placeholder {
120
+ color: var(--select-input-placeholder-color);
121
+ }
122
+
123
+ width: ${({ width }) => width || 'auto'};
124
+ `;
125
+ const SelectInternalInputPlaceholder = styled_components_1.default.div `
126
+ color: var(--select-input-placeholder-color);
127
+ padding-left: 8px;
128
+ `;
129
+ //# sourceMappingURL=SelectInput.js.map
@@ -11,10 +11,19 @@ exports.select = (0, styled_components_1.css) `
11
11
  --select-line-height: var(--line-height-base); // @presenter LineHeight
12
12
  --select-text-color: var(--text-color-secondary); // @presenter Color
13
13
  --select-border-radius: var(--border-radius); // @presenter BorderRadius
14
+ --select-border: var(--border-width) var(--border-style) var(--border-color-primary); // @presenter Border
15
+
14
16
  --select-input-padding-vertical: 6px; // @presenter Spacing
15
- --select-input-padding-horizontal: 16px; // @presenter Spacing
17
+ --select-input-padding-horizontal: 6px; // @presenter Spacing
16
18
  --select-input-padding: var(--select-input-padding-vertical) var(--select-input-padding-horizontal);
19
+ --select-input-gap: var(--spacing-xs); // @presenter Spacing
20
+ --select-input-value-gap: var(--spacing-unit); // @presenter Spacing
17
21
  --select-input-border-radius: var(--border-radius); // @presenter BorderRadius
22
+ --select-input-font-size: var(--font-size-base); // @presenter FontSize
23
+ --select-input-font-weight: var(--font-weight-regular); // @presenter FontWeight
24
+ --select-input-line-height: var(--line-height-base); // @presenter LineHeight
25
+ --select-input-bg-color: var(--bg-color); // @presenter Color
26
+ --select-input-placeholder-color: var(--input-content-placeholder-color); // @presenter Color
18
27
 
19
28
  --select-list-min-width: 100px;
20
29
  --select-list-max-width: 300px;
@@ -32,6 +41,8 @@ exports.select = (0, styled_components_1.css) `
32
41
  --select-list-item-bg-color-active: transparent; // @presenter Color
33
42
  --select-list-item-bg-color-hover: var(--menu-item-bg-color-hover); // @presenter Color
34
43
  --select-list-item-font-weight-active: var(--font-weight-medium); // @presenter Color
44
+
45
+ --select-placeholder-color: var(--color-warm-grey-6); // @presenter Color
35
46
  // @tokens End
36
47
  `;
37
48
  //# sourceMappingURL=variables.js.map
@@ -16,7 +16,9 @@ export type TagProps = {
16
16
  statusDotColor?: string;
17
17
  size?: string;
18
18
  icon?: React.ReactNode;
19
- onClick?: () => void;
19
+ active?: boolean;
20
+ onClick?: (event: React.MouseEvent) => void;
21
+ onClose?: (event: React.MouseEvent) => void;
20
22
  };
21
- export declare function Tag({ children, color, icon, onClick, size, borderless, withStatusDot, statusDotColor, ...otherProps }: TagProps): JSX.Element;
23
+ export declare function Tag({ children, color, icon, active, closable, onClick, onClose, size, borderless, withStatusDot, statusDotColor, ...otherProps }: TagProps): JSX.Element;
22
24
  export {};
@@ -17,14 +17,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Tag = void 0;
18
18
  const react_1 = __importDefault(require("react"));
19
19
  const styled_components_1 = __importDefault(require("styled-components"));
20
+ const CloseIcon_1 = require("../../icons/CloseIcon/CloseIcon");
21
+ const CheckmarkFilledIcon_1 = require("../../icons/CheckmarkFilledIcon/CheckmarkFilledIcon");
20
22
  function Tag(_a) {
21
- var { children, color, icon, onClick, size, borderless, withStatusDot, statusDotColor = 'var(--tag-status-dot-color-default)' } = _a, otherProps = __rest(_a, ["children", "color", "icon", "onClick", "size", "borderless", "withStatusDot", "statusDotColor"]);
22
- return (react_1.default.createElement(TagContainer, Object.assign({ "data-component-name": "Tag/Tag", borderless: borderless, color: color, size: size, onClick: onClick }, otherProps),
23
+ var { children, color, icon, active, closable, onClick, onClose, size, borderless, withStatusDot, statusDotColor = 'var(--tag-status-dot-color-default)' } = _a, otherProps = __rest(_a, ["children", "color", "icon", "active", "closable", "onClick", "onClose", "size", "borderless", "withStatusDot", "statusDotColor"]);
24
+ return (react_1.default.createElement(TagWrapper, Object.assign({ "data-component-name": "Tag/Tag", borderless: borderless, color: color, size: size, onClick: onClick, hasCloseButton: closable }, otherProps),
23
25
  withStatusDot ? react_1.default.createElement(StatusDot, { color: statusDotColor }) : icon ? icon : null,
24
- children));
26
+ react_1.default.createElement(ContentWrapper, null, children),
27
+ closable && (react_1.default.createElement(CloseButton, { onClick: (event) => {
28
+ onClose === null || onClose === void 0 ? void 0 : onClose(event);
29
+ } },
30
+ react_1.default.createElement(CloseIcon_1.CloseIcon, null))),
31
+ active && react_1.default.createElement(ActiveIcon, null)));
25
32
  }
26
33
  exports.Tag = Tag;
27
- const TagContainer = styled_components_1.default.div.attrs(({ className, color, size }) => ({
34
+ const ContentWrapper = styled_components_1.default.div `
35
+ display: inline-flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ text-wrap: nowrap;
39
+
40
+ padding: var(--tag-content-padding);
41
+ gap: var(--tag-content-gap);
42
+ `;
43
+ const CloseButton = styled_components_1.default.div `
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: center;
47
+ align-self: stretch;
48
+ border-radius: 0 var(--tag-border-radius) var(--tag-border-radius) 0;
49
+
50
+ &:hover {
51
+ background: var(--tag-close-button-bg-color-hover);
52
+ }
53
+ `;
54
+ const TagWrapper = styled_components_1.default.div.attrs(({ className, color, size }) => ({
28
55
  className: (className || '') +
29
56
  ` tag-default ${color ? `tag-${color}` : ''} ${size ? `tag-size-${size}` : ''}`,
30
57
  })) `
@@ -32,8 +59,10 @@ const TagContainer = styled_components_1.default.div.attrs(({ className, color,
32
59
  align-items: center;
33
60
  justify-content: center;
34
61
  text-wrap: nowrap;
62
+ position: relative;
35
63
 
36
64
  padding: var(--tag-padding);
65
+ ${({ hasCloseButton }) => (hasCloseButton ? 'padding-right: 0;' : '')};
37
66
  margin: var(--tag-margin);
38
67
 
39
68
  &:last-child {
@@ -64,4 +93,11 @@ const StatusDot = styled_components_1.default.div `
64
93
  border-radius: 50%;
65
94
  background-color: ${({ color }) => color};
66
95
  `;
96
+ const ActiveIcon = (0, styled_components_1.default)(CheckmarkFilledIcon_1.CheckmarkFilledIcon) `
97
+ width: 12px;
98
+ height: 12px;
99
+ position: absolute;
100
+ right: -4px;
101
+ top: -4px;
102
+ `;
67
103
  //# sourceMappingURL=Tag.js.map
@@ -3,11 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tagDarkMode = void 0;
4
4
  const styled_components_1 = require("styled-components");
5
5
  exports.tagDarkMode = (0, styled_components_1.css) `
6
- --tag-operation-color-delete: #fa82a2;
7
- --tag-operation-color-get: #68cc97;
8
- --tag-operation-color-post: #90b0f0;
9
- --tag-operation-color-put: #e0a663;
10
- --tag-operation-color-patch: #e0c363;
6
+ --tag-operation-color-delete: #fa82a2; // @presenter Color
7
+ --tag-operation-bg-color-delete: #77214C; // @presenter Color
8
+
9
+ --tag-operation-color-get: #68cc97; // @presenter Color
10
+ --tag-operation-bg-color-get: #1F4D2D; // @presenter Color
11
+
12
+ --tag-operation-color-post: #90b0f0; // @presenter Color
13
+ --tag-operation-bg-color-post: #233061; // @presenter Color
14
+
15
+ --tag-operation-color-put: #e0a663; // @presenter Color
16
+ --tag-operation-bg-color-put: #612729; // @presenter Color
17
+
18
+ --tag-operation-color-patch: #e0c363; // @presenter Color
19
+ --tag-operation-bg-color-patch: #5C3721; // @presenter Color
20
+
21
+ --tag-operation-color-head: #e6e1fe; // @presenter Color
22
+ --tag-operation-bg-color-head: #5b4ccc; // @presenter Color
23
+
24
+ --tag-operation-color-options: #1a1c21; // @presenter Color
25
+ --tag-operation-bg-color-options: #2a2b33; // @presenter Color
11
26
 
12
27
  .tag-grey,
13
28
  .tag-draft,