@mbpockets/shared-ui 0.1.20 → 0.2.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 (125) hide show
  1. package/dist/EventPage/index.cjs +208 -121
  2. package/dist/EventPage/index.cjs.map +1 -1
  3. package/dist/EventPage/index.mjs +200 -119
  4. package/dist/EventPage/index.mjs.map +1 -1
  5. package/dist/EventPage.cjs +208 -121
  6. package/dist/EventPage.cjs.map +1 -1
  7. package/dist/EventPage.mjs +200 -119
  8. package/dist/EventPage.mjs.map +1 -1
  9. package/dist/PlayerPage/index.cjs.map +1 -1
  10. package/dist/PlayerPage/index.mjs.map +1 -1
  11. package/dist/PlayerPage.cjs.map +1 -1
  12. package/dist/PlayerPage.mjs.map +1 -1
  13. package/dist/ProfilePage/index.cjs.map +1 -1
  14. package/dist/ProfilePage/index.mjs.map +1 -1
  15. package/dist/ProfilePage.cjs.map +1 -1
  16. package/dist/ProfilePage.mjs.map +1 -1
  17. package/dist/SearchPage/Filters/index.cjs +149 -43
  18. package/dist/SearchPage/Filters/index.cjs.map +1 -1
  19. package/dist/SearchPage/Filters/index.d.cts +1 -2
  20. package/dist/SearchPage/Filters/index.d.ts +1 -2
  21. package/dist/SearchPage/Filters/index.mjs +146 -42
  22. package/dist/SearchPage/Filters/index.mjs.map +1 -1
  23. package/dist/SearchPage/Filters.cjs +149 -43
  24. package/dist/SearchPage/Filters.cjs.map +1 -1
  25. package/dist/SearchPage/Filters.d.cts +38 -3
  26. package/dist/SearchPage/Filters.d.ts +38 -3
  27. package/dist/SearchPage/Filters.mjs +146 -42
  28. package/dist/SearchPage/Filters.mjs.map +1 -1
  29. package/dist/SearchPage/Results/index.cjs +138 -67
  30. package/dist/SearchPage/Results/index.cjs.map +1 -1
  31. package/dist/SearchPage/Results/index.mjs +126 -63
  32. package/dist/SearchPage/Results/index.mjs.map +1 -1
  33. package/dist/SearchPage/Results.cjs +138 -67
  34. package/dist/SearchPage/Results.cjs.map +1 -1
  35. package/dist/SearchPage/Results.d.cts +21 -12
  36. package/dist/SearchPage/Results.d.ts +21 -12
  37. package/dist/SearchPage/Results.mjs +126 -63
  38. package/dist/SearchPage/Results.mjs.map +1 -1
  39. package/dist/SearchPage/index.cjs +495 -221
  40. package/dist/SearchPage/index.cjs.map +1 -1
  41. package/dist/SearchPage/index.d.cts +1 -1
  42. package/dist/SearchPage/index.d.ts +1 -1
  43. package/dist/SearchPage/index.mjs +482 -216
  44. package/dist/SearchPage/index.mjs.map +1 -1
  45. package/dist/SearchPage.cjs +495 -221
  46. package/dist/SearchPage.cjs.map +1 -1
  47. package/dist/SearchPage.d.cts +78 -7
  48. package/dist/SearchPage.d.ts +78 -7
  49. package/dist/SearchPage.mjs +482 -216
  50. package/dist/SearchPage.mjs.map +1 -1
  51. package/dist/TablePage/index.cjs +10 -1
  52. package/dist/TablePage/index.cjs.map +1 -1
  53. package/dist/TablePage/index.d.cts +2 -2
  54. package/dist/TablePage/index.d.ts +2 -2
  55. package/dist/TablePage/index.mjs +10 -2
  56. package/dist/TablePage/index.mjs.map +1 -1
  57. package/dist/TablePage.cjs +10 -1
  58. package/dist/TablePage.cjs.map +1 -1
  59. package/dist/TablePage.d.cts +7 -2
  60. package/dist/TablePage.d.ts +7 -2
  61. package/dist/TablePage.mjs +10 -2
  62. package/dist/TablePage.mjs.map +1 -1
  63. package/dist/index.cjs +446 -178
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.d.cts +3 -3
  66. package/dist/index.d.ts +3 -3
  67. package/dist/index.mjs +434 -175
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/mocks/SearchResults.cjs +22 -15
  70. package/dist/mocks/SearchResults.cjs.map +1 -1
  71. package/dist/mocks/SearchResults.d.cts +3 -15
  72. package/dist/mocks/SearchResults.d.ts +3 -15
  73. package/dist/mocks/SearchResults.mjs +22 -15
  74. package/dist/mocks/SearchResults.mjs.map +1 -1
  75. package/dist/mocks/index.cjs +22 -15
  76. package/dist/mocks/index.cjs.map +1 -1
  77. package/dist/mocks/index.d.cts +2 -1
  78. package/dist/mocks/index.d.ts +2 -1
  79. package/dist/mocks/index.mjs +22 -15
  80. package/dist/mocks/index.mjs.map +1 -1
  81. package/dist/mocks.cjs +22 -15
  82. package/dist/mocks.cjs.map +1 -1
  83. package/dist/mocks.d.cts +2 -1
  84. package/dist/mocks.d.ts +2 -1
  85. package/dist/mocks.mjs +22 -15
  86. package/dist/mocks.mjs.map +1 -1
  87. package/dist/{common → shared}/index.cjs.map +1 -1
  88. package/dist/{common → shared}/index.d.cts +1 -1
  89. package/dist/{common → shared}/index.d.ts +1 -1
  90. package/dist/{common → shared}/index.mjs.map +1 -1
  91. package/dist/{common.cjs → shared.cjs} +2 -2
  92. package/dist/{common.cjs.map → shared.cjs.map} +1 -1
  93. package/dist/{common.css → shared.css} +1 -1
  94. package/dist/{common.mjs → shared.mjs} +2 -2
  95. package/dist/{common.mjs.map → shared.mjs.map} +1 -1
  96. package/dist/types/index.d.cts +1 -1
  97. package/dist/types/index.d.ts +1 -1
  98. package/dist/types/search.d.cts +23 -1
  99. package/dist/types/search.d.ts +23 -1
  100. package/dist/types.d.cts +1 -1
  101. package/dist/types.d.ts +1 -1
  102. package/package.json +1 -1
  103. /package/dist/{common → shared}/Modal/index.cjs +0 -0
  104. /package/dist/{common → shared}/Modal/index.cjs.map +0 -0
  105. /package/dist/{common → shared}/Modal/index.css +0 -0
  106. /package/dist/{common → shared}/Modal/index.css.map +0 -0
  107. /package/dist/{common → shared}/Modal/index.d.cts +0 -0
  108. /package/dist/{common → shared}/Modal/index.d.ts +0 -0
  109. /package/dist/{common → shared}/Modal/index.mjs +0 -0
  110. /package/dist/{common → shared}/Modal/index.mjs.map +0 -0
  111. /package/dist/{common → shared}/Modal.cjs +0 -0
  112. /package/dist/{common → shared}/Modal.cjs.map +0 -0
  113. /package/dist/{common → shared}/Modal.css +0 -0
  114. /package/dist/{common → shared}/Modal.css.map +0 -0
  115. /package/dist/{common → shared}/Modal.d.cts +0 -0
  116. /package/dist/{common → shared}/Modal.d.ts +0 -0
  117. /package/dist/{common → shared}/Modal.mjs +0 -0
  118. /package/dist/{common → shared}/Modal.mjs.map +0 -0
  119. /package/dist/{common → shared}/index.cjs +0 -0
  120. /package/dist/{common → shared}/index.css +0 -0
  121. /package/dist/{common → shared}/index.css.map +0 -0
  122. /package/dist/{common → shared}/index.mjs +0 -0
  123. /package/dist/{common.css.map → shared.css.map} +0 -0
  124. /package/dist/{common.d.cts → shared.d.cts} +0 -0
  125. /package/dist/{common.d.ts → shared.d.ts} +0 -0
