@heymantle/litho 0.0.1
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/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/cjs/components/ActionList.js +267 -0
- package/dist/cjs/components/AnnouncementBar.js +73 -0
- package/dist/cjs/components/AppProvider.js +245 -0
- package/dist/cjs/components/Autocomplete.js +351 -0
- package/dist/cjs/components/Badge.js +234 -0
- package/dist/cjs/components/Banner.js +264 -0
- package/dist/cjs/components/Box.js +247 -0
- package/dist/cjs/components/Button.js +1018 -0
- package/dist/cjs/components/ButtonGroup.js +196 -0
- package/dist/cjs/components/Card.js +593 -0
- package/dist/cjs/components/Checkbox.js +175 -0
- package/dist/cjs/components/ChoiceList.js +160 -0
- package/dist/cjs/components/Collapsible.js +42 -0
- package/dist/cjs/components/ColorField.js +159 -0
- package/dist/cjs/components/ContextualSaveBar.js +53 -0
- package/dist/cjs/components/DatePicker.js +547 -0
- package/dist/cjs/components/Divider.js +50 -0
- package/dist/cjs/components/DropZone.js +547 -0
- package/dist/cjs/components/EmptyState.js +111 -0
- package/dist/cjs/components/Filters.js +874 -0
- package/dist/cjs/components/FooterHelp.js +48 -0
- package/dist/cjs/components/Form.js +44 -0
- package/dist/cjs/components/Frame.js +386 -0
- package/dist/cjs/components/FrameSaveBar.js +239 -0
- package/dist/cjs/components/Grid.js +151 -0
- package/dist/cjs/components/HorizontalStack.js +180 -0
- package/dist/cjs/components/Icon.js +346 -0
- package/dist/cjs/components/Image.js +191 -0
- package/dist/cjs/components/InlineError.js +57 -0
- package/dist/cjs/components/Label.js +78 -0
- package/dist/cjs/components/Layout.js +228 -0
- package/dist/cjs/components/LayoutSection.js +133 -0
- package/dist/cjs/components/Link.js +128 -0
- package/dist/cjs/components/List.js +69 -0
- package/dist/cjs/components/Listbox.js +211 -0
- package/dist/cjs/components/Loading.js +103 -0
- package/dist/cjs/components/Modal.js +449 -0
- package/dist/cjs/components/Navigation.js +331 -0
- package/dist/cjs/components/Page.js +529 -0
- package/dist/cjs/components/Pagination.js +109 -0
- package/dist/cjs/components/Pane.js +128 -0
- package/dist/cjs/components/Popover.js +365 -0
- package/dist/cjs/components/PopoverManager.js +34 -0
- package/dist/cjs/components/ProgressBar.js +124 -0
- package/dist/cjs/components/RadioButton.js +172 -0
- package/dist/cjs/components/RadioButtonCard.js +193 -0
- package/dist/cjs/components/RangeSlider.js +235 -0
- package/dist/cjs/components/ResourceList.js +105 -0
- package/dist/cjs/components/Select.js +300 -0
- package/dist/cjs/components/SkeletonText.js +130 -0
- package/dist/cjs/components/Spinner.js +72 -0
- package/dist/cjs/components/Table.js +1184 -0
- package/dist/cjs/components/Tabs.js +421 -0
- package/dist/cjs/components/Tag.js +165 -0
- package/dist/cjs/components/Text.js +274 -0
- package/dist/cjs/components/TextField.js +584 -0
- package/dist/cjs/components/Thumbnail.js +73 -0
- package/dist/cjs/components/TimePicker.js +23 -0
- package/dist/cjs/components/Tip.js +220 -0
- package/dist/cjs/components/Tooltip.js +431 -0
- package/dist/cjs/components/TopBar.js +210 -0
- package/dist/cjs/components/VerticalStack.js +161 -0
- package/dist/cjs/index.js +308 -0
- package/dist/cjs/styles/Table.js +591 -0
- package/dist/cjs/utilities/dates.js +339 -0
- package/dist/cjs/utilities/useIndexResourceState.js +175 -0
- package/dist/cjs/utilities/useMounted.js +67 -0
- package/dist/cjs/utilities/useTableScrollState.js +142 -0
- package/dist/esm/components/ActionList.js +216 -0
- package/dist/esm/components/AnnouncementBar.js +63 -0
- package/dist/esm/components/AppProvider.js +185 -0
- package/dist/esm/components/Autocomplete.js +300 -0
- package/dist/esm/components/Badge.js +225 -0
- package/dist/esm/components/Banner.js +254 -0
- package/dist/esm/components/Box.js +238 -0
- package/dist/esm/components/Button.js +967 -0
- package/dist/esm/components/ButtonGroup.js +137 -0
- package/dist/esm/components/Card.js +537 -0
- package/dist/esm/components/Checkbox.js +165 -0
- package/dist/esm/components/ChoiceList.js +145 -0
- package/dist/esm/components/Collapsible.js +32 -0
- package/dist/esm/components/ColorField.js +149 -0
- package/dist/esm/components/ContextualSaveBar.js +43 -0
- package/dist/esm/components/DatePicker.js +532 -0
- package/dist/esm/components/Divider.js +41 -0
- package/dist/esm/components/DropZone.js +537 -0
- package/dist/esm/components/EmptyState.js +101 -0
- package/dist/esm/components/Filters.js +823 -0
- package/dist/esm/components/FooterHelp.js +38 -0
- package/dist/esm/components/Form.js +35 -0
- package/dist/esm/components/Frame.js +376 -0
- package/dist/esm/components/FrameSaveBar.js +229 -0
- package/dist/esm/components/Grid.js +142 -0
- package/dist/esm/components/HorizontalStack.js +171 -0
- package/dist/esm/components/Icon.js +296 -0
- package/dist/esm/components/Image.js +141 -0
- package/dist/esm/components/InlineError.js +43 -0
- package/dist/esm/components/Label.js +63 -0
- package/dist/esm/components/Layout.js +164 -0
- package/dist/esm/components/LayoutSection.js +82 -0
- package/dist/esm/components/Link.js +119 -0
- package/dist/esm/components/List.js +61 -0
- package/dist/esm/components/Listbox.js +201 -0
- package/dist/esm/components/Loading.js +93 -0
- package/dist/esm/components/Modal.js +390 -0
- package/dist/esm/components/Navigation.js +321 -0
- package/dist/esm/components/Page.js +473 -0
- package/dist/esm/components/Pagination.js +99 -0
- package/dist/esm/components/Pane.js +118 -0
- package/dist/esm/components/Popover.js +350 -0
- package/dist/esm/components/PopoverManager.js +24 -0
- package/dist/esm/components/ProgressBar.js +114 -0
- package/dist/esm/components/RadioButton.js +157 -0
- package/dist/esm/components/RadioButtonCard.js +178 -0
- package/dist/esm/components/RangeSlider.js +225 -0
- package/dist/esm/components/ResourceList.js +95 -0
- package/dist/esm/components/Select.js +285 -0
- package/dist/esm/components/SkeletonText.js +120 -0
- package/dist/esm/components/Spinner.js +63 -0
- package/dist/esm/components/Table.js +1129 -0
- package/dist/esm/components/Tabs.js +366 -0
- package/dist/esm/components/Tag.js +151 -0
- package/dist/esm/components/Text.js +265 -0
- package/dist/esm/components/TextField.js +533 -0
- package/dist/esm/components/Thumbnail.js +63 -0
- package/dist/esm/components/TimePicker.js +13 -0
- package/dist/esm/components/Tip.js +169 -0
- package/dist/esm/components/Tooltip.js +380 -0
- package/dist/esm/components/TopBar.js +200 -0
- package/dist/esm/components/VerticalStack.js +152 -0
- package/dist/esm/index.js +61 -0
- package/dist/esm/styles/Table.js +581 -0
- package/dist/esm/utilities/dates.js +289 -0
- package/dist/esm/utilities/useIndexResourceState.js +158 -0
- package/dist/esm/utilities/useMounted.js +57 -0
- package/dist/esm/utilities/useTableScrollState.js +132 -0
- package/index.css +1137 -0
- package/package.json +53 -0
|
@@ -0,0 +1,823 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _array_without_holes(arr) {
|
|
11
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
+
}
|
|
13
|
+
function _define_property(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
function _iterable_to_array(iter) {
|
|
27
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
28
|
+
}
|
|
29
|
+
function _iterable_to_array_limit(arr, i) {
|
|
30
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
31
|
+
if (_i == null) return;
|
|
32
|
+
var _arr = [];
|
|
33
|
+
var _n = true;
|
|
34
|
+
var _d = false;
|
|
35
|
+
var _s, _e;
|
|
36
|
+
try {
|
|
37
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
38
|
+
_arr.push(_s.value);
|
|
39
|
+
if (i && _arr.length === i) break;
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
_d = true;
|
|
43
|
+
_e = err;
|
|
44
|
+
} finally{
|
|
45
|
+
try {
|
|
46
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
47
|
+
} finally{
|
|
48
|
+
if (_d) throw _e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return _arr;
|
|
52
|
+
}
|
|
53
|
+
function _non_iterable_rest() {
|
|
54
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
55
|
+
}
|
|
56
|
+
function _non_iterable_spread() {
|
|
57
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
58
|
+
}
|
|
59
|
+
function _object_spread(target) {
|
|
60
|
+
for(var i = 1; i < arguments.length; i++){
|
|
61
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
62
|
+
var ownKeys = Object.keys(source);
|
|
63
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
64
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
65
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
ownKeys.forEach(function(key) {
|
|
69
|
+
_define_property(target, key, source[key]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
function ownKeys(object, enumerableOnly) {
|
|
75
|
+
var keys = Object.keys(object);
|
|
76
|
+
if (Object.getOwnPropertySymbols) {
|
|
77
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
78
|
+
if (enumerableOnly) {
|
|
79
|
+
symbols = symbols.filter(function(sym) {
|
|
80
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
keys.push.apply(keys, symbols);
|
|
84
|
+
}
|
|
85
|
+
return keys;
|
|
86
|
+
}
|
|
87
|
+
function _object_spread_props(target, source) {
|
|
88
|
+
source = source != null ? source : {};
|
|
89
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
90
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
91
|
+
} else {
|
|
92
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
93
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return target;
|
|
97
|
+
}
|
|
98
|
+
function _sliced_to_array(arr, i) {
|
|
99
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
100
|
+
}
|
|
101
|
+
function _to_consumable_array(arr) {
|
|
102
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
103
|
+
}
|
|
104
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
105
|
+
if (!o) return;
|
|
106
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
107
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
108
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
109
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
110
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
111
|
+
}
|
|
112
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
113
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
114
|
+
import { tv } from "tailwind-variants";
|
|
115
|
+
import { ActionList, Button, Icon, Link, Popover, Text, TextField, Tooltip } from "../index.js";
|
|
116
|
+
import { CancelSmallMinor, CaretDownMinor, DeleteMinor, HorizontalDotsMinor, PlusMinor, SearchMajor, ChevronLeftMinor, ChevronRightMinor } from "@shopify/polaris-icons";
|
|
117
|
+
import { DarkModeContext } from "./AppProvider.js";
|
|
118
|
+
var styles = tv({
|
|
119
|
+
base: "Litho-Filters flex items-center",
|
|
120
|
+
variants: {
|
|
121
|
+
showTextField: {
|
|
122
|
+
true: "justify-between",
|
|
123
|
+
false: ""
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
var filterContainerStyles = tv({
|
|
128
|
+
base: "Litho-FiltersContainer flex flex-wrap gap-1.5 items-center",
|
|
129
|
+
variants: {
|
|
130
|
+
showTextField: {
|
|
131
|
+
true: "p-2",
|
|
132
|
+
false: ""
|
|
133
|
+
},
|
|
134
|
+
padded: {
|
|
135
|
+
true: "p-2",
|
|
136
|
+
false: ""
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Filters Component - A React component that manages filters for a given dataset.
|
|
142
|
+
* Includes functionality for visible filters, more filters, and a query field.
|
|
143
|
+
*
|
|
144
|
+
* @component
|
|
145
|
+
* @param {Object} props - The component props.
|
|
146
|
+
* @param {Array<{
|
|
147
|
+
* key: string,
|
|
148
|
+
* label: string,
|
|
149
|
+
* filter: React.ReactNode,
|
|
150
|
+
* shortcut?: boolean,
|
|
151
|
+
* promoted?: boolean,
|
|
152
|
+
* onRemove?: () => void
|
|
153
|
+
* }>} props.filters - The available filters to display.
|
|
154
|
+
* @param {Array<{
|
|
155
|
+
* key: string,
|
|
156
|
+
* label: string,
|
|
157
|
+
* onRemove?: () => void
|
|
158
|
+
* }>} props.appliedFilters - The currently applied filters.
|
|
159
|
+
* @param {Function} [props.onClearAll] - Callback for clearing all applied filters.
|
|
160
|
+
* @param {boolean} [props.showTextField=false] - Whether to show the query text field.
|
|
161
|
+
* @param {boolean} [props.textFieldSubdued=false] - Whether the text field should appear subdued.
|
|
162
|
+
* @param {boolean} [props.padded=false] - Whether to apply padding to the filters container.
|
|
163
|
+
* @param {string} [props.queryValue] - The current value of the query text field.
|
|
164
|
+
* @param {Function} [props.onQueryChange] - Callback for when the query text field value changes.
|
|
165
|
+
* @param {Function} [props.onQueryBlur] - Callback for when the query text field loses focus.
|
|
166
|
+
* @param {Function} [props.onQueryFocus] - Callback for when the query text field gains focus.
|
|
167
|
+
* @param {Function} [props.onQueryClear] - Callback for clearing the query text field.
|
|
168
|
+
* @param {string} [props.queryPlaceholder="Search"] - Placeholder text for the query text field.
|
|
169
|
+
* @param {boolean} [props.ignorePromotedFiltersWhenRemoving=true] - Whether to ignore promoted filters when clearing filters.
|
|
170
|
+
* @param {boolean} [props.disableQueryField=false] - Whether the query text field is disabled.
|
|
171
|
+
* @param {string} [props.className] - Additional class names for the component.
|
|
172
|
+
* @returns {JSX.Element|null} The Filters component or null if no filters are available.
|
|
173
|
+
*/ function Filters(props) {
|
|
174
|
+
var _filters_filter;
|
|
175
|
+
var _props_filters = props.filters, filters = _props_filters === void 0 ? [] : _props_filters, _props_appliedFilters = props.appliedFilters, appliedFilters = _props_appliedFilters === void 0 ? [] : _props_appliedFilters, onClearAll = props.onClearAll, _props_showTextField = props.showTextField, showTextField = _props_showTextField === void 0 ? false : _props_showTextField, _props_textFieldSubdued = props.textFieldSubdued, textFieldSubdued = _props_textFieldSubdued === void 0 ? false : _props_textFieldSubdued, _props_padded = props.padded, padded = _props_padded === void 0 ? false : _props_padded, queryValue = props.queryValue, onQueryChange = props.onQueryChange, onQueryBlur = props.onQueryBlur, onQueryFocus = props.onQueryFocus, onQueryClear = props.onQueryClear, _props_queryPlaceholder = props.queryPlaceholder, queryPlaceholder = _props_queryPlaceholder === void 0 ? "Search" : _props_queryPlaceholder, _props_ignorePromotedFiltersWhenRemoving = props.ignorePromotedFiltersWhenRemoving, ignorePromotedFiltersWhenRemoving = _props_ignorePromotedFiltersWhenRemoving === void 0 ? true : _props_ignorePromotedFiltersWhenRemoving, disableQueryField = props.disableQueryField, className = props.className;
|
|
176
|
+
var classes = styles({
|
|
177
|
+
showTextField: showTextField
|
|
178
|
+
});
|
|
179
|
+
var filterContainerClasses = filterContainerStyles({
|
|
180
|
+
showTextField: showTextField,
|
|
181
|
+
padded: padded
|
|
182
|
+
});
|
|
183
|
+
var _useState = _sliced_to_array(useState(""), 2), filterSearchValue = _useState[0], setFilterSearchValue = _useState[1];
|
|
184
|
+
var _useState1 = _sliced_to_array(useState(null), 2), activePopoverKey = _useState1[0], setActivePopoverKey = _useState1[1];
|
|
185
|
+
var _useState2 = _sliced_to_array(useState([]), 2), manuallyAddedFilters = _useState2[0], setManuallyAddedFilters = _useState2[1];
|
|
186
|
+
var visibleFilters = filters.filter(function(filter) {
|
|
187
|
+
if (manuallyAddedFilters.some(function(manuallyAddedFilter) {
|
|
188
|
+
return manuallyAddedFilter.key === filter.key;
|
|
189
|
+
})) return true;
|
|
190
|
+
if (filter.shortcut) return true;
|
|
191
|
+
if (appliedFilters.some(function(appliedFilter) {
|
|
192
|
+
return appliedFilter.key === filter.key || appliedFilter.key.startsWith("".concat(filter.key, "."));
|
|
193
|
+
})) return true;
|
|
194
|
+
return false;
|
|
195
|
+
}).sort(function(a, b) {
|
|
196
|
+
if (a.shortcut && !b.shortcut) return -1;
|
|
197
|
+
if (!a.shortcut && b.shortcut) return 1;
|
|
198
|
+
return 0;
|
|
199
|
+
});
|
|
200
|
+
var moreFilters = filters.filter(function(filter) {
|
|
201
|
+
var isVisible = visibleFilters.some(function(visibleFilter) {
|
|
202
|
+
return visibleFilter.key === filter.key;
|
|
203
|
+
});
|
|
204
|
+
return !isVisible && filter.label.toLowerCase().includes(filterSearchValue.toLowerCase());
|
|
205
|
+
});
|
|
206
|
+
if (filters.length === 0) return null;
|
|
207
|
+
var showMoreFilters = ((_filters_filter = filters.filter(function(f) {
|
|
208
|
+
return !visibleFilters.some(function(v) {
|
|
209
|
+
return v.key === f.key;
|
|
210
|
+
});
|
|
211
|
+
})) === null || _filters_filter === void 0 ? void 0 : _filters_filter.length) > 0;
|
|
212
|
+
var showClearAction = onClearAll && appliedFilters.length > 0;
|
|
213
|
+
if (ignorePromotedFiltersWhenRemoving) {
|
|
214
|
+
var promotedFilters = filters.filter(function(f) {
|
|
215
|
+
return f.promoted;
|
|
216
|
+
}).map(function(f) {
|
|
217
|
+
return f.key;
|
|
218
|
+
});
|
|
219
|
+
var appliedFiltersWithoutPromoted = appliedFilters.filter(function(f) {
|
|
220
|
+
return !promotedFilters.includes(f.key);
|
|
221
|
+
});
|
|
222
|
+
showClearAction = showClearAction && appliedFiltersWithoutPromoted.length > 0;
|
|
223
|
+
}
|
|
224
|
+
var popoverAlignment = showTextField ? "right" : "left";
|
|
225
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
226
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
227
|
+
children: [
|
|
228
|
+
showTextField && /*#__PURE__*/ _jsx("div", {
|
|
229
|
+
className: "flex-1",
|
|
230
|
+
children: /*#__PURE__*/ _jsx(Filters.TextField, {
|
|
231
|
+
subdued: textFieldSubdued,
|
|
232
|
+
queryValue: queryValue,
|
|
233
|
+
onQueryChange: onQueryChange,
|
|
234
|
+
onQueryBlur: onQueryBlur,
|
|
235
|
+
onQueryFocus: onQueryFocus,
|
|
236
|
+
onQueryClear: onQueryClear,
|
|
237
|
+
queryPlaceholder: queryPlaceholder,
|
|
238
|
+
disableQueryField: disableQueryField
|
|
239
|
+
})
|
|
240
|
+
}),
|
|
241
|
+
filters.length > 0 && /*#__PURE__*/ _jsxs("div", {
|
|
242
|
+
className: filterContainerClasses,
|
|
243
|
+
children: [
|
|
244
|
+
/*#__PURE__*/ _jsx("div", {
|
|
245
|
+
className: "flex items-center gap-1.5",
|
|
246
|
+
children: (visibleFilters === null || visibleFilters === void 0 ? void 0 : visibleFilters.length) > 0 && visibleFilters.map(function(filter, index) {
|
|
247
|
+
var _visibleFilters_;
|
|
248
|
+
var appliedFilter = appliedFilters.find(function(appliedFilter) {
|
|
249
|
+
return appliedFilter.key === filter.key || appliedFilter.key.startsWith("".concat(filter.key, "."));
|
|
250
|
+
});
|
|
251
|
+
var isApplied = !!appliedFilter;
|
|
252
|
+
var showDivider = index > 0 && ((_visibleFilters_ = visibleFilters[index - 1]) === null || _visibleFilters_ === void 0 ? void 0 : _visibleFilters_.promoted);
|
|
253
|
+
return /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
254
|
+
children: [
|
|
255
|
+
showDivider && /*#__PURE__*/ _jsx("div", {
|
|
256
|
+
className: "h-full min-h-3 disclosure-line mx-1"
|
|
257
|
+
}),
|
|
258
|
+
/*#__PURE__*/ _jsx(Popover, {
|
|
259
|
+
active: activePopoverKey === filter.key,
|
|
260
|
+
activatorDisplayType: "block",
|
|
261
|
+
onClose: function() {
|
|
262
|
+
return setActivePopoverKey(null);
|
|
263
|
+
},
|
|
264
|
+
preferredAlignment: popoverAlignment,
|
|
265
|
+
preferredPosition: "cover",
|
|
266
|
+
activator: /*#__PURE__*/ _jsx("div", {
|
|
267
|
+
children: /*#__PURE__*/ _jsx(Filters.Pill, {
|
|
268
|
+
label: isApplied ? appliedFilter.label : filter.label,
|
|
269
|
+
applied: isApplied,
|
|
270
|
+
onClick: function() {
|
|
271
|
+
return setActivePopoverKey(activePopoverKey === filter.key ? null : filter.key);
|
|
272
|
+
}
|
|
273
|
+
}, "filter-pill-".concat(filter.key))
|
|
274
|
+
}),
|
|
275
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
276
|
+
className: "flex flex-col gap-2 px-4 pt-2 pb-4 min-w-60",
|
|
277
|
+
children: [
|
|
278
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
279
|
+
className: "flex items-center justify-between",
|
|
280
|
+
children: [
|
|
281
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
282
|
+
variant: "headingSm",
|
|
283
|
+
fontWeight: "medium",
|
|
284
|
+
children: filter.label
|
|
285
|
+
}),
|
|
286
|
+
/*#__PURE__*/ _jsx("div", {
|
|
287
|
+
className: "relative -right-2",
|
|
288
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
289
|
+
plain: true,
|
|
290
|
+
size: "small",
|
|
291
|
+
icon: CancelSmallMinor,
|
|
292
|
+
onClick: function() {
|
|
293
|
+
return setActivePopoverKey(null);
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
})
|
|
297
|
+
]
|
|
298
|
+
}),
|
|
299
|
+
/*#__PURE__*/ _jsx("div", {
|
|
300
|
+
children: filter.filter
|
|
301
|
+
}, "filter-content-".concat(filter.key)),
|
|
302
|
+
((appliedFilter === null || appliedFilter === void 0 ? void 0 : appliedFilter.onRemove) || (filter === null || filter === void 0 ? void 0 : filter.onRemove)) && /*#__PURE__*/ _jsx("div", {
|
|
303
|
+
className: "pt-1",
|
|
304
|
+
children: /*#__PURE__*/ _jsx(Link, {
|
|
305
|
+
bold: true,
|
|
306
|
+
onClick: function() {
|
|
307
|
+
if (appliedFilter === null || appliedFilter === void 0 ? void 0 : appliedFilter.onRemove) {
|
|
308
|
+
appliedFilter.onRemove();
|
|
309
|
+
}
|
|
310
|
+
if (filter === null || filter === void 0 ? void 0 : filter.onRemove) {
|
|
311
|
+
filter.onRemove();
|
|
312
|
+
}
|
|
313
|
+
if (isApplied) {
|
|
314
|
+
setManuallyAddedFilters(function(currentManuallyAddedFilters) {
|
|
315
|
+
return currentManuallyAddedFilters.filter(function(f) {
|
|
316
|
+
return f.key !== appliedFilter.key;
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
setActivePopoverKey(null);
|
|
321
|
+
},
|
|
322
|
+
children: "Remove filter"
|
|
323
|
+
})
|
|
324
|
+
})
|
|
325
|
+
]
|
|
326
|
+
})
|
|
327
|
+
}, "filter-popover-".concat(filter.key))
|
|
328
|
+
]
|
|
329
|
+
}, "visible-filter-".concat(filter.key));
|
|
330
|
+
})
|
|
331
|
+
}),
|
|
332
|
+
/*#__PURE__*/ _jsx(_Fragment, {
|
|
333
|
+
children: (showMoreFilters || showClearAction) && /*#__PURE__*/ _jsxs("div", {
|
|
334
|
+
className: "flex gap-1.5",
|
|
335
|
+
children: [
|
|
336
|
+
showMoreFilters && /*#__PURE__*/ _jsx(Popover, {
|
|
337
|
+
active: activePopoverKey === "moreFilters",
|
|
338
|
+
activatorDisplayType: "block",
|
|
339
|
+
onClose: function() {
|
|
340
|
+
return setActivePopoverKey(null);
|
|
341
|
+
},
|
|
342
|
+
preferredAlignment: popoverAlignment,
|
|
343
|
+
preferredPosition: "below",
|
|
344
|
+
activator: /*#__PURE__*/ _jsx(Filters.Pill, {
|
|
345
|
+
label: visibleFilters.length > 0 ? "More filters" : "Filters",
|
|
346
|
+
onClick: function() {
|
|
347
|
+
return setActivePopoverKey("moreFilters");
|
|
348
|
+
}
|
|
349
|
+
}),
|
|
350
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
351
|
+
className: "max-h-75 overflow-auto",
|
|
352
|
+
children: [
|
|
353
|
+
/*#__PURE__*/ _jsx("div", {
|
|
354
|
+
className: "p-2 pb-0 sticky top-0 bg-surface-highest",
|
|
355
|
+
children: /*#__PURE__*/ _jsx(TextField, {
|
|
356
|
+
value: filterSearchValue,
|
|
357
|
+
onChange: function(value) {
|
|
358
|
+
return setFilterSearchValue(value);
|
|
359
|
+
},
|
|
360
|
+
placeholder: "Search",
|
|
361
|
+
autoFocus: true,
|
|
362
|
+
clearButton: true,
|
|
363
|
+
onClearButtonClick: function() {
|
|
364
|
+
return setFilterSearchValue("");
|
|
365
|
+
}
|
|
366
|
+
})
|
|
367
|
+
}),
|
|
368
|
+
/*#__PURE__*/ _jsx(ActionList, {
|
|
369
|
+
items: moreFilters.map(function(filter) {
|
|
370
|
+
return {
|
|
371
|
+
content: filter.label,
|
|
372
|
+
onAction: function() {
|
|
373
|
+
setFilterSearchValue("");
|
|
374
|
+
setManuallyAddedFilters(function(currentManuallyAddedFilters) {
|
|
375
|
+
return _to_consumable_array(currentManuallyAddedFilters).concat([
|
|
376
|
+
filter
|
|
377
|
+
]);
|
|
378
|
+
});
|
|
379
|
+
setActivePopoverKey(filter.key);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
]
|
|
385
|
+
})
|
|
386
|
+
}),
|
|
387
|
+
showClearAction && /*#__PURE__*/ _jsx(Filters.Pill, {
|
|
388
|
+
destructive: true,
|
|
389
|
+
onClick: onClearAll
|
|
390
|
+
})
|
|
391
|
+
]
|
|
392
|
+
})
|
|
393
|
+
})
|
|
394
|
+
]
|
|
395
|
+
})
|
|
396
|
+
]
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
var pillStyles = tv({
|
|
400
|
+
base: "Litho-Filters-Pill flex items-center justify-center rounded-full h-6.5 truncate font-medium text-sm border",
|
|
401
|
+
variants: {
|
|
402
|
+
disabled: {
|
|
403
|
+
true: "opacity-50 cursor-not-allowed",
|
|
404
|
+
false: "cursor-pointer"
|
|
405
|
+
},
|
|
406
|
+
applied: {
|
|
407
|
+
true: "",
|
|
408
|
+
false: ""
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
compoundVariants: [
|
|
412
|
+
{
|
|
413
|
+
destructive: true,
|
|
414
|
+
class: "px-1"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
destructive: false,
|
|
418
|
+
applied: true,
|
|
419
|
+
class: "bg-surface-highest text-highest pl-2.5 pr-1"
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
destructive: false,
|
|
423
|
+
applied: false,
|
|
424
|
+
class: "pl-1 pr-2.5 border-dashed bg-surface-normal hover:bg-surface-lower dark:border-edge-alt-subdued"
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
});
|
|
428
|
+
var pillTextStyles = tv({
|
|
429
|
+
base: "leading-5",
|
|
430
|
+
variants: {
|
|
431
|
+
applied: {
|
|
432
|
+
true: "text-high",
|
|
433
|
+
false: "text-normal"
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
/**
|
|
438
|
+
* Filters.Pill - A subcomponent for rendering filter pills.
|
|
439
|
+
*
|
|
440
|
+
* @component
|
|
441
|
+
* @param {Object} props - The component props.
|
|
442
|
+
* @param {string} props.label - The label of the filter pill.
|
|
443
|
+
* @param {boolean} [props.applied=false] - Whether the pill represents an applied filter.
|
|
444
|
+
* @param {boolean} [props.disabled=false] - Whether the pill is disabled.
|
|
445
|
+
* @param {boolean} [props.destructive=false] - Whether the pill represents a destructive action (e.g., remove filters).
|
|
446
|
+
* @param {Function} [props.onClick] - Callback when the pill is clicked.
|
|
447
|
+
* @returns {JSX.Element} The filter pill component.
|
|
448
|
+
*/ Filters.Pill = function FiltersPill() {
|
|
449
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
450
|
+
var label = props.label, _props_applied = props.applied, applied = _props_applied === void 0 ? false : _props_applied, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, _props_destructive = props.destructive, destructive = _props_destructive === void 0 ? false : _props_destructive, onClick = props.onClick;
|
|
451
|
+
var classes = pillStyles({
|
|
452
|
+
applied: applied,
|
|
453
|
+
disabled: disabled,
|
|
454
|
+
destructive: destructive
|
|
455
|
+
});
|
|
456
|
+
var textClasses = pillTextStyles({
|
|
457
|
+
applied: applied
|
|
458
|
+
});
|
|
459
|
+
var content = /*#__PURE__*/ _jsx("div", {
|
|
460
|
+
className: classes,
|
|
461
|
+
onClick: onClick,
|
|
462
|
+
children: destructive ? /*#__PURE__*/ _jsx(Icon, {
|
|
463
|
+
source: DeleteMinor,
|
|
464
|
+
color: "subdued"
|
|
465
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
466
|
+
children: [
|
|
467
|
+
!applied && /*#__PURE__*/ _jsx(Icon, {
|
|
468
|
+
source: PlusMinor,
|
|
469
|
+
color: "subdued"
|
|
470
|
+
}),
|
|
471
|
+
label && /*#__PURE__*/ _jsx("span", {
|
|
472
|
+
className: textClasses,
|
|
473
|
+
children: label
|
|
474
|
+
}),
|
|
475
|
+
applied && /*#__PURE__*/ _jsx(Icon, {
|
|
476
|
+
source: CaretDownMinor,
|
|
477
|
+
color: "subdued"
|
|
478
|
+
})
|
|
479
|
+
]
|
|
480
|
+
})
|
|
481
|
+
});
|
|
482
|
+
if (destructive) {
|
|
483
|
+
return /*#__PURE__*/ _jsx(Tooltip, {
|
|
484
|
+
content: "Remove filters",
|
|
485
|
+
preferredPosition: "above",
|
|
486
|
+
children: content
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
return content;
|
|
490
|
+
};
|
|
491
|
+
Filters.Pill.displayName = "Filters.Pill";
|
|
492
|
+
var tabsStyles = tv({
|
|
493
|
+
base: "Litho-FilterTabs relative"
|
|
494
|
+
});
|
|
495
|
+
var leftGradientStyles = tv({
|
|
496
|
+
base: "pointer-events-none absolute flex items-center justify-center top-0 left-0 h-full bg-linear-to-r from-surface-normal to-transparent transition-opacity duration-150",
|
|
497
|
+
variants: {
|
|
498
|
+
canScrollLeft: {
|
|
499
|
+
true: "opacity-100",
|
|
500
|
+
false: "opacity-0 pointer-events-none"
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
var rightGradientStyles = tv({
|
|
505
|
+
base: "pointer-events-none absolute flex items-center justify-center top-0 right-0 h-full bg-linear-to-l from-surface-normal to-transparent transition-opacity duration-150",
|
|
506
|
+
variants: {
|
|
507
|
+
canScrollRight: {
|
|
508
|
+
true: "opacity-100",
|
|
509
|
+
false: "opacity-0 pointer-events-none"
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
/**
|
|
514
|
+
* Filters.Tabs - A subcomponent for managing tabs with scrollable functionality.
|
|
515
|
+
*
|
|
516
|
+
* @component
|
|
517
|
+
* @param {Object} props - The component props.
|
|
518
|
+
* @param {Array} props.tabs - The tabs to display.
|
|
519
|
+
* @param {Object} [props.insertBeforeTabs] - Tab to insert before the main tabs.
|
|
520
|
+
* @param {number} props.selected - The index of the selected tab.
|
|
521
|
+
* @param {Function} props.onSelect - Callback when a tab is selected.
|
|
522
|
+
* @returns {JSX.Element} The tabs component.
|
|
523
|
+
*/ Filters.Tabs = function FiltersTabs() {
|
|
524
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
525
|
+
var tabs = props.tabs, insertBeforeTabs = props.insertBeforeTabs, selected = props.selected, onSelect = props.onSelect;
|
|
526
|
+
var containerRef = useRef(null);
|
|
527
|
+
var _useState = _sliced_to_array(useState(false), 2), canScrollLeft = _useState[0], setCanScrollLeft = _useState[1];
|
|
528
|
+
var _useState1 = _sliced_to_array(useState(false), 2), canScrollRight = _useState1[0], setCanScrollRight = _useState1[1];
|
|
529
|
+
var classes = tabsStyles();
|
|
530
|
+
var leftGradientClasses = leftGradientStyles({
|
|
531
|
+
canScrollLeft: canScrollLeft
|
|
532
|
+
});
|
|
533
|
+
var rightGradientClasses = rightGradientStyles({
|
|
534
|
+
canScrollRight: canScrollRight
|
|
535
|
+
});
|
|
536
|
+
useEffect(function() {
|
|
537
|
+
var _containerRef_current;
|
|
538
|
+
var checkOverflow = function() {
|
|
539
|
+
if (containerRef.current) {
|
|
540
|
+
var _containerRef_current = containerRef.current, scrollWidth = _containerRef_current.scrollWidth, clientWidth = _containerRef_current.clientWidth;
|
|
541
|
+
setCanScrollRight(scrollWidth > clientWidth);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
var checkScrollPosition = function() {
|
|
545
|
+
if (containerRef.current) {
|
|
546
|
+
var _containerRef_current = containerRef.current, scrollWidth = _containerRef_current.scrollWidth, scrollLeft = _containerRef_current.scrollLeft, clientWidth = _containerRef_current.clientWidth;
|
|
547
|
+
setCanScrollLeft(scrollLeft > 0);
|
|
548
|
+
setCanScrollRight(scrollLeft + clientWidth < scrollWidth);
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
checkOverflow();
|
|
552
|
+
checkScrollPosition();
|
|
553
|
+
(_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.addEventListener("scroll", checkScrollPosition);
|
|
554
|
+
window.addEventListener("resize", checkOverflow);
|
|
555
|
+
return function() {
|
|
556
|
+
var _containerRef_current;
|
|
557
|
+
window.removeEventListener("resize", checkOverflow);
|
|
558
|
+
(_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.removeEventListener("scroll", checkScrollPosition);
|
|
559
|
+
};
|
|
560
|
+
}, []);
|
|
561
|
+
var scrollToSelectedTab = function() {
|
|
562
|
+
if (containerRef.current && selected !== undefined) {
|
|
563
|
+
var selectedTab = containerRef.current.children[selected];
|
|
564
|
+
if (selectedTab) {
|
|
565
|
+
var offsetLeft = selectedTab.offsetLeft, offsetWidth = selectedTab.offsetWidth;
|
|
566
|
+
var clientWidth = containerRef.current.clientWidth;
|
|
567
|
+
var targetScrollLeft = offsetLeft + offsetWidth / 2 - clientWidth / 2;
|
|
568
|
+
containerRef.current.scrollTo({
|
|
569
|
+
left: targetScrollLeft,
|
|
570
|
+
behavior: "smooth"
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
useEffect(function() {
|
|
576
|
+
if (!canScrollLeft && !canScrollRight) return;
|
|
577
|
+
scrollToSelectedTab();
|
|
578
|
+
}, [
|
|
579
|
+
selected
|
|
580
|
+
]);
|
|
581
|
+
var handleScroll = function(direction) {
|
|
582
|
+
if (!containerRef.current) return;
|
|
583
|
+
var _containerRef_current = containerRef.current, scrollLeft = _containerRef_current.scrollLeft, offsetWidth = _containerRef_current.offsetWidth;
|
|
584
|
+
var children = Array.from(containerRef.current.children);
|
|
585
|
+
var overlayOffset = 44;
|
|
586
|
+
var visibleStart = scrollLeft + overlayOffset;
|
|
587
|
+
var visibleEnd = scrollLeft + offsetWidth - overlayOffset;
|
|
588
|
+
var targetIndex = -1;
|
|
589
|
+
if (direction === "left") {
|
|
590
|
+
var reversedChildren = _to_consumable_array(children).reverse();
|
|
591
|
+
for(var i = 0; i < reversedChildren.length; i++){
|
|
592
|
+
var child = reversedChildren[i];
|
|
593
|
+
var childStart = child.offsetLeft;
|
|
594
|
+
var childEnd = child.offsetLeft + child.offsetWidth;
|
|
595
|
+
if (childEnd > visibleStart && childStart < visibleStart) {
|
|
596
|
+
targetIndex = children.length - 1 - i;
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
} else {
|
|
601
|
+
for(var i1 = 0; i1 < children.length; i1++){
|
|
602
|
+
var child1 = children[i1];
|
|
603
|
+
var childStart1 = child1.offsetLeft;
|
|
604
|
+
var childEnd1 = child1.offsetLeft + child1.offsetWidth;
|
|
605
|
+
if (childStart1 < visibleEnd && childEnd1 > visibleEnd) {
|
|
606
|
+
targetIndex = i1;
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
if (targetIndex === -1) {
|
|
612
|
+
targetIndex = direction === "left" ? 0 : children.length - 1;
|
|
613
|
+
}
|
|
614
|
+
containerRef.current.scrollTo({
|
|
615
|
+
left: children[targetIndex].offsetLeft - overlayOffset,
|
|
616
|
+
behavior: "smooth"
|
|
617
|
+
});
|
|
618
|
+
};
|
|
619
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
620
|
+
className: classes,
|
|
621
|
+
children: [
|
|
622
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
623
|
+
ref: containerRef,
|
|
624
|
+
className: "flex w-full gap-1.5 p-px overflow-x-auto no-scrollbar",
|
|
625
|
+
children: [
|
|
626
|
+
insertBeforeTabs && /*#__PURE__*/ _jsx(Filters.Tab, _object_spread_props(_object_spread({}, insertBeforeTabs), {
|
|
627
|
+
selected: true,
|
|
628
|
+
onClick: function() {
|
|
629
|
+
var _insertBeforeTabs_onAction;
|
|
630
|
+
(_insertBeforeTabs_onAction = insertBeforeTabs.onAction) === null || _insertBeforeTabs_onAction === void 0 ? void 0 : _insertBeforeTabs_onAction.call(insertBeforeTabs);
|
|
631
|
+
}
|
|
632
|
+
}), insertBeforeTabs.id),
|
|
633
|
+
tabs.map(function(tab, index) {
|
|
634
|
+
return /*#__PURE__*/ _jsx(Filters.Tab, _object_spread_props(_object_spread({}, tab), {
|
|
635
|
+
index: index,
|
|
636
|
+
selected: parseInt(selected) === index,
|
|
637
|
+
onClick: function() {
|
|
638
|
+
return onSelect(index);
|
|
639
|
+
}
|
|
640
|
+
}), tab.id);
|
|
641
|
+
})
|
|
642
|
+
]
|
|
643
|
+
}),
|
|
644
|
+
/*#__PURE__*/ _jsx("div", {
|
|
645
|
+
className: leftGradientClasses,
|
|
646
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
647
|
+
rounded: true,
|
|
648
|
+
shadow: true,
|
|
649
|
+
icon: ChevronLeftMinor,
|
|
650
|
+
className: "relative -left-2 @md:left-0 ".concat(canScrollLeft ? "pointer-events-auto" : "pointer-events-none"),
|
|
651
|
+
onClick: function() {
|
|
652
|
+
return handleScroll("left");
|
|
653
|
+
}
|
|
654
|
+
})
|
|
655
|
+
}),
|
|
656
|
+
/*#__PURE__*/ _jsx("div", {
|
|
657
|
+
className: rightGradientClasses,
|
|
658
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
659
|
+
rounded: true,
|
|
660
|
+
shadow: true,
|
|
661
|
+
icon: ChevronRightMinor,
|
|
662
|
+
className: "relative -right-2 @md:right-0 ".concat(canScrollRight ? "pointer-events-auto" : "pointer-events-none"),
|
|
663
|
+
onClick: function() {
|
|
664
|
+
return handleScroll("right");
|
|
665
|
+
}
|
|
666
|
+
})
|
|
667
|
+
})
|
|
668
|
+
]
|
|
669
|
+
});
|
|
670
|
+
};
|
|
671
|
+
Filters.Tabs.displayName = "Filters.Tabs";
|
|
672
|
+
var tabStyles = tv({
|
|
673
|
+
base: "Litho-FilterTabs-Tab group cursor-pointer flex shrink-0 items-start justify-center rounded-md px-2 py-1 truncate font-medium text-sm",
|
|
674
|
+
variants: {
|
|
675
|
+
selected: {
|
|
676
|
+
true: "shadow-card bg-surface-highest outline outline-tint-1",
|
|
677
|
+
false: "bg-transparent hover-dark outline outline-tint-3 dark:outline-tint-alt-2"
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
var tabActionStyles = tv({
|
|
682
|
+
base: "Litho-FilterTabs-TabAction h-5 w-5 rounded-sm flex items-center justify-end",
|
|
683
|
+
variants: {
|
|
684
|
+
selected: {
|
|
685
|
+
true: "",
|
|
686
|
+
false: "opacity-0 pointer-events-none"
|
|
687
|
+
},
|
|
688
|
+
disabled: {
|
|
689
|
+
true: "",
|
|
690
|
+
false: ""
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
compoundVariants: [
|
|
694
|
+
{
|
|
695
|
+
interactive: true,
|
|
696
|
+
selected: true,
|
|
697
|
+
class: "relative -right-2 hover:bg-surface-higher"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
interactive: false,
|
|
701
|
+
selected: false,
|
|
702
|
+
class: "absolute top-0 -right-1"
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
interactive: false,
|
|
706
|
+
selected: true,
|
|
707
|
+
class: "absolute top-0 -right-1 opacity-0 group-hover:opacity-100 bg-surface-highest hover:bg-surface-higher transition-all duration-150"
|
|
708
|
+
}
|
|
709
|
+
]
|
|
710
|
+
});
|
|
711
|
+
var tabActionIconStyles = tv({
|
|
712
|
+
base: "opacity-80"
|
|
713
|
+
});
|
|
714
|
+
/**
|
|
715
|
+
* Filters.Tab - A subcomponent for rendering individual tabs within the Filters.Tabs component.
|
|
716
|
+
*
|
|
717
|
+
* @component
|
|
718
|
+
* @param {Object} props - The component props.
|
|
719
|
+
* @param {React.ReactNode} [props.icon=HorizontalDotsMinor] - The icon displayed in the tab (default is a horizontal dots icon).
|
|
720
|
+
* @param {boolean} [props.selected=false] - Whether the tab is currently selected.
|
|
721
|
+
* @param {string|React.ReactNode} props.content - The content displayed in the tab (e.g., tab label).
|
|
722
|
+
* @param {Function} [props.onClick] - Callback when the tab is clicked.
|
|
723
|
+
* @param {Function} [props.onAction] - Callback for an optional tab action (e.g., a secondary click area).
|
|
724
|
+
* @param {React.ReactNode} [props.accessory] - Additional content displayed below the tab label (e.g., a badge or description).
|
|
725
|
+
* @param {boolean} [props.interactive=false] - Whether the tab action is interactive.
|
|
726
|
+
* @param {string} [props.tooltip="Edit"] - Tooltip text displayed when hovering over the tab action icon.
|
|
727
|
+
* @returns {JSX.Element} The tab component.
|
|
728
|
+
*/ Filters.Tab = function FiltersTab() {
|
|
729
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
730
|
+
var _props_icon = props.icon, icon = _props_icon === void 0 ? HorizontalDotsMinor : _props_icon, _props_selected = props.selected, selected = _props_selected === void 0 ? false : _props_selected, content = props.content, onClick = props.onClick, onAction = props.onAction, accessory = props.accessory, _props_interactive = props.interactive, interactive = _props_interactive === void 0 ? false : _props_interactive, _props_tooltip = props.tooltip, tooltip = _props_tooltip === void 0 ? "Edit" : _props_tooltip;
|
|
731
|
+
var classes = tabStyles({
|
|
732
|
+
selected: selected,
|
|
733
|
+
onAction: onAction
|
|
734
|
+
});
|
|
735
|
+
var actionClasses = tabActionStyles({
|
|
736
|
+
selected: selected,
|
|
737
|
+
interactive: interactive,
|
|
738
|
+
disabled: false
|
|
739
|
+
});
|
|
740
|
+
var color = interactive ? "link" : selected ? "default" : "subdued";
|
|
741
|
+
var actionIconClasses = tabActionIconStyles();
|
|
742
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
743
|
+
className: classes,
|
|
744
|
+
onClick: onClick,
|
|
745
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
746
|
+
className: "flex flex-col items-start justify-start",
|
|
747
|
+
children: [
|
|
748
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
749
|
+
className: "relative w-full flex items-center justify-between gap-0 min-h-5 pr-1",
|
|
750
|
+
children: [
|
|
751
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
752
|
+
variant: "headingXs",
|
|
753
|
+
color: color,
|
|
754
|
+
fontWeight: "medium",
|
|
755
|
+
children: content
|
|
756
|
+
}),
|
|
757
|
+
onAction && /*#__PURE__*/ _jsxs("div", {
|
|
758
|
+
className: actionClasses,
|
|
759
|
+
onClick: onAction,
|
|
760
|
+
children: [
|
|
761
|
+
!interactive && /*#__PURE__*/ _jsx("div", {
|
|
762
|
+
className: "min-h-full min-w-2 bg-linear-to-l from-surface-highest to-transparent"
|
|
763
|
+
}),
|
|
764
|
+
tooltip ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
765
|
+
content: tooltip,
|
|
766
|
+
preferredPosition: "above",
|
|
767
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
768
|
+
source: icon,
|
|
769
|
+
color: interactive ? "link" : "subdued",
|
|
770
|
+
className: actionIconClasses
|
|
771
|
+
})
|
|
772
|
+
}) : /*#__PURE__*/ _jsx(Icon, {
|
|
773
|
+
source: icon,
|
|
774
|
+
color: interactive ? "link" : "subdued",
|
|
775
|
+
className: actionIconClasses
|
|
776
|
+
})
|
|
777
|
+
]
|
|
778
|
+
})
|
|
779
|
+
]
|
|
780
|
+
}),
|
|
781
|
+
accessory
|
|
782
|
+
]
|
|
783
|
+
})
|
|
784
|
+
});
|
|
785
|
+
};
|
|
786
|
+
/**
|
|
787
|
+
* Filters.TextField - A subcomponent for the query text field.
|
|
788
|
+
*
|
|
789
|
+
* @component
|
|
790
|
+
* @param {Object} props - The component props.
|
|
791
|
+
* @param {string} [props.queryValue] - The current value of the text field.
|
|
792
|
+
* @param {Function} [props.onQueryChange] - Callback for when the text field value changes.
|
|
793
|
+
* @param {Function} [props.onQueryBlur] - Callback for when the text field loses focus.
|
|
794
|
+
* @param {Function} [props.onQueryFocus] - Callback for when the text field gains focus.
|
|
795
|
+
* @param {Function} [props.onQueryClear] - Callback for clearing the text field.
|
|
796
|
+
* @param {string} [props.queryPlaceholder="Search"] - Placeholder text for the text field.
|
|
797
|
+
* @param {boolean} [props.subdued=false] - Whether the text field appears subdued.
|
|
798
|
+
* @param {boolean} [props.disableQueryField=false] - Whether the text field is disabled.
|
|
799
|
+
* @param {boolean} [props.transparent=true] - Whether the text field has a transparent background.
|
|
800
|
+
* @returns {JSX.Element} The text field component.
|
|
801
|
+
*/ Filters.TextField = function FiltersTextField() {
|
|
802
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
803
|
+
var darkMode = useContext(DarkModeContext).darkMode;
|
|
804
|
+
var queryValue = props.queryValue, onQueryChange = props.onQueryChange, onQueryBlur = props.onQueryBlur, onQueryFocus = props.onQueryFocus, onQueryClear = props.onQueryClear, _props_queryPlaceholder = props.queryPlaceholder, queryPlaceholder = _props_queryPlaceholder === void 0 ? "Search" : _props_queryPlaceholder, disableQueryField = props.disableQueryField;
|
|
805
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
806
|
+
className: "p-1",
|
|
807
|
+
children: /*#__PURE__*/ _jsx(TextField, {
|
|
808
|
+
icon: SearchMajor,
|
|
809
|
+
value: queryValue,
|
|
810
|
+
onChange: onQueryChange,
|
|
811
|
+
onBlur: onQueryBlur,
|
|
812
|
+
onFocus: onQueryFocus,
|
|
813
|
+
placeholder: queryPlaceholder,
|
|
814
|
+
disabled: disableQueryField,
|
|
815
|
+
subdued: darkMode,
|
|
816
|
+
transparent: !darkMode,
|
|
817
|
+
clearButton: true,
|
|
818
|
+
onClearButtonClick: onQueryClear
|
|
819
|
+
})
|
|
820
|
+
});
|
|
821
|
+
};
|
|
822
|
+
Filters.TextField.displayName = "Filters.TextField";
|
|
823
|
+
export default Filters;
|