@@ -1,32 +1,58 @@
1
1
  "use client";
2
- import Typography2 from '@mui/material/Typography';
2
+ import FormControlLabel from '@mui/material/FormControlLabel';
3
+ import Checkbox from '@mui/material/Checkbox';
4
+ import Box8 from '@mui/material/Box';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+ import Typography6 from '@mui/material/Typography';
3
7
  import FormControl from '@mui/material/FormControl';
4
8
  import RadioGroup from '@mui/material/RadioGroup';
5
- import FormControlLabel from '@mui/material/FormControlLabel';
6
9
  import Radio from '@mui/material/Radio';
7
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
8
- import React from 'react';
9
- import Box2 from '@mui/material/Box';
10
+ import React, { useEffect, useState } from 'react';
10
11
  import Autocomplete from '@mui/material/Autocomplete';
11
12
  import TextField from '@mui/material/TextField';
12
13
  import Popper from '@mui/material/Popper';
13
- import Divider from '@mui/material/Divider';
14
+ import Divider2 from '@mui/material/Divider';
14
15
  import FormGroup from '@mui/material/FormGroup';
15
- import Checkbox from '@mui/material/Checkbox';
16
16
  import Button from '@mui/material/Button';
17
17
  import SearchIcon from '@mui/icons-material/Search';
18
+ import Pagination from '@mui/material/Pagination';
18
19
  import Avatar from '@mui/material/Avatar';
19
- import { Card, CardContent, Box, Typography, Chip as Chip$1, LinearProgress, useTheme, useMediaQuery } from '@mui/material';
20
- import CasinoIcon from '@mui/icons-material/Casino';
20
+ import Card2 from '@mui/material/Card';
21
+ import CardContent2 from '@mui/material/CardContent';
22
+ import { useTheme, useMediaQuery, Typography } from '@mui/material';
23
+ import Chip2 from '@mui/material/Chip';
24
+ import LinearProgress from '@mui/material/LinearProgress';
25
+ import PersonIcon from '@mui/icons-material/Person';
26
+ import SupervisorAccountIcon from '@mui/icons-material/SupervisorAccount';
27
+ import TableRestaurantIcon from '@mui/icons-material/TableRestaurant';
21
28
  import CalendarTodayIcon from '@mui/icons-material/CalendarToday';
22
29
  import LocationOnIcon from '@mui/icons-material/LocationOn';
23
30
  import EventIcon from '@mui/icons-material/Event';
24
31
  import Grid from '@mui/material/Grid';
25
- import Card2 from '@mui/material/Card';
26
32
  import CardHeader from '@mui/material/CardHeader';
27
- import CardContent2 from '@mui/material/CardContent';
33
+ import CircularProgress from '@mui/material/CircularProgress';
28
34
 
29
- // src/components/SearchPage/Filters/SortOptions.tsx
35
+ // src/components/SearchPage/Filters/ExpiredTablesFilter.tsx
36
+ var ExpiredTablesFilter = ({
37
+ includeExpiredTables,
38
+ onChange
39
+ }) => {
40
+ return /* @__PURE__ */ jsx(Box8, { sx: { mt: 2 }, children: /* @__PURE__ */ jsx(
41
+ FormControlLabel,
42
+ {
43
+ control: /* @__PURE__ */ jsx(
44
+ Checkbox,
45
+ {
46
+ checked: includeExpiredTables,
47
+ onChange: (e) => onChange(e.target.checked),
48
+ color: "primary"
49
+ }
50
+ ),
51
+ label: "Show expired tables"
52
+ }
53
+ ) });
54
+ };
55
+ var ExpiredTablesFilter_default = ExpiredTablesFilter;
30
56
  var SORT_OPTIONS = [
31
57
  { id: "relevance", label: "Relevance" },
32
58
  { id: "newest", label: "Newest" },
@@ -40,7 +66,7 @@ var SortOptions = ({
40
66
  onChange == null ? void 0 : onChange(event.target.value);
41
67
  };
42
68
  return /* @__PURE__ */ jsxs(Fragment, { children: [
43
- /* @__PURE__ */ jsx(Typography2, { variant: "h6", gutterBottom: true, children: "Sort By" }),
69
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", gutterBottom: true, children: "Sort By" }),
44
70
  /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(RadioGroup, { defaultValue, onChange: handleSortChange, children: SORT_OPTIONS.map((option) => /* @__PURE__ */ jsx(
45
71
  FormControlLabel,
46
72
  {
@@ -53,13 +79,53 @@ var SortOptions = ({
53
79
  ] });
54
80
  };
55
81
  var SortOptions_default = SortOptions;
82
+ function Chip({ tag, removeCallback }) {
83
+ var _a;
84
+ const color = (_a = tag.color) != null ? _a : "#bfbcbb";
85
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
86
+ "span",
87
+ {
88
+ className: "inline-block text-sm px-3 py-1 rounded-full border-2 font-outlined text-white m-0.5 font-stretch-105% font-sans",
89
+ style: {
90
+ borderColor: `color-mix(in srgb, ${color}, black 50%)`,
91
+ background: `linear-gradient(160deg, color-mix(in srgb, ${color}, white 10%) 0%, color-mix(in srgb, ${color}, black 60%) 100%)`,
92
+ textShadow: "black 1.5px 1px 1.5px",
93
+ filter: `drop-shadow(2px 2px 1.5px color-mix(in srgb, ${color}, black 80%))`
94
+ },
95
+ children: [
96
+ tag.label,
97
+ removeCallback && /* @__PURE__ */ jsx(
98
+ "button",
99
+ {
100
+ type: "button",
101
+ onClick: () => removeCallback(tag.id),
102
+ className: "ml-2 text-white hover:text-red-700 focus:outline-none pl-0.5 pr-1 cursor-pointer hover:bg-white rounded-full",
103
+ style: {
104
+ textShadow: "black 1px 1px 1px"
105
+ },
106
+ children: "X"
107
+ }
108
+ )
109
+ ]
110
+ },
111
+ tag.id
112
+ ) });
113
+ }
56
114
  var TagsFilter = ({
57
115
  onChange,
58
- tags: Tags = []
116
+ tags: Tags = [],
117
+ initialSelectedTags
59
118
  }) => {
60
- const [mustHaveTags, setMustHaveTags] = React.useState([]);
61
- const [mustNotHaveTags, setMustNotHaveTags] = React.useState([]);
62
- const [shouldHaveAtLeastOneTags, setShouldHaveAtLeastOneTags] = React.useState([]);
119
+ const [mustHaveTags, setMustHaveTags] = React.useState((initialSelectedTags == null ? void 0 : initialSelectedTags.mustHave) || []);
120
+ const [mustNotHaveTags, setMustNotHaveTags] = React.useState((initialSelectedTags == null ? void 0 : initialSelectedTags.mustNotHave) || []);
121
+ const [shouldHaveAtLeastOneTags, setShouldHaveAtLeastOneTags] = React.useState((initialSelectedTags == null ? void 0 : initialSelectedTags.shouldHaveAtLeastOne) || []);
122
+ React.useEffect(() => {
123
+ if (initialSelectedTags) {
124
+ setMustHaveTags(initialSelectedTags.mustHave || []);
125
+ setMustNotHaveTags(initialSelectedTags.mustNotHave || []);
126
+ setShouldHaveAtLeastOneTags(initialSelectedTags.shouldHaveAtLeastOne || []);
127
+ }
128
+ }, [initialSelectedTags]);
63
129
  Tags = !!Tags ? Tags : [];
64
130
  const [inputValues, setInputValues] = React.useState({
65
131
  mustHave: "",
@@ -69,7 +135,7 @@ var TagsFilter = ({
69
135
  const tagOptions = React.useMemo(() => {
70
136
  console.log("available tags: " + JSON.stringify(Tags));
71
137
  console.log(!Tags);
72
- if (!Tags || Tags.length == 0 || !Tags.map) return [];
138
+ if (!Tags || Tags.length === 0 || !Tags.map) return [];
73
139
  return Tags.map((tag) => ({
74
140
  value: tag.id,
75
141
  label: tag.label
@@ -101,7 +167,7 @@ var TagsFilter = ({
101
167
  };
102
168
  const renderSelectedTags = (selectedTags, category) => {
103
169
  const tagValues = [];
104
- if (!Tags || Tags.length == 0 || !Tags.map) return null;
170
+ if (!Tags || Tags.length === 0 || !Tags.map) return null;
105
171
  Tags.forEach((tag) => {
106
172
  if (selectedTags.includes(tag.id)) {
107
173
  tagValues.push(tag);
@@ -110,27 +176,11 @@ var TagsFilter = ({
110
176
  if (tagValues.length === 0) {
111
177
  return null;
112
178
  }
113
- return /* @__PURE__ */ jsx(Box2, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mb: 2 }, children: tagValues.map((tag) => /* @__PURE__ */ jsxs(
114
- "span",
179
+ return /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mb: 2 }, children: tagValues.map((tag) => /* @__PURE__ */ jsx(
180
+ Chip,
115
181
  {
116
- className: "inline-block text-sm px-3 py-1 rounded-full outline-black outline-2 font-outlined",
117
- style: {
118
- background: tag.color || "#bfbcbb",
119
- color: "white",
120
- textShadow: "black 0.2em 0.2em 0.4em"
121
- },
122
- children: [
123
- tag.label,
124
- /* @__PURE__ */ jsx(
125
- "button",
126
- {
127
- type: "button",
128
- onClick: () => handleTagChange(tag.id, category),
129
- className: "ml-2 text-red-500 bg-white bg-opacity-50 rounded-full outline-black outline-2 font-outlined",
130
- children: "\xD7"
131
- }
132
- )
133
- ]
182
+ tag,
183
+ removeCallback: (tagId) => handleTagChange(tagId, category)
134
184
  },
135
185
  tag.id
136
186
  )) });
@@ -138,7 +188,7 @@ var TagsFilter = ({
138
188
  const createTagSelector = (category, label) => {
139
189
  const selectedTags = category === "mustHave" ? mustHaveTags : category === "mustNotHave" ? mustNotHaveTags : shouldHaveAtLeastOneTags;
140
190
  return /* @__PURE__ */ jsxs(Fragment, { children: [
141
- /* @__PURE__ */ jsx(Typography2, { variant: "subtitle1", gutterBottom: true, sx: { mt: 2 }, children: label }),
191
+ /* @__PURE__ */ jsx(Typography6, { variant: "subtitle1", gutterBottom: true, sx: { mt: 2 }, children: label }),
142
192
  renderSelectedTags(selectedTags, category),
143
193
  /* @__PURE__ */ jsx(
144
194
  Autocomplete,
@@ -191,11 +241,11 @@ var TagsFilter = ({
191
241
  ] });
192
242
  };
193
243
  return /* @__PURE__ */ jsxs(Fragment, { children: [
194
- /* @__PURE__ */ jsx(Typography2, { variant: "h6", gutterBottom: true, children: "Tags" }),
244
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", gutterBottom: true, children: "Tags" }),
195
245
  createTagSelector("mustHave", "Must Have Tags"),
196
- /* @__PURE__ */ jsx(Divider, { sx: { my: 2 } }),
246
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
197
247
  createTagSelector("mustNotHave", "Must Not Have Tags"),
198
- /* @__PURE__ */ jsx(Divider, { sx: { my: 2 } }),
248
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
199
249
  createTagSelector("shouldHaveAtLeastOne", "Should Contain At Least One Tag")
200
250
  ] });
201
251
  };
@@ -225,21 +275,80 @@ var CustomPopper = (props) => {
225
275
  );
226
276
  };
227
277
  var TagsFilter_default = TagsFilter;
228
- var FILTER_TYPES = [
229
- { id: "player", label: "Players" },
230
- { id: "event", label: "Events", disabled: true },
231
- { id: "table", label: "Tables", disabled: true }
232
- ];
233
- var TypeFilter = ({ onChange }) => {
234
- const [selectedTypes, setSelectedTypes] = React.useState([]);
278
+ var TextSearchCard = ({ onChange, selectedTypes, initialTextSearch }) => {
279
+ const [query, setQuery] = React.useState((initialTextSearch == null ? void 0 : initialTextSearch.query) || "");
280
+ const [titleOnly, setTitleOnly] = React.useState((initialTextSearch == null ? void 0 : initialTextSearch.titleOnly) || false);
281
+ useEffect(() => {
282
+ if (initialTextSearch) {
283
+ setQuery(initialTextSearch.query || "");
284
+ setTitleOnly(initialTextSearch.titleOnly || false);
285
+ }
286
+ }, [initialTextSearch]);
287
+ const shouldShow = selectedTypes.includes("table") || selectedTypes.includes("event");
288
+ if (!shouldShow) {
289
+ return null;
290
+ }
291
+ const handleQueryChange = (e) => {
292
+ const newQuery = e.target.value;
293
+ setQuery(newQuery);
294
+ if (onChange) {
295
+ onChange({ query: newQuery, titleOnly });
296
+ }
297
+ };
298
+ const handleTitleOnlyChange = (e) => {
299
+ const newTitleOnly = e.target.checked;
300
+ setTitleOnly(newTitleOnly);
301
+ if (onChange) {
302
+ onChange({ query, titleOnly: newTitleOnly });
303
+ }
304
+ };
305
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
306
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", gutterBottom: true, children: "Text Search" }),
307
+ /* @__PURE__ */ jsxs(Box8, { sx: { mb: 2 }, children: [
308
+ /* @__PURE__ */ jsx(
309
+ TextField,
310
+ {
311
+ fullWidth: true,
312
+ label: "Search in title and description",
313
+ variant: "outlined",
314
+ value: query,
315
+ onChange: handleQueryChange,
316
+ placeholder: "Enter search terms...",
317
+ sx: { mb: 1 }
318
+ }
319
+ ),
320
+ /* @__PURE__ */ jsx(
321
+ FormControlLabel,
322
+ {
323
+ control: /* @__PURE__ */ jsx(
324
+ Checkbox,
325
+ {
326
+ checked: titleOnly,
327
+ onChange: handleTitleOnlyChange
328
+ }
329
+ ),
330
+ label: "Search in title only"
331
+ }
332
+ )
333
+ ] })
334
+ ] });
335
+ };
336
+ var TextSearchCard_default = TextSearchCard;
337
+ var TypeFilter = ({ types, initialSelectedTypes = [], onChange }) => {
338
+ const [selectedTypes, setSelectedTypes] = React.useState(initialSelectedTypes);
339
+ useEffect(() => {
340
+ setSelectedTypes(initialSelectedTypes);
341
+ }, [initialSelectedTypes]);
235
342
  const handleTypeChange = (typeId) => {
236
343
  const newSelectedTypes = selectedTypes.includes(typeId) ? selectedTypes.filter((id) => id !== typeId) : [...selectedTypes, typeId];
237
344
  setSelectedTypes(newSelectedTypes);
238
- onChange == null ? void 0 : onChange(newSelectedTypes);
345
+ if (onChange) {
346
+ onChange(newSelectedTypes);
347
+ }
239
348
  };
240
349
  return /* @__PURE__ */ jsxs(Fragment, { children: [
241
- /* @__PURE__ */ jsx(Typography2, { variant: "h6", gutterBottom: true, children: "Type" }),
242
- /* @__PURE__ */ jsx(FormGroup, { children: FILTER_TYPES.map((type) => /* @__PURE__ */ jsx(
350
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", gutterBottom: true, children: "Type" }),
351
+ /* @__PURE__ */ jsx(FormGroup, { children: types.map((type) => /* @__PURE__ */ jsx(
243
352
  FormControlLabel,
244
353
  {
245
354
  control: /* @__PURE__ */ jsx(
@@ -247,7 +356,8 @@ var TypeFilter = ({ onChange }) => {
247
356
  {
248
357
  checked: selectedTypes.includes(type.id),
249
358
  onChange: () => handleTypeChange(type.id),
250
- disabled: type.disabled
359
+ disabled: type.id === "event",
360
+ title: type.id === "event" ? "Coming soon! Currently only player and table search are supported." : ""
251
361
  }
252
362
  ),
253
363
  label: type.label
@@ -258,23 +368,68 @@ var TypeFilter = ({ onChange }) => {
258
368
  };
259
369
  var TypeFilter_default = TypeFilter;
260
370
  var FiltersContainer = ({
371
+ initialSelectedTypes = [],
372
+ initialSelectedTags,
373
+ initialTextSearch,
374
+ includeExpiredTables = false,
261
375
  onTypeChange,
262
376
  onTagChange,
377
+ onTextSearchChange,
378
+ onIncludeExpiredTablesChange,
263
379
  onSubmit,
264
- tags
380
+ tags,
381
+ searchTypes
265
382
  }) => {
266
- return /* @__PURE__ */ jsxs(Box2, { children: [
267
- /* @__PURE__ */ jsx(TypeFilter_default, { onChange: onTypeChange }),
268
- /* @__PURE__ */ jsx(Divider, { sx: { my: 2 } }),
383
+ const [selectedTypes, setSelectedTypes] = React.useState(initialSelectedTypes);
384
+ useEffect(() => {
385
+ setSelectedTypes(initialSelectedTypes);
386
+ }, [initialSelectedTypes]);
387
+ const handleTypeChange = (types) => {
388
+ setSelectedTypes(types);
389
+ if (onTypeChange) {
390
+ onTypeChange(types);
391
+ }
392
+ };
393
+ return /* @__PURE__ */ jsxs(Box8, { children: [
394
+ /* @__PURE__ */ jsx(
395
+ TypeFilter_default,
396
+ {
397
+ types: searchTypes,
398
+ initialSelectedTypes,
399
+ onChange: handleTypeChange
400
+ }
401
+ ),
402
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
403
+ /* @__PURE__ */ jsx(
404
+ TextSearchCard_default,
405
+ {
406
+ selectedTypes,
407
+ initialTextSearch,
408
+ onChange: onTextSearchChange
409
+ }
410
+ ),
411
+ (selectedTypes.includes("table") || selectedTypes.includes("event")) && /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
269
412
  /* @__PURE__ */ jsx(
270
413
  TagsFilter_default,
271
414
  {
272
415
  tags,
416
+ initialSelectedTags,
273
417
  onChange: onTagChange
274
418
  }
275
419
  ),
276
- /* @__PURE__ */ jsx(Divider, { sx: { my: 2 } }),
277
- /* @__PURE__ */ jsx(Box2, { sx: { display: "flex", justifyContent: "center", mt: 2 }, children: /* @__PURE__ */ jsx(
420
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } }),
421
+ selectedTypes.includes("table") && /* @__PURE__ */ jsxs(Fragment, { children: [
422
+ /* @__PURE__ */ jsx(
423
+ ExpiredTablesFilter_default,
424
+ {
425
+ includeExpiredTables,
426
+ onChange: onIncludeExpiredTablesChange || (() => {
427
+ })
428
+ }
429
+ ),
430
+ /* @__PURE__ */ jsx(Divider2, { sx: { my: 2 } })
431
+ ] }),
432
+ /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", justifyContent: "center", mt: 2 }, children: /* @__PURE__ */ jsx(
278
433
  Button,
279
434
  {
280
435
  variant: "contained",
@@ -299,41 +454,24 @@ var FiltersContainer = ({
299
454
  ] });
300
455
  };
301
456
  var FiltersContainer_default = FiltersContainer;
302
- function Chip({ tag, removeCallback }) {
303
- var _a;
304
- const color = (_a = tag.color) != null ? _a : "#bfbcbb";
305
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
306
- "span",
307
- {
308
- className: "inline-block text-sm px-3 py-1 rounded-full border-2 font-outlined text-white m-0.5 font-stretch-105% font-sans",
309
- style: {
310
- borderColor: `color-mix(in srgb, ${color}, black 50%)`,
311
- background: `linear-gradient(160deg, color-mix(in srgb, ${color}, white 10%) 0%, color-mix(in srgb, ${color}, black 60%) 100%)`,
312
- textShadow: "black 1.5px 1px 1.5px",
313
- filter: `drop-shadow(2px 2px 1.5px color-mix(in srgb, ${color}, black 80%))`
314
- },
315
- children: [
316
- tag.label,
317
- removeCallback && /* @__PURE__ */ jsx(
318
- "button",
319
- {
320
- type: "button",
321
- onClick: () => removeCallback(tag.id),
322
- className: "ml-2 text-white hover:text-red-700 focus:outline-none pl-0.5 pr-1 cursor-pointer hover:bg-white rounded-full",
323
- style: {
324
- textShadow: "black 1px 1px 1px"
325
- },
326
- children: "X"
327
- }
328
- )
329
- ]
330
- },
331
- tag.id
332
- ) });
333
- }
457
+ var NextGameLabel = ({ nextGameTime }) => {
458
+ const date = typeof nextGameTime === "string" ? new Date(nextGameTime) : nextGameTime;
459
+ return /* @__PURE__ */ jsxs(Typography, { variant: "caption", sx: { display: "block", mb: 1, color: "primary.main", fontWeight: "bold" }, children: [
460
+ "Next Game: ",
461
+ date.toLocaleString()
462
+ ] });
463
+ };
464
+ var NextGameLabel_default = NextGameLabel;
334
465
  function generateTagsDisplay(tag) {
335
466
  return /* @__PURE__ */ jsx(Chip, { tag }, tag.id);
336
467
  }
468
+ function renderTagsFromIds(ids, legalTags) {
469
+ if (!ids || !legalTags || legalTags.length === 0) {
470
+ return /* @__PURE__ */ jsx(Fragment, {});
471
+ }
472
+ const validTags = ids.map((id) => legalTags.find((tag) => tag.id === id)).filter((tag) => Boolean(tag));
473
+ return validTags.map((tag) => generateTagsDisplay(tag));
474
+ }
337
475
  var BaseSearchResultCard = ({
338
476
  result,
339
477
  onClick,
@@ -341,13 +479,19 @@ var BaseSearchResultCard = ({
341
479
  icon,
342
480
  tags
343
481
  }) => {
344
- const handleClick = () => {
482
+ const handleClick = (e) => {
345
483
  if (onClick) {
346
- onClick(result.id);
484
+ if (e.ctrlKey || e.metaKey || e.shiftKey) {
485
+ e.stopPropagation();
486
+ const url = `/${result.type}/${result.id}`;
487
+ window.open(url, "_blank");
488
+ } else {
489
+ onClick(result.id);
490
+ }
347
491
  }
348
492
  };
349
493
  return /* @__PURE__ */ jsx(
350
- Card,
494
+ Card2,
351
495
  {
352
496
  elevation: 6,
353
497
  sx: {
@@ -360,48 +504,21 @@ var BaseSearchResultCard = ({
360
504
  },
361
505
  marginBottom: 2
362
506
  },
363
- onClick: handleClick,
364
- children: /* @__PURE__ */ jsxs(CardContent, { sx: { display: "flex", alignItems: "flex-start" }, children: [
365
- icon && /* @__PURE__ */ jsx(Box, { sx: { mr: 2, display: "flex", alignItems: "center", pt: 0.5 }, children: icon }),
366
- /* @__PURE__ */ jsxs(Box, { sx: { flex: 1 }, children: [
367
- /* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { mb: 1 }, children: result.title }),
507
+ onClick: (e) => handleClick(e),
508
+ children: /* @__PURE__ */ jsxs(CardContent2, { sx: { display: "flex", alignItems: "flex-start" }, children: [
509
+ icon && /* @__PURE__ */ jsx(Box8, { sx: { mr: 2, display: "flex", alignItems: "center", pt: 0.5 }, children: icon }),
510
+ /* @__PURE__ */ jsxs(Box8, { sx: { flex: 1 }, children: [
511
+ /* @__PURE__ */ jsx(Typography6, { variant: "h6", sx: { mb: 1 }, children: result.title }),
512
+ result.nextGameTime && /* @__PURE__ */ jsx(NextGameLabel_default, { nextGameTime: result.nextGameTime }),
513
+ result.type === "table" && result.shortDescription ? /* @__PURE__ */ jsx(Typography6, { variant: "body2", sx: { mb: 1 }, children: result.shortDescription }) : null,
368
514
  children,
369
- /* @__PURE__ */ jsx(Typography, { variant: "body1", children: result.description }),
370
- result.tags && result.tags.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { mt: 1 }, children: /* @__PURE__ */ jsx(Box, { sx: {
371
- display: "block",
372
- whiteSpace: "nowrap",
373
- overflow: "hidden",
374
- textOverflow: "clip",
375
- pl: 0.5
376
- // Add some padding to prevent clipping of the leftmost tag
377
- }, children: (() => {
378
- const MAX_VISIBLE = 5;
379
- const tagObjs = result.tags.map((tagId) => tags.find((t) => t.id === tagId)).filter((t) => Boolean(t));
380
- const visible = tagObjs.slice(0, MAX_VISIBLE);
381
- const hiddenCount = Math.max(tagObjs.length - visible.length, 0);
382
- return /* @__PURE__ */ jsxs(Fragment, { children: [
383
- visible.map((tag) => generateTagsDisplay(tag)),
384
- hiddenCount > 0 && /* @__PURE__ */ jsxs(
385
- "span",
386
- {
387
- className: "inline-block text-sm px-3 py-1 rounded-full outline-black outline-2 font-outlined",
388
- style: {
389
- marginTop: "6px",
390
- marginRight: "6px",
391
- marginBottom: "6px",
392
- background: "#9e9e9e",
393
- color: "white",
394
- textShadow: "black 0.2em 0.2em 0.4em"
395
- },
396
- children: [
397
- "+",
398
- hiddenCount,
399
- " more"
400
- ]
401
- }
402
- )
403
- ] });
404
- })() }) })
515
+ result.type === "table" ? /* @__PURE__ */ jsx(Typography6, { variant: "body1", children: (() => {
516
+ var _a, _b;
517
+ const full = (_b = (_a = result.fullDescription) != null ? _a : result.description) != null ? _b : "";
518
+ const text = full || "";
519
+ return text.length > 200 ? `${text.slice(0, 200).trimEnd()}...` : text;
520
+ })() }) : /* @__PURE__ */ jsx(Typography6, { variant: "body1", children: result.description }),
521
+ result.tags && result.tags.length > 0 && /* @__PURE__ */ jsx(Box8, { sx: { mt: 1, display: "flex", flexWrap: "wrap", gap: 1 }, children: renderTagsFromIds(result.tags, tags) })
405
522
  ] })
406
523
  ] })
407
524
  }
@@ -456,21 +573,60 @@ var PlayerResultCard = ({
456
573
  return /* @__PURE__ */ jsx(BaseSearchResultCard_default, { result, onClick, icon: playerIcon, tags });
457
574
  };
458
575
  var PlayerResultCard_default = PlayerResultCard;
459
- var TableResultCard = ({ result, tags, onClick }) => {
460
- const capacity = result.capacity || 1;
461
- const numPlayers = result.numPlayers || 0;
462
- const occupancy = numPlayers / capacity * 100;
463
- return /* @__PURE__ */ jsx(BaseSearchResultCard, { result, tags, onClick, icon: /* @__PURE__ */ jsx(CasinoIcon, { color: "primary" }), children: /* @__PURE__ */ jsxs(Box, { sx: { mb: 1 }, children: [
464
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 0.5 }, children: [
465
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", color: "text.secondary", children: [
466
- "Players: ",
467
- numPlayers,
468
- " / ",
469
- capacity
576
+ var TableResultCard = ({
577
+ result,
578
+ onClick,
579
+ tags
580
+ }) => {
581
+ const rawCapacity = result.capacity;
582
+ const hasDefinedCapacity = typeof rawCapacity === "number" && Number.isFinite(rawCapacity) && rawCapacity > 0;
583
+ const capacity = hasDefinedCapacity ? rawCapacity : 0;
584
+ const activePlayers = typeof result.numPlayers === "number" ? result.numPlayers : 0;
585
+ const availableSlots = Math.max(capacity - activePlayers, 0);
586
+ const hasDM = typeof result.hasDM === "boolean" ? result.hasDM : Boolean(result.dungeonMaster);
587
+ const occupancyPercentage = hasDefinedCapacity ? activePlayers / capacity * 100 : 100;
588
+ const tableIcon = /* @__PURE__ */ jsx(
589
+ TableRestaurantIcon,
590
+ {
591
+ sx: {
592
+ fontSize: 40,
593
+ color: "primary.main"
594
+ }
595
+ }
596
+ );
597
+ return /* @__PURE__ */ jsx(BaseSearchResultCard_default, { result, onClick, icon: tableIcon, tags, children: /* @__PURE__ */ jsxs(Box8, { sx: { mb: 2 }, children: [
598
+ /* @__PURE__ */ jsxs(Box8, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 1 }, children: [
599
+ /* @__PURE__ */ jsxs(Typography6, { variant: "body2", children: [
600
+ /* @__PURE__ */ jsx("strong", { children: "Players:" }),
601
+ " ",
602
+ hasDefinedCapacity ? `${activePlayers}/${capacity}` : activePlayers
470
603
  ] }),
471
- result.dungeonMaster ? /* @__PURE__ */ jsx(Chip$1, { label: "DM Present", size: "small", color: "success", variant: "outlined" }) : /* @__PURE__ */ jsx(Chip$1, { label: "No DM", size: "small", color: "warning", variant: "outlined" })
604
+ typeof hasDM === "boolean" && /* @__PURE__ */ jsx(
605
+ Chip2,
606
+ {
607
+ icon: hasDM ? /* @__PURE__ */ jsx(SupervisorAccountIcon, {}) : /* @__PURE__ */ jsx(PersonIcon, {}),
608
+ label: hasDM ? "DM Present" : "No DM",
609
+ color: hasDM ? "success" : "warning",
610
+ size: "small"
611
+ }
612
+ )
472
613
  ] }),
473
- /* @__PURE__ */ jsx(LinearProgress, { variant: "determinate", value: occupancy, sx: { height: 8, borderRadius: 4 } })
614
+ /* @__PURE__ */ jsx(
615
+ LinearProgress,
616
+ {
617
+ variant: "determinate",
618
+ value: occupancyPercentage,
619
+ sx: {
620
+ height: 10,
621
+ borderRadius: 5,
622
+ backgroundColor: "#e0e0e0",
623
+ "& .MuiLinearProgress-bar": {
624
+ backgroundColor: hasDefinedCapacity ? availableSlots > 0 ? "#4caf50" : "#f44336" : "#2196f3"
625
+ }
626
+ }
627
+ }
628
+ ),
629
+ hasDefinedCapacity && /* @__PURE__ */ jsx(Typography6, { variant: "body2", sx: { mt: 0.5, textAlign: "right" }, children: availableSlots > 0 ? `${availableSlots} slot${availableSlots !== 1 ? "s" : ""} available` : "Table full" })
474
630
  ] }) });
475
631
  };
476
632
  var TableResultCard_default = TableResultCard;
@@ -489,20 +645,42 @@ var EventResultCard = ({
489
645
  try {
490
646
  const date = new Date(dateString);
491
647
  return date.toLocaleDateString("en-US", options);
492
- } catch {
648
+ } catch (error) {
493
649
  return dateString;
494
650
  }
495
651
  };
496
652
  const formattedDate = result.date ? formatDate(result.date) : "Date TBD";
497
653
  const location = result.location || "Location TBD";
498
- return /* @__PURE__ */ jsx(BaseSearchResultCard_default, { result, onClick, icon: /* @__PURE__ */ jsx(EventIcon, { color: "primary" }), tags, children: /* @__PURE__ */ jsxs(Box, { sx: { mb: 1 }, children: [
499
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", mb: 0.5 }, children: [
500
- /* @__PURE__ */ jsx(CalendarTodayIcon, { sx: { mr: 1, fontSize: "small", color: "text.secondary" } }),
501
- /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: formattedDate })
654
+ const eventIcon = /* @__PURE__ */ jsx(
655
+ EventIcon,
656
+ {
657
+ sx: {
658
+ fontSize: 40,
659
+ color: "primary.main"
660
+ }
661
+ }
662
+ );
663
+ return /* @__PURE__ */ jsx(BaseSearchResultCard_default, { result, onClick, icon: eventIcon, tags, children: /* @__PURE__ */ jsxs(Box8, { sx: { mb: 2 }, children: [
664
+ /* @__PURE__ */ jsxs(Box8, { sx: { display: "flex", alignItems: "center", mb: 1 }, children: [
665
+ /* @__PURE__ */ jsx(CalendarTodayIcon, { sx: { mr: 1, color: "primary.main" } }),
666
+ /* @__PURE__ */ jsxs(Typography6, { variant: "body2", children: [
667
+ /* @__PURE__ */ jsx("strong", { children: "Date:" }),
668
+ " ",
669
+ formattedDate
670
+ ] })
671
+ ] }),
672
+ /* @__PURE__ */ jsxs(Box8, { sx: { display: "flex", alignItems: "center" }, children: [
673
+ /* @__PURE__ */ jsx(LocationOnIcon, { sx: { mr: 1, color: "primary.main" } }),
674
+ /* @__PURE__ */ jsxs(Typography6, { variant: "body2", children: [
675
+ /* @__PURE__ */ jsx("strong", { children: "Location:" }),
676
+ " ",
677
+ location
678
+ ] })
502
679
  ] }),
503
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", mb: 1 }, children: [
504
- /* @__PURE__ */ jsx(LocationOnIcon, { sx: { mr: 1, fontSize: "small", color: "text.secondary" } }),
505
- /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: location })
680
+ result.organizer && /* @__PURE__ */ jsxs(Typography6, { variant: "body2", sx: { mt: 1 }, children: [
681
+ /* @__PURE__ */ jsx("strong", { children: "Organizer:" }),
682
+ " ",
683
+ result.organizer
506
684
  ] })
507
685
  ] }) });
508
686
  };
@@ -510,10 +688,12 @@ var EventResultCard_default = EventResultCard;
510
688
  var ResultsContainer = ({
511
689
  results,
512
690
  onResultClick,
513
- tags
691
+ tags,
692
+ pagination,
693
+ onPacketChange
514
694
  }) => {
515
- if (results.length === 0 || !results.map) {
516
- return /* @__PURE__ */ jsx(Box2, { sx: { textAlign: "center", py: 4 }, children: "No results found. Try adjusting your filters." });
695
+ if (!results || results.length === 0 || !results.map) {
696
+ return /* @__PURE__ */ jsx(Box8, { sx: { textAlign: "center", py: 4 }, children: "No results found. Try adjusting your filters." });
517
697
  }
518
698
  const onPlayerClick = (id) => {
519
699
  onResultClick == null ? void 0 : onResultClick(id, "player");
@@ -524,43 +704,68 @@ var ResultsContainer = ({
524
704
  const onEventClick = (id) => {
525
705
  onResultClick == null ? void 0 : onResultClick(id, "event");
526
706
  };
527
- return /* @__PURE__ */ jsx(Box2, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: results.map((result) => {
528
- switch (result.type) {
529
- case "player":
530
- return /* @__PURE__ */ jsx(
531
- PlayerResultCard_default,
532
- {
533
- result,
534
- onClick: onPlayerClick,
535
- tags
536
- },
537
- result.id
538
- );
539
- case "table":
540
- return /* @__PURE__ */ jsx(
541
- TableResultCard_default,
542
- {
543
- result,
544
- onClick: onTableClick,
545
- tags
546
- },
547
- result.id
548
- );
549
- case "event":
550
- return /* @__PURE__ */ jsx(
551
- EventResultCard_default,
552
- {
553
- result,
554
- onClick: onEventClick,
555
- tags
556
- },
557
- result.id
558
- );
559
- default:
560
- console.error(`Unknown result type: ${result.type}`);
561
- return null;
562
- }
563
- }) });
707
+ const handlePacketChange = (_event, packet) => {
708
+ onPacketChange == null ? void 0 : onPacketChange(packet);
709
+ };
710
+ const startResult = pagination ? (pagination.currentPacket - 1) * pagination.packetSize + 1 : 1;
711
+ const endResult = pagination ? Math.min(pagination.currentPacket * pagination.packetSize, pagination.totalResults) : results.length;
712
+ return /* @__PURE__ */ jsxs(Box8, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
713
+ pagination && /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 1 }, children: /* @__PURE__ */ jsxs(Typography6, { variant: "body2", color: "text.secondary", children: [
714
+ "Showing ",
715
+ startResult,
716
+ "-",
717
+ endResult,
718
+ " of ",
719
+ pagination.totalResults,
720
+ " results"
721
+ ] }) }),
722
+ results.map((result) => {
723
+ switch (result.type) {
724
+ case "player":
725
+ return /* @__PURE__ */ jsx(
726
+ PlayerResultCard_default,
727
+ {
728
+ result,
729
+ onClick: onPlayerClick,
730
+ tags
731
+ },
732
+ result.id
733
+ );
734
+ case "table":
735
+ return /* @__PURE__ */ jsx(
736
+ TableResultCard_default,
737
+ {
738
+ result,
739
+ onClick: onTableClick,
740
+ tags
741
+ },
742
+ result.id
743
+ );
744
+ case "event":
745
+ return /* @__PURE__ */ jsx(
746
+ EventResultCard_default,
747
+ {
748
+ result,
749
+ onClick: onEventClick,
750
+ tags
751
+ },
752
+ result.id
753
+ );
754
+ default:
755
+ console.error(`Unknown result type: ${result.type}`);
756
+ return null;
757
+ }
758
+ }),
759
+ pagination && pagination.totalPackets > 1 && /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", justifyContent: "center", mt: 4 }, children: /* @__PURE__ */ jsx(
760
+ Pagination,
761
+ {
762
+ count: pagination.totalPackets,
763
+ page: pagination.currentPacket,
764
+ onChange: handlePacketChange,
765
+ color: "primary"
766
+ }
767
+ ) })
768
+ ] });
564
769
  };
565
770
  var ResultsContainer_default = ResultsContainer;
566
771
  var ScrollableResultsList = ({
@@ -571,7 +776,7 @@ var ScrollableResultsList = ({
571
776
  emptyText
572
777
  }) => {
573
778
  const hasResults = Array.isArray(results) && results.length > 0;
574
- return /* @__PURE__ */ jsx(Box2, { sx: { maxHeight, overflowY: "auto", pr: 1 }, children: hasResults ? /* @__PURE__ */ jsx(ResultsContainer_default, { results, onResultClick, tags }) : /* @__PURE__ */ jsx(Box2, { sx: { textAlign: "center", py: 2 }, children: emptyText || "No results to display." }) });
779
+ return /* @__PURE__ */ jsx(Box8, { sx: { maxHeight, overflowY: "auto", pr: 1 }, children: hasResults ? /* @__PURE__ */ jsx(ResultsContainer_default, { results, onResultClick, tags }) : /* @__PURE__ */ jsx(Box8, { sx: { textAlign: "center", py: 2 }, children: emptyText || "No results to display." }) });
575
780
  };
576
781
  var ScrollableResultsList_default = ScrollableResultsList;
577
782
  var PlayersScrollableList = ({
@@ -606,17 +811,76 @@ var SearchResultCard_default = SearchResultCard;
606
811
  function SearchPageLayout({
607
812
  results,
608
813
  title = "Search Results",
814
+ initialSelectedTypes = [],
815
+ initialSelectedTags = {
816
+ mustHave: [],
817
+ mustNotHave: [],
818
+ shouldHaveAtLeastOne: []
819
+ },
820
+ initialTextSearch = {
821
+ query: "",
822
+ titleOnly: false
823
+ },
824
+ includeExpiredTables: initialIncludeExpiredTables = false,
609
825
  onTypeChange,
610
826
  onTagChange,
827
+ onTextSearchChange,
828
+ onIncludeExpiredTablesChange,
611
829
  onSubmit,
612
830
  onResultClick,
831
+ onPacketChange,
832
+ pagination,
613
833
  validTags,
614
- allTags
834
+ allTags,
835
+ searchTypes,
836
+ isLoading = false
615
837
  }) {
616
- "use client";
617
838
  const theme = useTheme();
618
839
  const isMobile = useMediaQuery(theme.breakpoints.down("md"));
619
- return /* @__PURE__ */ jsxs(Box2, { sx: { padding: 2 }, children: [
840
+ const [selectedTypes, setSelectedTypes] = useState(initialSelectedTypes);
841
+ const [selectedTags, setSelectedTags] = useState(initialSelectedTags);
842
+ const [textSearch, setTextSearch] = useState(initialTextSearch);
843
+ const [includeExpiredTables, setIncludeExpiredTables] = useState(initialIncludeExpiredTables);
844
+ useEffect(() => {
845
+ setSelectedTypes(initialSelectedTypes);
846
+ }, [initialSelectedTypes]);
847
+ useEffect(() => {
848
+ setSelectedTags(initialSelectedTags);
849
+ }, [initialSelectedTags]);
850
+ useEffect(() => {
851
+ setTextSearch(initialTextSearch);
852
+ }, [initialTextSearch]);
853
+ useEffect(() => {
854
+ setIncludeExpiredTables(initialIncludeExpiredTables);
855
+ }, [initialIncludeExpiredTables]);
856
+ const handleTypeChange = (types) => {
857
+ setSelectedTypes(types);
858
+ if (onTypeChange) onTypeChange(types);
859
+ };
860
+ const handleTagChange = (tags) => {
861
+ setSelectedTags(tags);
862
+ if (onTagChange) onTagChange(tags);
863
+ };
864
+ const handleTextSearchChange = (ts) => {
865
+ setTextSearch(ts);
866
+ if (onTextSearchChange) onTextSearchChange(ts);
867
+ };
868
+ const handleIncludeExpiredTablesChange = (include) => {
869
+ setIncludeExpiredTables(include);
870
+ if (onIncludeExpiredTablesChange) onIncludeExpiredTablesChange(include);
871
+ };
872
+ const handleSubmit = () => {
873
+ const currentCriteria = {
874
+ selectedTypes,
875
+ selectedTags,
876
+ textSearch,
877
+ includeExpiredTables
878
+ };
879
+ if (onSubmit) {
880
+ onSubmit(currentCriteria);
881
+ }
882
+ };
883
+ return /* @__PURE__ */ jsxs(Box8, { sx: { padding: 2 }, children: [
620
884
  /* @__PURE__ */ jsx(Card2, { sx: { marginBottom: 2 }, children: /* @__PURE__ */ jsx(
621
885
  CardHeader,
622
886
  {
@@ -646,10 +910,17 @@ function SearchPageLayout({
646
910
  /* @__PURE__ */ jsx(CardContent2, { children: /* @__PURE__ */ jsx(
647
911
  FiltersContainer_default,
648
912
  {
649
- onTypeChange,
650
- onTagChange,
651
- onSubmit,
652
- tags: validTags
913
+ initialSelectedTypes: selectedTypes,
914
+ initialSelectedTags: selectedTags,
915
+ initialTextSearch: textSearch,
916
+ includeExpiredTables,
917
+ onTypeChange: handleTypeChange,
918
+ onTagChange: handleTagChange,
919
+ onTextSearchChange: handleTextSearchChange,
920
+ onIncludeExpiredTablesChange: handleIncludeExpiredTablesChange,
921
+ onSubmit: handleSubmit,
922
+ tags: validTags,
923
+ searchTypes
653
924
  }
654
925
  ) })
655
926
  ] }) }),
@@ -666,10 +937,12 @@ function SearchPageLayout({
666
937
  }
667
938
  }
668
939
  ),
669
- /* @__PURE__ */ jsx(CardContent2, { children: /* @__PURE__ */ jsx(
940
+ /* @__PURE__ */ jsx(CardContent2, { children: isLoading ? /* @__PURE__ */ jsx(Box8, { sx: { display: "flex", justifyContent: "center", py: 8 }, children: /* @__PURE__ */ jsx(CircularProgress, { size: 60, thickness: 4 }) }) : /* @__PURE__ */ jsx(
670
941
  ResultsContainer_default,
671
942
  {
672
943
  results,
944
+ pagination,
945
+ onPacketChange,
673
946
  onResultClick,
674
947
  tags: allTags
675
948
  }
@@ -682,21 +955,14 @@ var TablesScrollableList = ({
682
955
  results,
683
956
  tags,
684
957
  maxHeight,
685
- onResultClick,
686
- sortBy = "availability"
958
+ onResultClick
687
959
  }) => {
688
960
  const tables = (results || []).filter((r) => (r == null ? void 0 : r.type) === "table");
689
- const getAvailableSlots = (r) => {
690
- const capacity = typeof r.capacity === "number" ? r.capacity : 0;
691
- const playersCount = typeof r.numPlayers === "number" ? r.numPlayers : 0;
692
- return Math.max(capacity - playersCount, 0);
693
- };
694
- const sortedTables = sortBy === "availability" ? [...tables].sort((a, b) => getAvailableSlots(b) - getAvailableSlots(a)) : tables;
695
961
  const handleClick = (id) => onResultClick == null ? void 0 : onResultClick(id);
696
962
  return /* @__PURE__ */ jsx(
697
963
  ScrollableResultsList_default,
698
964
  {
699
- results: sortedTables,
965
+ results: tables,
700
966
  tags,
701
967
  maxHeight,
702
968
  onResultClick: (id, type) => {
@@ -707,6 +973,6 @@ var TablesScrollableList = ({
707
973
  };
708
974
  var TablesScrollableList_default = TablesScrollableList;
709
975
 
710
- export { BaseSearchResultCard_default as BaseSearchResultCard, EventResultCard_default as EventResultCard, FiltersContainer_default as FiltersContainer, PlayerResultCard_default as PlayerResultCard, PlayersScrollableList_default as PlayersScrollableList, ResultsContainer_default as ResultsContainer, ScrollableResultsList_default as ScrollableResultsList, SearchPageLayout, SearchResultCard_default as SearchResultCard, SortOptions_default as SortOptions, TableResultCard_default as TableResultCard, TablesScrollableList_default as TablesScrollableList, TagsFilter_default as TagsFilter, TypeFilter_default as TypeFilter };
976
+ export { BaseSearchResultCard_default as BaseSearchResultCard, EventResultCard_default as EventResultCard, ExpiredTablesFilter_default as ExpiredTablesFilter, FiltersContainer_default as FiltersContainer, PlayerResultCard_default as PlayerResultCard, PlayersScrollableList_default as PlayersScrollableList, ResultsContainer_default as ResultsContainer, ScrollableResultsList_default as ScrollableResultsList, SearchPageLayout, SearchResultCard_default as SearchResultCard, SortOptions_default as SortOptions, TableResultCard_default as TableResultCard, TablesScrollableList_default as TablesScrollableList, TagsFilter_default as TagsFilter, TextSearchCard_default as TextSearchCard, TypeFilter_default as TypeFilter };
711
977
  //# sourceMappingURL=index.mjs.map
712
978
  //# sourceMappingURL=index.mjs.map