@bsol-oss/react-datatable5 7.1.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +24 -7
- package/dist/index.js +578 -481
- package/dist/index.mjs +581 -486
- package/dist/types/components/DataTable/DataTable.d.ts +1 -1
- package/dist/types/components/DataTable/DataTableServer.d.ts +1 -2
- package/dist/types/components/DataTable/TableControls.d.ts +3 -2
- package/dist/types/components/DataTable/TableFilters.d.ts +1 -0
- package/dist/types/components/DataTable/components/EmptyState.d.ts +5 -0
- package/dist/types/components/DataTable/components/ErrorAlert.d.ts +4 -0
- package/dist/types/components/DataTable/context/DataTableContext.d.ts +1 -0
- package/dist/types/components/Form/Form.d.ts +6 -1
- package/dist/types/components/Form/components/EnumPicker.d.ts +5 -0
- package/dist/types/index.d.ts +3 -1
- package/package.json +6 -4
package/dist/index.js
CHANGED
|
@@ -6,8 +6,11 @@ var ai = require('react-icons/ai');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var md = require('react-icons/md');
|
|
8
8
|
var lu = require('react-icons/lu');
|
|
9
|
-
var
|
|
9
|
+
var Dayzed = require('@bsol-oss/dayzed-react19');
|
|
10
|
+
var fa6 = require('react-icons/fa6');
|
|
10
11
|
var bi = require('react-icons/bi');
|
|
12
|
+
var cg = require('react-icons/cg');
|
|
13
|
+
var io = require('react-icons/io');
|
|
11
14
|
var hi2 = require('react-icons/hi2');
|
|
12
15
|
var reactTable = require('@tanstack/react-table');
|
|
13
16
|
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
@@ -16,12 +19,10 @@ var gr = require('react-icons/gr');
|
|
|
16
19
|
var reactQuery = require('@tanstack/react-query');
|
|
17
20
|
var io5 = require('react-icons/io5');
|
|
18
21
|
var hi = require('react-icons/hi');
|
|
19
|
-
var Dayzed = require('@bsol-oss/dayzed-react19');
|
|
20
|
-
var fa6 = require('react-icons/fa6');
|
|
21
|
-
var cg = require('react-icons/cg');
|
|
22
22
|
var adapter = require('@atlaskit/pragmatic-drag-and-drop/element/adapter');
|
|
23
23
|
var invariant = require('tiny-invariant');
|
|
24
24
|
var axios = require('axios');
|
|
25
|
+
var usehooks = require('@uidotdev/usehooks');
|
|
25
26
|
var reactHookForm = require('react-hook-form');
|
|
26
27
|
var dayjs = require('dayjs');
|
|
27
28
|
var adapter$1 = require('@atlaskit/pragmatic-drag-and-drop/external/adapter');
|
|
@@ -51,6 +52,7 @@ const DataTableContext = React.createContext({
|
|
|
51
52
|
table: {},
|
|
52
53
|
globalFilter: "",
|
|
53
54
|
setGlobalFilter: () => { },
|
|
55
|
+
type: "client",
|
|
54
56
|
});
|
|
55
57
|
|
|
56
58
|
const useDataTableContext = () => {
|
|
@@ -92,13 +94,363 @@ react.Dialog.Description;
|
|
|
92
94
|
const DialogTrigger = react.Dialog.Trigger;
|
|
93
95
|
const DialogActionTrigger = react.Dialog.ActionTrigger;
|
|
94
96
|
|
|
97
|
+
const Radio = React__namespace.forwardRef(function Radio(props, ref) {
|
|
98
|
+
const { children, inputProps, rootRef, ...rest } = props;
|
|
99
|
+
return (jsxRuntime.jsxs(react.RadioGroup.Item, { ref: rootRef, ...rest, children: [jsxRuntime.jsx(react.RadioGroup.ItemHiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsx(react.RadioGroup.ItemIndicator, {}), children && (jsxRuntime.jsx(react.RadioGroup.ItemText, { children: children }))] }));
|
|
100
|
+
});
|
|
101
|
+
const RadioGroup = react.RadioGroup.Root;
|
|
102
|
+
|
|
103
|
+
const monthNamesFull = [
|
|
104
|
+
"January",
|
|
105
|
+
"February",
|
|
106
|
+
"March",
|
|
107
|
+
"April",
|
|
108
|
+
"May",
|
|
109
|
+
"June",
|
|
110
|
+
"July",
|
|
111
|
+
"August",
|
|
112
|
+
"September",
|
|
113
|
+
"October",
|
|
114
|
+
"November",
|
|
115
|
+
"December",
|
|
116
|
+
];
|
|
117
|
+
const weekdayNamesShort$1 = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
118
|
+
function Calendar$1({ calendars, getBackProps, getForwardProps, getDateProps, selected = [], firstDayOfWeek = 0, }) {
|
|
119
|
+
const [hoveredDate, setHoveredDate] = React.useState();
|
|
120
|
+
const onMouseLeave = () => {
|
|
121
|
+
setHoveredDate(undefined);
|
|
122
|
+
};
|
|
123
|
+
const onMouseEnter = (date) => {
|
|
124
|
+
setHoveredDate(date);
|
|
125
|
+
};
|
|
126
|
+
const isInRange = (date) => {
|
|
127
|
+
if (selected.length) {
|
|
128
|
+
const firstSelected = selected[0].getTime();
|
|
129
|
+
if (selected.length === 2) {
|
|
130
|
+
const secondSelected = selected[1].getTime();
|
|
131
|
+
return (firstSelected < date.getTime() && secondSelected > date.getTime());
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return !!(hoveredDate &&
|
|
135
|
+
((firstSelected < date.getTime() &&
|
|
136
|
+
hoveredDate.getTime() >= date.getTime()) ||
|
|
137
|
+
(date.getTime() < firstSelected &&
|
|
138
|
+
date.getTime() >= hoveredDate.getTime())));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
};
|
|
143
|
+
if (calendars.length) {
|
|
144
|
+
return (jsxRuntime.jsxs(react.Grid, { onMouseLeave: onMouseLeave, children: [jsxRuntime.jsxs(react.Grid, { templateColumns: "repeat(4, auto)", justifyContent: "center", children: [jsxRuntime.jsx(react.Button, { variant: "ghost", ...getBackProps({
|
|
145
|
+
calendars,
|
|
146
|
+
offset: 12,
|
|
147
|
+
}), children: "<<" }), jsxRuntime.jsx(react.Button, { variant: "ghost", ...getBackProps({ calendars }), children: "Back" }), jsxRuntime.jsx(react.Button, { variant: "ghost", ...getForwardProps({ calendars }), children: "Next" }), jsxRuntime.jsx(react.Button, { variant: "ghost", ...getForwardProps({
|
|
148
|
+
calendars,
|
|
149
|
+
offset: 12,
|
|
150
|
+
}), children: ">>" })] }), jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(2, auto)", justifyContent: "center", gap: 4, children: calendars.map((calendar) => (jsxRuntime.jsxs(react.Grid, { gap: 4, children: [jsxRuntime.jsxs(react.Grid, { justifyContent: "center", children: [monthNamesFull[calendar.month], " ", calendar.year] }), jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(7, auto)", justifyContent: "center", children: [0, 1, 2, 3, 4, 5, 6].map((weekdayNum) => {
|
|
151
|
+
const weekday = (weekdayNum + firstDayOfWeek) % 7;
|
|
152
|
+
return (jsxRuntime.jsx(react.Box, { minWidth: "48px", textAlign: "center", children: weekdayNamesShort$1[weekday] }, `${calendar.month}${calendar.year}${weekday}`));
|
|
153
|
+
}) }), jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(7, auto)", justifyContent: "center", children: calendar.weeks.map((week, windex) => week.map((dateObj, index) => {
|
|
154
|
+
const key = `${calendar.month}${calendar.year}${windex}${index}`;
|
|
155
|
+
if (!dateObj) {
|
|
156
|
+
return jsxRuntime.jsx(react.Box, {}, key);
|
|
157
|
+
}
|
|
158
|
+
const { date, selected, selectable, today } = dateObj;
|
|
159
|
+
const getStyle = ({ selected, unavailable, today, isInRange, }) => {
|
|
160
|
+
if (unavailable) {
|
|
161
|
+
return {
|
|
162
|
+
colorPalette: "gray",
|
|
163
|
+
variant: "solid",
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (selected) {
|
|
167
|
+
return {
|
|
168
|
+
colorPalette: "blue",
|
|
169
|
+
variant: "solid",
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (isInRange) {
|
|
173
|
+
return {
|
|
174
|
+
colorPalette: "blue",
|
|
175
|
+
variant: "subtle",
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (today) {
|
|
179
|
+
return {
|
|
180
|
+
colorPalette: "green",
|
|
181
|
+
variant: "solid",
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return { variant: "ghost" };
|
|
185
|
+
};
|
|
186
|
+
return (jsxRuntime.jsx(react.Button, { ...getDateProps({
|
|
187
|
+
dateObj,
|
|
188
|
+
onMouseEnter: () => {
|
|
189
|
+
onMouseEnter(date);
|
|
190
|
+
},
|
|
191
|
+
}), ...getStyle({
|
|
192
|
+
selected,
|
|
193
|
+
unavailable: !selectable,
|
|
194
|
+
today,
|
|
195
|
+
isInRange: isInRange(date),
|
|
196
|
+
}), children: selectable ? date.getDate() : "X" }, key));
|
|
197
|
+
})) })] }, `${calendar.month}${calendar.year}`))) })] }));
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
class RangeDatePicker extends React.Component {
|
|
202
|
+
render() {
|
|
203
|
+
return (jsxRuntime.jsx(Dayzed, { onDateSelected: this.props.onDateSelected, selected: this.props.selected, firstDayOfWeek: this.props.firstDayOfWeek, showOutsideDays: this.props.showOutsideDays, date: this.props.date, minDate: this.props.minDate, maxDate: this.props.maxDate, monthsToDisplay: this.props.monthsToDisplay, render: (dayzedData) => (jsxRuntime.jsx(Calendar$1, { ...dayzedData,
|
|
204
|
+
firstDayOfWeek: this.props.firstDayOfWeek,
|
|
205
|
+
selected: this.props.selected })) }));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const getRangeDates = ({ selectable, date, selectedDates, }) => {
|
|
210
|
+
if (!selectable) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const dateTime = date.getTime();
|
|
214
|
+
const newDates = [...selectedDates];
|
|
215
|
+
if (selectedDates.length) {
|
|
216
|
+
if (selectedDates.length === 1) {
|
|
217
|
+
const firstTime = selectedDates[0].getTime();
|
|
218
|
+
if (firstTime < dateTime) {
|
|
219
|
+
newDates.push(date);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
newDates.unshift(date);
|
|
223
|
+
}
|
|
224
|
+
return newDates;
|
|
225
|
+
}
|
|
226
|
+
else if (newDates.length === 2) {
|
|
227
|
+
return [date];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
newDates.push(date);
|
|
232
|
+
return newDates;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const Slider = React__namespace.forwardRef(function Slider(props, ref) {
|
|
237
|
+
const { marks: marksProp, label, showValue, ...rest } = props;
|
|
238
|
+
const value = props.defaultValue ?? props.value;
|
|
239
|
+
const marks = marksProp?.map((mark) => {
|
|
240
|
+
if (typeof mark === "number")
|
|
241
|
+
return { value: mark, label: undefined };
|
|
242
|
+
return mark;
|
|
243
|
+
});
|
|
244
|
+
const hasMarkLabel = !!marks?.some((mark) => mark.label);
|
|
245
|
+
return (jsxRuntime.jsxs(react.Slider.Root, { ref: ref, thumbAlignment: "center", ...rest, children: [label && !showValue && (jsxRuntime.jsx(react.Slider.Label, { children: label })), label && showValue && (jsxRuntime.jsxs(react.HStack, { justify: "space-between", children: [jsxRuntime.jsx(react.Slider.Label, { children: label }), jsxRuntime.jsx(react.Slider.ValueText, {})] })), jsxRuntime.jsxs(react.Slider.Control, { "data-has-mark-label": hasMarkLabel || undefined, children: [jsxRuntime.jsx(react.Slider.Track, { children: jsxRuntime.jsx(react.Slider.Range, {}) }), jsxRuntime.jsx(SliderThumbs, { value: value }), jsxRuntime.jsx(SliderMarks, { marks: marks })] })] }));
|
|
246
|
+
});
|
|
247
|
+
function SliderThumbs(props) {
|
|
248
|
+
const { value } = props;
|
|
249
|
+
return (jsxRuntime.jsx(react.For, { each: value, children: (_, index) => (jsxRuntime.jsx(react.Slider.Thumb, { index: index, children: jsxRuntime.jsx(react.Slider.HiddenInput, {}) }, index)) }));
|
|
250
|
+
}
|
|
251
|
+
const SliderMarks = React__namespace.forwardRef(function SliderMarks(props, ref) {
|
|
252
|
+
const { marks } = props;
|
|
253
|
+
if (!marks?.length)
|
|
254
|
+
return null;
|
|
255
|
+
return (jsxRuntime.jsx(react.Slider.MarkerGroup, { ref: ref, children: marks.map((mark, index) => {
|
|
256
|
+
const value = typeof mark === "number" ? mark : mark.value;
|
|
257
|
+
const label = typeof mark === "number" ? undefined : mark.label;
|
|
258
|
+
return (jsxRuntime.jsxs(react.Slider.Marker, { value: value, children: [jsxRuntime.jsx(react.Slider.MarkerIndicator, {}), label] }, index));
|
|
259
|
+
}) }));
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
const RangeFilter = ({ range, setRange, defaultValue, min, max, step, }) => {
|
|
263
|
+
return (jsxRuntime.jsxs(react.Flex, { p: 2, gap: 2, flexFlow: 'column', children: [jsxRuntime.jsx(react.Text, { children: `${range[0]} - ${range[1]}` }), jsxRuntime.jsx(Slider, { width: "full", min: min, max: max, defaultValue: defaultValue, step: step, name: `Selected Range: ${range[0]} - ${range[1]}`,
|
|
264
|
+
// value={field.value}
|
|
265
|
+
onValueChange: (val) => setRange(val.value) })] }));
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const Tag = React__namespace.forwardRef(function Tag(props, ref) {
|
|
269
|
+
const { startElement, endElement, onClose, closable = !!onClose, children, ...rest } = props;
|
|
270
|
+
return (jsxRuntime.jsxs(react.Tag.Root, { ref: ref, ...rest, children: [startElement && (jsxRuntime.jsx(react.Tag.StartElement, { children: startElement })), jsxRuntime.jsx(react.Tag.Label, { children: children }), endElement && (jsxRuntime.jsx(react.Tag.EndElement, { children: endElement })), closable && (jsxRuntime.jsx(react.Tag.EndElement, { children: jsxRuntime.jsx(react.Tag.CloseTrigger, { onClick: onClose }) }))] }));
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const TagFilter = ({ availableTags, selectedTags, onTagChange, }) => {
|
|
274
|
+
const toggleTag = (tag) => {
|
|
275
|
+
if (selectedTags.includes(tag)) {
|
|
276
|
+
onTagChange(selectedTags.filter((t) => t !== tag));
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
onTagChange([...selectedTags, tag]);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
return (jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", p: "0.5rem", gap: "0.5rem", children: availableTags.map((tag) => (jsxRuntime.jsx(Tag, { variant: selectedTags.includes(tag) ? "solid" : "outline", cursor: "pointer", closable: selectedTags.includes(tag) ? true : undefined, onClick: () => toggleTag(tag), children: tag }))) }));
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const Filter = ({ column }) => {
|
|
286
|
+
const { filterVariant } = column.columnDef.meta ?? {};
|
|
287
|
+
const displayName = column.columnDef.meta?.displayName ?? column.id;
|
|
288
|
+
const filterOptions = column.columnDef.meta?.filterOptions ?? [];
|
|
289
|
+
if (column.columns.length > 0) {
|
|
290
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 1, children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(20rem, 1fr))", gap: 1, children: column.columns.map((column) => {
|
|
291
|
+
return jsxRuntime.jsx(Filter, { column: column }, column.id);
|
|
292
|
+
}) }, column.id)] }));
|
|
293
|
+
}
|
|
294
|
+
if (!column.getCanFilter()) {
|
|
295
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
296
|
+
}
|
|
297
|
+
if (filterVariant === "select") {
|
|
298
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(RadioGroup, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onValueChange: (details) => {
|
|
299
|
+
column.setFilterValue(details.value);
|
|
300
|
+
}, children: jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: "0.5rem", children: filterOptions.map((item) => (jsxRuntime.jsx(Radio, { value: item, children: item }, item))) }) })] }, column.id));
|
|
301
|
+
}
|
|
302
|
+
if (filterVariant === "tag") {
|
|
303
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(TagFilter, { availableTags: filterOptions, selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
304
|
+
if (tags.length === 0) {
|
|
305
|
+
return column.setFilterValue(undefined);
|
|
306
|
+
}
|
|
307
|
+
column.setFilterValue(tags);
|
|
308
|
+
} })] }, column.id));
|
|
309
|
+
}
|
|
310
|
+
if (filterVariant === "boolean") {
|
|
311
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(TagFilter, { availableTags: ["true", "false"], selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
312
|
+
if (tags.length === 0) {
|
|
313
|
+
return column.setFilterValue(undefined);
|
|
314
|
+
}
|
|
315
|
+
column.setFilterValue(tags);
|
|
316
|
+
} })] }, column.id));
|
|
317
|
+
}
|
|
318
|
+
if (filterVariant === "range") {
|
|
319
|
+
const filterValue = column.getFilterValue() ?? [
|
|
320
|
+
undefined,
|
|
321
|
+
undefined,
|
|
322
|
+
];
|
|
323
|
+
const { min, max, step, defaultValue } = column.columnDef.meta
|
|
324
|
+
?.filterRangeConfig ?? {
|
|
325
|
+
min: 0,
|
|
326
|
+
max: 100,
|
|
327
|
+
step: 1,
|
|
328
|
+
defaultValue: [4, 50],
|
|
329
|
+
};
|
|
330
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(RangeFilter, { range: filterValue, setRange: function (value) {
|
|
331
|
+
// throw new Error("Function not implemented.");
|
|
332
|
+
column.setFilterValue(value);
|
|
333
|
+
}, defaultValue: defaultValue, min: min, max: max, step: step })] }, column.id));
|
|
334
|
+
}
|
|
335
|
+
if (filterVariant === "dateRange") {
|
|
336
|
+
const filterValue = column.getFilterValue() ?? [];
|
|
337
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(RangeDatePicker, { selected: filterValue, onDateSelected: ({ selected, selectable, date }) => {
|
|
338
|
+
const newDates = getRangeDates({
|
|
339
|
+
selectable,
|
|
340
|
+
date,
|
|
341
|
+
selectedDates: filterValue,
|
|
342
|
+
}) ?? [];
|
|
343
|
+
column.setFilterValue(() => {
|
|
344
|
+
return newDates;
|
|
345
|
+
});
|
|
346
|
+
} })] }, column.id));
|
|
347
|
+
}
|
|
348
|
+
if (filterVariant === "custom") {
|
|
349
|
+
const renderFilter = column.columnDef.meta?.renderFilter;
|
|
350
|
+
if (renderFilter === undefined) {
|
|
351
|
+
throw new Error("renderFilter is undefined");
|
|
352
|
+
}
|
|
353
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderFilter(column) });
|
|
354
|
+
}
|
|
355
|
+
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(react.Input, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onChange: (e) => {
|
|
356
|
+
column.setFilterValue(e.target.value);
|
|
357
|
+
} })] }, column.id));
|
|
358
|
+
};
|
|
359
|
+
const TableFilter = () => {
|
|
360
|
+
const { table } = useDataTableContext();
|
|
361
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getAllColumns().map((column) => {
|
|
362
|
+
return jsxRuntime.jsx(Filter, { column: column }, column.id);
|
|
363
|
+
}) }));
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
367
|
+
const { table } = useDataTableContext();
|
|
368
|
+
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
369
|
+
table.resetColumnFilters();
|
|
370
|
+
}, children: text }));
|
|
371
|
+
};
|
|
372
|
+
|
|
95
373
|
const EditFilterButton = ({ text, title = "Edit Filter", closeText = "Close", resetText = "Reset", icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
|
|
96
374
|
const filterModal = react.useDisclosure();
|
|
97
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: jsxRuntime.jsxs(DialogRoot, { children: [jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant:
|
|
375
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(DialogRoot, { size: ["full", "full", "md", "md"], open: filterModal.open, children: jsxRuntime.jsxs(DialogRoot, { children: [jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", onClick: filterModal.onOpen, children: [icon, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogHeader, { children: jsxRuntime.jsx(DialogTitle, { children: title }) }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "1rem", children: [jsxRuntime.jsx(TableFilter, {}), jsxRuntime.jsx(ResetFilteringButton, { text: resetText })] }) }), jsxRuntime.jsxs(DialogFooter, { children: [jsxRuntime.jsx(DialogActionTrigger, { asChild: true, children: jsxRuntime.jsx(react.Button, { onClick: filterModal.onClose, children: closeText }) }), jsxRuntime.jsx(react.Button, { children: "Save" })] }), jsxRuntime.jsx(DialogCloseTrigger, {})] })] }) }) }));
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const ColumnOrderChanger = ({ columns }) => {
|
|
379
|
+
const [order, setOrder] = React.useState([]);
|
|
380
|
+
const [originalOrder, setOriginalOrder] = React.useState([]);
|
|
381
|
+
const { table } = useDataTableContext();
|
|
382
|
+
const handleChangeOrder = (startIndex, endIndex) => {
|
|
383
|
+
const newOrder = Array.from(order);
|
|
384
|
+
const [removed] = newOrder.splice(startIndex, 1);
|
|
385
|
+
newOrder.splice(endIndex, 0, removed);
|
|
386
|
+
setOrder(newOrder);
|
|
387
|
+
};
|
|
388
|
+
React.useEffect(() => {
|
|
389
|
+
setOrder(columns);
|
|
390
|
+
}, [columns]);
|
|
391
|
+
React.useEffect(() => {
|
|
392
|
+
if (originalOrder.length > 0) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (columns.length <= 0) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
setOriginalOrder(columns);
|
|
399
|
+
}, [columns]);
|
|
400
|
+
return (jsxRuntime.jsxs(react.Flex, { gap: 2, flexFlow: "column", children: [jsxRuntime.jsx(react.Flex, { gap: 2, flexFlow: "column", children: order.map((columnId, index) => (jsxRuntime.jsxs(react.Flex, { gap: 2, alignItems: "center", justifyContent: "space-between", children: [jsxRuntime.jsx(react.IconButton, { onClick: () => {
|
|
401
|
+
const prevIndex = index - 1;
|
|
402
|
+
if (prevIndex >= 0) {
|
|
403
|
+
handleChangeOrder(index, prevIndex);
|
|
404
|
+
}
|
|
405
|
+
}, disabled: index === 0, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowUpward, {}) }), table
|
|
406
|
+
.getAllFlatColumns()
|
|
407
|
+
.filter((column) => {
|
|
408
|
+
return column.id === columnId;
|
|
409
|
+
})
|
|
410
|
+
.map((column) => {
|
|
411
|
+
const displayName = column.columnDef.meta === undefined
|
|
412
|
+
? column.id
|
|
413
|
+
: column.columnDef.meta.displayName;
|
|
414
|
+
return jsxRuntime.jsx("span", { children: displayName }, column.id);
|
|
415
|
+
}), jsxRuntime.jsx(react.IconButton, { onClick: () => {
|
|
416
|
+
const nextIndex = index + 1;
|
|
417
|
+
if (nextIndex < order.length) {
|
|
418
|
+
handleChangeOrder(index, nextIndex);
|
|
419
|
+
}
|
|
420
|
+
}, disabled: index === order.length - 1, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowDownward, {}) })] }, columnId))) }), jsxRuntime.jsxs(react.Flex, { gap: "0.25rem", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
421
|
+
table.setColumnOrder(order);
|
|
422
|
+
}, children: "Apply" }), jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
423
|
+
table.setColumnOrder(originalOrder);
|
|
424
|
+
}, children: "Reset" })] })] }));
|
|
425
|
+
};
|
|
426
|
+
const TableOrderer = () => {
|
|
427
|
+
const { table } = useDataTableContext();
|
|
428
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ColumnOrderChanger, { columns: table.getState().columnOrder }) }));
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
const EditOrderButton = ({ text, icon = jsxRuntime.jsx(md.MdOutlineMoveDown, {}), title = "Change Order", }) => {
|
|
432
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(DialogRoot, { size: "cover", children: [jsxRuntime.jsx(react.DialogBackdrop, {}), jsxRuntime.jsx(DialogTrigger, { asChild: true, children: jsxRuntime.jsxs(react.Button, { as: react.Box, variant: "ghost", children: [icon, " ", text] }) }), jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsx(DialogCloseTrigger, {}), jsxRuntime.jsxs(DialogHeader, { children: [jsxRuntime.jsx(DialogTitle, {}), title] }), jsxRuntime.jsx(DialogBody, { children: jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.25rem", children: jsxRuntime.jsx(TableOrderer, {}) }) }), jsxRuntime.jsx(DialogFooter, {})] })] }) }));
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
const TableSorter = () => {
|
|
436
|
+
const { table } = useDataTableContext();
|
|
437
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: headerGroup.headers.map((header) => {
|
|
438
|
+
const displayName = header.column.columnDef.meta === undefined
|
|
439
|
+
? header.column.id
|
|
440
|
+
: header.column.columnDef.meta.displayName;
|
|
441
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: header.column.getCanSort() && (jsxRuntime.jsxs(react.Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsxs(react.Button, { variant: "ghost", onClick: () => {
|
|
442
|
+
header.column.toggleSorting();
|
|
443
|
+
}, children: [header.column.getIsSorted() === false && jsxRuntime.jsx(fa6.FaUpDown, {}), header.column.getIsSorted() === "asc" && jsxRuntime.jsx(bi.BiDownArrow, {}), header.column.getIsSorted() === "desc" && jsxRuntime.jsx(bi.BiUpArrow, {})] }), header.column.getIsSorted() && (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
444
|
+
header.column.clearSorting();
|
|
445
|
+
}, children: jsxRuntime.jsx(cg.CgClose, {}) }))] })) }));
|
|
446
|
+
}) }))) }));
|
|
98
447
|
};
|
|
99
448
|
|
|
100
|
-
const
|
|
101
|
-
|
|
449
|
+
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
450
|
+
const { table } = useDataTableContext();
|
|
451
|
+
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
452
|
+
table.resetSorting();
|
|
453
|
+
}, children: text }));
|
|
102
454
|
};
|
|
103
455
|
|
|
104
456
|
const EditSortingButton = ({ text, icon = jsxRuntime.jsx(md.MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
@@ -149,13 +501,6 @@ const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
|
149
501
|
}, children: pageSize }, `chakra-table-pageSize-${pageSize}`))) })] }) }));
|
|
150
502
|
};
|
|
151
503
|
|
|
152
|
-
const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
153
|
-
const { table } = useDataTableContext();
|
|
154
|
-
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
155
|
-
table.resetColumnFilters();
|
|
156
|
-
}, children: text }));
|
|
157
|
-
};
|
|
158
|
-
|
|
159
504
|
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
160
505
|
const { table } = useDataTableContext();
|
|
161
506
|
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
@@ -163,16 +508,15 @@ const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
|
163
508
|
}, children: text }));
|
|
164
509
|
};
|
|
165
510
|
|
|
166
|
-
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
167
|
-
const { table } = useDataTableContext();
|
|
168
|
-
return (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
169
|
-
table.resetSorting();
|
|
170
|
-
}, children: text }));
|
|
171
|
-
};
|
|
172
|
-
|
|
173
511
|
const RowCountText = () => {
|
|
174
|
-
const { table } = useDataTableContext();
|
|
175
|
-
|
|
512
|
+
const { table, type } = useDataTableContext();
|
|
513
|
+
const getCount = () => {
|
|
514
|
+
if (type === "client") {
|
|
515
|
+
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
516
|
+
}
|
|
517
|
+
return table.getRowCount();
|
|
518
|
+
};
|
|
519
|
+
return jsxRuntime.jsx(react.Text, { children: getCount() });
|
|
176
520
|
};
|
|
177
521
|
|
|
178
522
|
const { withContext } = react.createRecipeContext({ key: "button" });
|
|
@@ -241,17 +585,18 @@ React__namespace.forwardRef(function PaginationPageText(props, ref) {
|
|
|
241
585
|
|
|
242
586
|
// TODO: not working in client side
|
|
243
587
|
const TablePagination = () => {
|
|
244
|
-
const { table } = useDataTableContext();
|
|
245
|
-
|
|
588
|
+
const { table, type } = useDataTableContext();
|
|
589
|
+
const getCount = () => {
|
|
590
|
+
if (type === "client") {
|
|
591
|
+
return table.getFilteredRowModel().flatRows.length ?? 0;
|
|
592
|
+
}
|
|
593
|
+
return table.getRowCount();
|
|
594
|
+
};
|
|
595
|
+
return (jsxRuntime.jsx(PaginationRoot, { page: table.getState().pagination.pageIndex + 1, count: getCount(), pageSize: table.getState().pagination.pageSize, onPageChange: (e) => {
|
|
246
596
|
table.setPageIndex(e.page - 1);
|
|
247
597
|
}, children: jsxRuntime.jsxs(react.HStack, { children: [jsxRuntime.jsx(PaginationPrevTrigger, {}), jsxRuntime.jsx(PaginationItems, {}), jsxRuntime.jsx(PaginationNextTrigger, {})] }) }));
|
|
248
598
|
};
|
|
249
599
|
|
|
250
|
-
const Tag = React__namespace.forwardRef(function Tag(props, ref) {
|
|
251
|
-
const { startElement, endElement, onClose, closable = !!onClose, children, ...rest } = props;
|
|
252
|
-
return (jsxRuntime.jsxs(react.Tag.Root, { ref: ref, ...rest, children: [startElement && (jsxRuntime.jsx(react.Tag.StartElement, { children: startElement })), jsxRuntime.jsx(react.Tag.Label, { children: children }), endElement && (jsxRuntime.jsx(react.Tag.EndElement, { children: endElement })), closable && (jsxRuntime.jsx(react.Tag.EndElement, { children: jsxRuntime.jsx(react.Tag.CloseTrigger, { onClick: onClose }) }))] }));
|
|
253
|
-
});
|
|
254
|
-
|
|
255
600
|
const CardHeader = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, imageProps = {}, }) => {
|
|
256
601
|
if (!!row.original === false) {
|
|
257
602
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
@@ -389,7 +734,7 @@ const fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
389
734
|
// Return if the item should be filtered in/out
|
|
390
735
|
return itemRank.passed;
|
|
391
736
|
};
|
|
392
|
-
|
|
737
|
+
function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, children, }) {
|
|
393
738
|
const table = reactTable.useReactTable({
|
|
394
739
|
_features: [DensityFeature],
|
|
395
740
|
data: data,
|
|
@@ -436,24 +781,19 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
436
781
|
onDensityChange: setDensity,
|
|
437
782
|
onColumnVisibilityChange: setColumnVisibility,
|
|
438
783
|
});
|
|
439
|
-
React.useEffect(() => {
|
|
440
|
-
setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
|
|
441
|
-
}, [table, setColumnOrder]);
|
|
442
|
-
React.useEffect(() => {
|
|
443
|
-
onRowSelect(table.getState().rowSelection, data);
|
|
444
|
-
}, [data, onRowSelect, table]);
|
|
445
784
|
return (jsxRuntime.jsx(DataTableContext.Provider, { value: {
|
|
446
785
|
table: { ...table },
|
|
447
786
|
globalFilter: globalFilter,
|
|
448
787
|
setGlobalFilter: setGlobalFilter,
|
|
788
|
+
type: "client",
|
|
449
789
|
}, children: children }));
|
|
450
|
-
}
|
|
790
|
+
}
|
|
451
791
|
|
|
452
792
|
const DataTableServerContext = React.createContext({
|
|
453
793
|
url: "",
|
|
454
794
|
});
|
|
455
795
|
|
|
456
|
-
|
|
796
|
+
function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, query, children, url, }) {
|
|
457
797
|
const table = reactTable.useReactTable({
|
|
458
798
|
_features: [DensityFeature],
|
|
459
799
|
data: query.data?.data ?? [],
|
|
@@ -505,8 +845,9 @@ const DataTableServer = ({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
505
845
|
table: { ...table },
|
|
506
846
|
globalFilter,
|
|
507
847
|
setGlobalFilter,
|
|
848
|
+
type: "server",
|
|
508
849
|
}, children: jsxRuntime.jsx(DataTableServerContext.Provider, { value: { url }, children: children }) }));
|
|
509
|
-
}
|
|
850
|
+
}
|
|
510
851
|
|
|
511
852
|
const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
512
853
|
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
@@ -596,8 +937,8 @@ const Tooltip = React__namespace.forwardRef(function Tooltip(props, ref) {
|
|
|
596
937
|
return (jsxRuntime.jsxs(react.Tooltip.Root, { ...rest, children: [jsxRuntime.jsx(react.Tooltip.Trigger, { asChild: true, children: children }), jsxRuntime.jsx(react.Portal, { disabled: !portalled, container: portalRef, children: jsxRuntime.jsx(react.Tooltip.Positioner, { children: jsxRuntime.jsxs(react.Tooltip.Content, { ref: ref, ...contentProps, children: [showArrow && (jsxRuntime.jsx(react.Tooltip.Arrow, { children: jsxRuntime.jsx(react.Tooltip.ArrowTip, {}) })), content] }) }) })] }));
|
|
597
938
|
});
|
|
598
939
|
|
|
599
|
-
const TableControls = ({ totalText = "Total:",
|
|
600
|
-
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto 1fr auto", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", justifySelf: "center", alignSelf: "center", gap: "0.5rem", children: [jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 2, children: [jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsx(react.Box, { children: jsxRuntime.jsx(EditViewButton, { text: isMobile ? undefined : "View", icon: jsxRuntime.jsx(md.MdOutlineViewColumn, {}) }) }), jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsxRuntime.jsx(react.Spinner, { size: "sm" }), hasError && (jsxRuntime.jsx(Tooltip, { content: "An error occurred while fetching data", children: jsxRuntime.jsx(react.Icon, { as: bs.BsExclamationCircleFill, color: "red.400" }) })),
|
|
940
|
+
const TableControls = ({ totalText = "Total:", fitTableWidth = false, fitTableHeight = false, isMobile = false, children = jsxRuntime.jsx(jsxRuntime.Fragment, {}), showGlobalFilter = false, showFilter = false, showFilterName = false, showFilterTags = false, showReload = false, filterOptions = [], extraItems = jsxRuntime.jsx(jsxRuntime.Fragment, {}), loading = false, hasError = false, }) => {
|
|
941
|
+
return (jsxRuntime.jsxs(react.Grid, { templateRows: "auto 1fr auto", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", justifySelf: "center", alignSelf: "center", gap: "0.5rem", children: [jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 2, children: [jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsx(react.Box, { children: jsxRuntime.jsx(EditViewButton, { text: isMobile ? undefined : "View", icon: jsxRuntime.jsx(md.MdOutlineViewColumn, {}) }) }), jsxRuntime.jsxs(react.Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsxRuntime.jsx(react.Spinner, { size: "sm" }), hasError && (jsxRuntime.jsx(Tooltip, { content: "An error occurred while fetching data", children: jsxRuntime.jsx(react.Icon, { as: bs.BsExclamationCircleFill, color: "red.400" }) })), showGlobalFilter && jsxRuntime.jsx(GlobalFilter, {}), showFilter && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(EditFilterButton, { text: isMobile ? undefined : "Advanced Filter" }) })), showReload && jsxRuntime.jsx(ReloadButton, {}), extraItems] })] }), filterOptions.length > 0 && (jsxRuntime.jsx(react.Flex, { flexFlow: "column", gap: "0.5rem", children: filterOptions.map((column) => {
|
|
601
942
|
return (jsxRuntime.jsxs(react.Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxRuntime.jsxs(react.Text, { children: [column, ":"] }), jsxRuntime.jsx(FilterOptions, { column: column })] }, column));
|
|
602
943
|
}) })), showFilterTags && (jsxRuntime.jsx(react.Flex, { children: jsxRuntime.jsx(TableFilterTags, {}) }))] }), jsxRuntime.jsx(react.Box, { overflow: "auto", width: "100%", height: "100%", backgroundColor: "gray.50", _dark: {
|
|
603
944
|
backgroundColor: "gray.900",
|
|
@@ -788,316 +1129,52 @@ const ReloadButton = ({ text = "Reload", variant = "icon", }) => {
|
|
|
788
1129
|
}, children: [jsxRuntime.jsx(io5.IoReload, {}), " ", text] }));
|
|
789
1130
|
};
|
|
790
1131
|
|
|
791
|
-
const EmptyState = React__namespace.forwardRef(function EmptyState(props, ref) {
|
|
792
|
-
const { title, description, icon, children, ...rest } = props;
|
|
793
|
-
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
794
|
-
});
|
|
795
|
-
|
|
796
|
-
const EmptyResult = (jsxRuntime.jsx(EmptyState, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
797
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
798
|
-
const { table } = useDataTableContext();
|
|
799
|
-
if (table.getRowModel().rows.length <= 0) {
|
|
800
|
-
return emptyComponent;
|
|
801
|
-
}
|
|
802
|
-
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, ...props, children: children }));
|
|
803
|
-
};
|
|
804
|
-
|
|
805
|
-
const TableCardContainer = ({ children, variant = "", ...props }) => {
|
|
806
|
-
if (variant === "carousel") {
|
|
807
|
-
return (jsxRuntime.jsx(react.Flex, { overflow: "scroll", gap: "1rem", children: children }));
|
|
808
|
-
}
|
|
809
|
-
return (jsxRuntime.jsx(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(20rem, 1fr))", gap: "0.5rem", ...props, children: children }));
|
|
810
|
-
};
|
|
811
|
-
|
|
812
|
-
const DefaultCardTitle = () => {
|
|
813
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
814
|
-
};
|
|
815
|
-
const TableCards = ({ isSelectable = false, showDisplayNameOnly = false, renderTitle = DefaultCardTitle, cardBodyProps = {}, }) => {
|
|
816
|
-
const { table } = useDataTableContext();
|
|
817
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getRowModel().rows.map((row) => {
|
|
818
|
-
return (jsxRuntime.jsx(react.Card.Root, { flex: "1 0 20rem", children: jsxRuntime.jsxs(react.Card.Body, { display: "flex", flexFlow: "column", gap: "0.5rem", ...cardBodyProps, children: [isSelectable && (jsxRuntime.jsx(Checkbox, { isChecked: row.getIsSelected(),
|
|
819
|
-
disabled: !row.getCanSelect(),
|
|
820
|
-
// indeterminate: row.getIsSomeSelected(),
|
|
821
|
-
onChange: row.getToggleSelectedHandler() })), renderTitle(row), jsxRuntime.jsx(react.Grid, { templateColumns: "auto 1fr", gap: "1rem", children: row.getVisibleCells().map((cell) => {
|
|
822
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(react.Box, { children: [showDisplayNameOnly && (jsxRuntime.jsx(react.Text, { fontWeight: "bold", children: cell.column.columnDef.meta?.displayName ??
|
|
823
|
-
cell.column.id })), !showDisplayNameOnly && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: reactTable.flexRender(cell.column.columnDef.header,
|
|
824
|
-
// @ts-expect-error Assuming the CellContext interface is the same as HeaderContext
|
|
825
|
-
cell.getContext()) }))] }, `chakra-table-cardcolumnid-${row.id}`), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-cardcolumn-${row.id}`)] }));
|
|
826
|
-
}) })] }) }, `chakra-table-card-${row.id}`));
|
|
827
|
-
}) }));
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
const TableComponent = ({ render = () => {
|
|
831
|
-
throw Error("Not Implemented");
|
|
832
|
-
}, }) => {
|
|
833
|
-
const { table } = useDataTableContext();
|
|
834
|
-
return render(table);
|
|
835
|
-
};
|
|
836
|
-
|
|
837
|
-
const Radio = React__namespace.forwardRef(function Radio(props, ref) {
|
|
838
|
-
const { children, inputProps, rootRef, ...rest } = props;
|
|
839
|
-
return (jsxRuntime.jsxs(react.RadioGroup.Item, { ref: rootRef, ...rest, children: [jsxRuntime.jsx(react.RadioGroup.ItemHiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsx(react.RadioGroup.ItemIndicator, {}), children && (jsxRuntime.jsx(react.RadioGroup.ItemText, { children: children }))] }));
|
|
840
|
-
});
|
|
841
|
-
const RadioGroup = react.RadioGroup.Root;
|
|
842
|
-
|
|
843
|
-
const monthNamesFull = [
|
|
844
|
-
"January",
|
|
845
|
-
"February",
|
|
846
|
-
"March",
|
|
847
|
-
"April",
|
|
848
|
-
"May",
|
|
849
|
-
"June",
|
|
850
|
-
"July",
|
|
851
|
-
"August",
|
|
852
|
-
"September",
|
|
853
|
-
"October",
|
|
854
|
-
"November",
|
|
855
|
-
"December",
|
|
856
|
-
];
|
|
857
|
-
const weekdayNamesShort$1 = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
858
|
-
function Calendar$1({ calendars, getBackProps, getForwardProps, getDateProps, selected = [], firstDayOfWeek = 0, }) {
|
|
859
|
-
const [hoveredDate, setHoveredDate] = React.useState();
|
|
860
|
-
const onMouseLeave = () => {
|
|
861
|
-
setHoveredDate(undefined);
|
|
862
|
-
};
|
|
863
|
-
const onMouseEnter = (date) => {
|
|
864
|
-
setHoveredDate(date);
|
|
865
|
-
};
|
|
866
|
-
const isInRange = (date) => {
|
|
867
|
-
if (selected.length) {
|
|
868
|
-
const firstSelected = selected[0].getTime();
|
|
869
|
-
if (selected.length === 2) {
|
|
870
|
-
const secondSelected = selected[1].getTime();
|
|
871
|
-
return (firstSelected < date.getTime() && secondSelected > date.getTime());
|
|
872
|
-
}
|
|
873
|
-
else {
|
|
874
|
-
return !!(hoveredDate &&
|
|
875
|
-
((firstSelected < date.getTime() &&
|
|
876
|
-
hoveredDate.getTime() >= date.getTime()) ||
|
|
877
|
-
(date.getTime() < firstSelected &&
|
|
878
|
-
date.getTime() >= hoveredDate.getTime())));
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
return false;
|
|
882
|
-
};
|
|
883
|
-
if (calendars.length) {
|
|
884
|
-
return (jsxRuntime.jsxs(react.Grid, { onMouseLeave: onMouseLeave, children: [jsxRuntime.jsxs(react.Grid, { templateColumns: "repeat(4, auto)", justifyContent: "center", children: [jsxRuntime.jsx(react.Button, { variant: "ghost", ...getBackProps({
|
|
885
|
-
calendars,
|
|
886
|
-
offset: 12,
|
|
887
|
-
}), children: "<<" }), jsxRuntime.jsx(react.Button, { variant: "ghost", ...getBackProps({ calendars }), children: "Back" }), jsxRuntime.jsx(react.Button, { variant: "ghost", ...getForwardProps({ calendars }), children: "Next" }), jsxRuntime.jsx(react.Button, { variant: "ghost", ...getForwardProps({
|
|
888
|
-
calendars,
|
|
889
|
-
offset: 12,
|
|
890
|
-
}), children: ">>" })] }), jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(2, auto)", justifyContent: "center", gap: 4, children: calendars.map((calendar) => (jsxRuntime.jsxs(react.Grid, { gap: 4, children: [jsxRuntime.jsxs(react.Grid, { justifyContent: "center", children: [monthNamesFull[calendar.month], " ", calendar.year] }), jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(7, auto)", justifyContent: "center", children: [0, 1, 2, 3, 4, 5, 6].map((weekdayNum) => {
|
|
891
|
-
const weekday = (weekdayNum + firstDayOfWeek) % 7;
|
|
892
|
-
return (jsxRuntime.jsx(react.Box, { minWidth: "48px", textAlign: "center", children: weekdayNamesShort$1[weekday] }, `${calendar.month}${calendar.year}${weekday}`));
|
|
893
|
-
}) }), jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(7, auto)", justifyContent: "center", children: calendar.weeks.map((week, windex) => week.map((dateObj, index) => {
|
|
894
|
-
const key = `${calendar.month}${calendar.year}${windex}${index}`;
|
|
895
|
-
if (!dateObj) {
|
|
896
|
-
return jsxRuntime.jsx(react.Box, {}, key);
|
|
897
|
-
}
|
|
898
|
-
const { date, selected, selectable, today } = dateObj;
|
|
899
|
-
const getStyle = ({ selected, unavailable, today, isInRange, }) => {
|
|
900
|
-
if (unavailable) {
|
|
901
|
-
return {
|
|
902
|
-
colorPalette: "gray",
|
|
903
|
-
variant: "solid",
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
if (selected) {
|
|
907
|
-
return {
|
|
908
|
-
colorPalette: "blue",
|
|
909
|
-
variant: "solid",
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
if (isInRange) {
|
|
913
|
-
return {
|
|
914
|
-
colorPalette: "blue",
|
|
915
|
-
variant: "subtle",
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
|
-
if (today) {
|
|
919
|
-
return {
|
|
920
|
-
colorPalette: "green",
|
|
921
|
-
variant: "solid",
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
return { variant: "ghost" };
|
|
925
|
-
};
|
|
926
|
-
return (jsxRuntime.jsx(react.Button, { ...getDateProps({
|
|
927
|
-
dateObj,
|
|
928
|
-
onMouseEnter: () => {
|
|
929
|
-
onMouseEnter(date);
|
|
930
|
-
},
|
|
931
|
-
}), ...getStyle({
|
|
932
|
-
selected,
|
|
933
|
-
unavailable: !selectable,
|
|
934
|
-
today,
|
|
935
|
-
isInRange: isInRange(date),
|
|
936
|
-
}), children: selectable ? date.getDate() : "X" }, key));
|
|
937
|
-
})) })] }, `${calendar.month}${calendar.year}`))) })] }));
|
|
938
|
-
}
|
|
939
|
-
return null;
|
|
940
|
-
}
|
|
941
|
-
class RangeDatePicker extends React.Component {
|
|
942
|
-
render() {
|
|
943
|
-
return (jsxRuntime.jsx(Dayzed, { onDateSelected: this.props.onDateSelected, selected: this.props.selected, firstDayOfWeek: this.props.firstDayOfWeek, showOutsideDays: this.props.showOutsideDays, date: this.props.date, minDate: this.props.minDate, maxDate: this.props.maxDate, monthsToDisplay: this.props.monthsToDisplay, render: (dayzedData) => (jsxRuntime.jsx(Calendar$1, { ...dayzedData,
|
|
944
|
-
firstDayOfWeek: this.props.firstDayOfWeek,
|
|
945
|
-
selected: this.props.selected })) }));
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
const getRangeDates = ({ selectable, date, selectedDates, }) => {
|
|
950
|
-
if (!selectable) {
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
953
|
-
const dateTime = date.getTime();
|
|
954
|
-
const newDates = [...selectedDates];
|
|
955
|
-
if (selectedDates.length) {
|
|
956
|
-
if (selectedDates.length === 1) {
|
|
957
|
-
const firstTime = selectedDates[0].getTime();
|
|
958
|
-
if (firstTime < dateTime) {
|
|
959
|
-
newDates.push(date);
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
newDates.unshift(date);
|
|
963
|
-
}
|
|
964
|
-
return newDates;
|
|
965
|
-
}
|
|
966
|
-
else if (newDates.length === 2) {
|
|
967
|
-
return [date];
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
else {
|
|
971
|
-
newDates.push(date);
|
|
972
|
-
return newDates;
|
|
973
|
-
}
|
|
974
|
-
};
|
|
975
|
-
|
|
976
|
-
const Slider = React__namespace.forwardRef(function Slider(props, ref) {
|
|
977
|
-
const { marks: marksProp, label, showValue, ...rest } = props;
|
|
978
|
-
const value = props.defaultValue ?? props.value;
|
|
979
|
-
const marks = marksProp?.map((mark) => {
|
|
980
|
-
if (typeof mark === "number")
|
|
981
|
-
return { value: mark, label: undefined };
|
|
982
|
-
return mark;
|
|
983
|
-
});
|
|
984
|
-
const hasMarkLabel = !!marks?.some((mark) => mark.label);
|
|
985
|
-
return (jsxRuntime.jsxs(react.Slider.Root, { ref: ref, thumbAlignment: "center", ...rest, children: [label && !showValue && (jsxRuntime.jsx(react.Slider.Label, { children: label })), label && showValue && (jsxRuntime.jsxs(react.HStack, { justify: "space-between", children: [jsxRuntime.jsx(react.Slider.Label, { children: label }), jsxRuntime.jsx(react.Slider.ValueText, {})] })), jsxRuntime.jsxs(react.Slider.Control, { "data-has-mark-label": hasMarkLabel || undefined, children: [jsxRuntime.jsx(react.Slider.Track, { children: jsxRuntime.jsx(react.Slider.Range, {}) }), jsxRuntime.jsx(SliderThumbs, { value: value }), jsxRuntime.jsx(SliderMarks, { marks: marks })] })] }));
|
|
986
|
-
});
|
|
987
|
-
function SliderThumbs(props) {
|
|
988
|
-
const { value } = props;
|
|
989
|
-
return (jsxRuntime.jsx(react.For, { each: value, children: (_, index) => (jsxRuntime.jsx(react.Slider.Thumb, { index: index, children: jsxRuntime.jsx(react.Slider.HiddenInput, {}) }, index)) }));
|
|
990
|
-
}
|
|
991
|
-
const SliderMarks = React__namespace.forwardRef(function SliderMarks(props, ref) {
|
|
992
|
-
const { marks } = props;
|
|
993
|
-
if (!marks?.length)
|
|
994
|
-
return null;
|
|
995
|
-
return (jsxRuntime.jsx(react.Slider.MarkerGroup, { ref: ref, children: marks.map((mark, index) => {
|
|
996
|
-
const value = typeof mark === "number" ? mark : mark.value;
|
|
997
|
-
const label = typeof mark === "number" ? undefined : mark.label;
|
|
998
|
-
return (jsxRuntime.jsxs(react.Slider.Marker, { value: value, children: [jsxRuntime.jsx(react.Slider.MarkerIndicator, {}), label] }, index));
|
|
999
|
-
}) }));
|
|
1132
|
+
const EmptyState$1 = React__namespace.forwardRef(function EmptyState(props, ref) {
|
|
1133
|
+
const { title, description, icon, children, ...rest } = props;
|
|
1134
|
+
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
1000
1135
|
});
|
|
1001
1136
|
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1137
|
+
const EmptyResult = (jsxRuntime.jsx(EmptyState$1, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
1138
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
1139
|
+
const { table } = useDataTableContext();
|
|
1140
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
1141
|
+
return emptyComponent;
|
|
1142
|
+
}
|
|
1143
|
+
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, ...props, children: children }));
|
|
1006
1144
|
};
|
|
1007
1145
|
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
else {
|
|
1014
|
-
onTagChange([...selectedTags, tag]);
|
|
1015
|
-
}
|
|
1016
|
-
};
|
|
1017
|
-
return (jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", p: "0.5rem", gap: "0.5rem", children: availableTags.map((tag) => (jsxRuntime.jsx(Tag, { variant: selectedTags.includes(tag) ? "solid" : "outline", cursor: "pointer", closable: selectedTags.includes(tag) ? true : undefined, onClick: () => toggleTag(tag), children: tag }))) }));
|
|
1146
|
+
const TableCardContainer = ({ children, variant = "", ...props }) => {
|
|
1147
|
+
if (variant === "carousel") {
|
|
1148
|
+
return (jsxRuntime.jsx(react.Flex, { overflow: "scroll", gap: "1rem", children: children }));
|
|
1149
|
+
}
|
|
1150
|
+
return (jsxRuntime.jsx(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(20rem, 1fr))", gap: "0.5rem", ...props, children: children }));
|
|
1018
1151
|
};
|
|
1019
1152
|
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
const displayName = column.columnDef.meta?.displayName ?? column.id;
|
|
1023
|
-
const filterOptions = column.columnDef.meta?.filterOptions ?? [];
|
|
1024
|
-
if (column.columns.length > 0) {
|
|
1025
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: 1, children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(20rem, 1fr))", gap: 1, children: column.columns.map((column) => {
|
|
1026
|
-
return jsxRuntime.jsx(Filter, { column: column }, column.id);
|
|
1027
|
-
}) }, column.id)] }));
|
|
1028
|
-
}
|
|
1029
|
-
if (!column.getCanFilter()) {
|
|
1030
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
1031
|
-
}
|
|
1032
|
-
if (filterVariant === "select") {
|
|
1033
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(RadioGroup, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onValueChange: (details) => {
|
|
1034
|
-
column.setFilterValue(details.value);
|
|
1035
|
-
}, children: jsxRuntime.jsx(react.Flex, { flexFlow: "wrap", gap: "0.5rem", children: filterOptions.map((item) => (jsxRuntime.jsx(Radio, { value: item, children: item }, item))) }) })] }, column.id));
|
|
1036
|
-
}
|
|
1037
|
-
if (filterVariant === "tag") {
|
|
1038
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(TagFilter, { availableTags: filterOptions, selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
1039
|
-
if (tags.length === 0) {
|
|
1040
|
-
return column.setFilterValue(undefined);
|
|
1041
|
-
}
|
|
1042
|
-
column.setFilterValue(tags);
|
|
1043
|
-
} })] }, column.id));
|
|
1044
|
-
}
|
|
1045
|
-
if (filterVariant === "boolean") {
|
|
1046
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(TagFilter, { availableTags: ["true", "false"], selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
1047
|
-
if (tags.length === 0) {
|
|
1048
|
-
return column.setFilterValue(undefined);
|
|
1049
|
-
}
|
|
1050
|
-
column.setFilterValue(tags);
|
|
1051
|
-
} })] }, column.id));
|
|
1052
|
-
}
|
|
1053
|
-
if (filterVariant === "range") {
|
|
1054
|
-
const filterValue = column.getFilterValue() ?? [
|
|
1055
|
-
undefined,
|
|
1056
|
-
undefined,
|
|
1057
|
-
];
|
|
1058
|
-
const { min, max, step, defaultValue } = column.columnDef.meta
|
|
1059
|
-
?.filterRangeConfig ?? {
|
|
1060
|
-
min: 0,
|
|
1061
|
-
max: 100,
|
|
1062
|
-
step: 1,
|
|
1063
|
-
defaultValue: [4, 50],
|
|
1064
|
-
};
|
|
1065
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(RangeFilter, { range: filterValue, setRange: function (value) {
|
|
1066
|
-
// throw new Error("Function not implemented.");
|
|
1067
|
-
column.setFilterValue(value);
|
|
1068
|
-
}, defaultValue: defaultValue, min: min, max: max, step: step })] }, column.id));
|
|
1069
|
-
}
|
|
1070
|
-
if (filterVariant === "dateRange") {
|
|
1071
|
-
const filterValue = column.getFilterValue() ?? [];
|
|
1072
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(RangeDatePicker, { selected: filterValue, onDateSelected: ({ selected, selectable, date }) => {
|
|
1073
|
-
const newDates = getRangeDates({
|
|
1074
|
-
selectable,
|
|
1075
|
-
date,
|
|
1076
|
-
selectedDates: filterValue,
|
|
1077
|
-
}) ?? [];
|
|
1078
|
-
column.setFilterValue(() => {
|
|
1079
|
-
return newDates;
|
|
1080
|
-
});
|
|
1081
|
-
} })] }, column.id));
|
|
1082
|
-
}
|
|
1083
|
-
if (filterVariant === "custom") {
|
|
1084
|
-
const renderFilter = column.columnDef.meta?.renderFilter;
|
|
1085
|
-
if (renderFilter === undefined) {
|
|
1086
|
-
throw new Error("renderFilter is undefined");
|
|
1087
|
-
}
|
|
1088
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderFilter(column) });
|
|
1089
|
-
}
|
|
1090
|
-
return (jsxRuntime.jsxs(react.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsx(react.Input, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onChange: (e) => {
|
|
1091
|
-
column.setFilterValue(e.target.value);
|
|
1092
|
-
} })] }, column.id));
|
|
1153
|
+
const DefaultCardTitle = () => {
|
|
1154
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
1093
1155
|
};
|
|
1094
|
-
const
|
|
1156
|
+
const TableCards = ({ isSelectable = false, showDisplayNameOnly = false, renderTitle = DefaultCardTitle, cardBodyProps = {}, }) => {
|
|
1095
1157
|
const { table } = useDataTableContext();
|
|
1096
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.
|
|
1097
|
-
return jsxRuntime.jsx(
|
|
1158
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getRowModel().rows.map((row) => {
|
|
1159
|
+
return (jsxRuntime.jsx(react.Card.Root, { flex: "1 0 20rem", children: jsxRuntime.jsxs(react.Card.Body, { display: "flex", flexFlow: "column", gap: "0.5rem", ...cardBodyProps, children: [isSelectable && (jsxRuntime.jsx(Checkbox, { isChecked: row.getIsSelected(),
|
|
1160
|
+
disabled: !row.getCanSelect(),
|
|
1161
|
+
// indeterminate: row.getIsSomeSelected(),
|
|
1162
|
+
onChange: row.getToggleSelectedHandler() })), renderTitle(row), jsxRuntime.jsx(react.Grid, { templateColumns: "auto 1fr", gap: "1rem", children: row.getVisibleCells().map((cell) => {
|
|
1163
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(react.Box, { children: [showDisplayNameOnly && (jsxRuntime.jsx(react.Text, { fontWeight: "bold", children: cell.column.columnDef.meta?.displayName ??
|
|
1164
|
+
cell.column.id })), !showDisplayNameOnly && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: reactTable.flexRender(cell.column.columnDef.header,
|
|
1165
|
+
// @ts-expect-error Assuming the CellContext interface is the same as HeaderContext
|
|
1166
|
+
cell.getContext()) }))] }, `chakra-table-cardcolumnid-${row.id}`), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-cardcolumn-${row.id}`)] }));
|
|
1167
|
+
}) })] }) }, `chakra-table-card-${row.id}`));
|
|
1098
1168
|
}) }));
|
|
1099
1169
|
};
|
|
1100
1170
|
|
|
1171
|
+
const TableComponent = ({ render = () => {
|
|
1172
|
+
throw Error("Not Implemented");
|
|
1173
|
+
}, }) => {
|
|
1174
|
+
const { table } = useDataTableContext();
|
|
1175
|
+
return render(table);
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1101
1178
|
const TableFilterTags = () => {
|
|
1102
1179
|
const { table } = useDataTableContext();
|
|
1103
1180
|
return (jsxRuntime.jsx(react.Flex, { gap: "0.5rem", flexFlow: "wrap", children: table.getState().columnFilters.map(({ id, value }) => {
|
|
@@ -1114,59 +1191,6 @@ const TableLoadingComponent = ({ render, }) => {
|
|
|
1114
1191
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: render(loading) });
|
|
1115
1192
|
};
|
|
1116
1193
|
|
|
1117
|
-
const ColumnOrderChanger = ({ columns }) => {
|
|
1118
|
-
const [order, setOrder] = React.useState([]);
|
|
1119
|
-
const [originalOrder, setOriginalOrder] = React.useState([]);
|
|
1120
|
-
const { table } = useDataTableContext();
|
|
1121
|
-
const handleChangeOrder = (startIndex, endIndex) => {
|
|
1122
|
-
const newOrder = Array.from(order);
|
|
1123
|
-
const [removed] = newOrder.splice(startIndex, 1);
|
|
1124
|
-
newOrder.splice(endIndex, 0, removed);
|
|
1125
|
-
setOrder(newOrder);
|
|
1126
|
-
};
|
|
1127
|
-
React.useEffect(() => {
|
|
1128
|
-
setOrder(columns);
|
|
1129
|
-
}, [columns]);
|
|
1130
|
-
React.useEffect(() => {
|
|
1131
|
-
if (originalOrder.length > 0) {
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
if (columns.length <= 0) {
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
|
-
setOriginalOrder(columns);
|
|
1138
|
-
}, [columns]);
|
|
1139
|
-
return (jsxRuntime.jsxs(react.Flex, { gap: 2, flexFlow: "column", children: [jsxRuntime.jsx(react.Flex, { gap: 2, flexFlow: "column", children: order.map((columnId, index) => (jsxRuntime.jsxs(react.Flex, { gap: 2, alignItems: "center", justifyContent: "space-between", children: [jsxRuntime.jsx(react.IconButton, { onClick: () => {
|
|
1140
|
-
const prevIndex = index - 1;
|
|
1141
|
-
if (prevIndex >= 0) {
|
|
1142
|
-
handleChangeOrder(index, prevIndex);
|
|
1143
|
-
}
|
|
1144
|
-
}, disabled: index === 0, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowUpward, {}) }), table
|
|
1145
|
-
.getAllFlatColumns()
|
|
1146
|
-
.filter((column) => {
|
|
1147
|
-
return column.id === columnId;
|
|
1148
|
-
})
|
|
1149
|
-
.map((column) => {
|
|
1150
|
-
const displayName = column.columnDef.meta === undefined
|
|
1151
|
-
? column.id
|
|
1152
|
-
: column.columnDef.meta.displayName;
|
|
1153
|
-
return jsxRuntime.jsx("span", { children: displayName }, column.id);
|
|
1154
|
-
}), jsxRuntime.jsx(react.IconButton, { onClick: () => {
|
|
1155
|
-
const nextIndex = index + 1;
|
|
1156
|
-
if (nextIndex < order.length) {
|
|
1157
|
-
handleChangeOrder(index, nextIndex);
|
|
1158
|
-
}
|
|
1159
|
-
}, disabled: index === order.length - 1, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowDownward, {}) })] }, columnId))) }), jsxRuntime.jsxs(react.Flex, { gap: "0.25rem", children: [jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
1160
|
-
table.setColumnOrder(order);
|
|
1161
|
-
}, children: "Apply" }), jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
1162
|
-
table.setColumnOrder(originalOrder);
|
|
1163
|
-
}, children: "Reset" })] })] }));
|
|
1164
|
-
};
|
|
1165
|
-
const TableOrderer = () => {
|
|
1166
|
-
const { table } = useDataTableContext();
|
|
1167
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ColumnOrderChanger, { columns: table.getState().columnOrder }) }));
|
|
1168
|
-
};
|
|
1169
|
-
|
|
1170
1194
|
const SelectAllRowsToggle = ({ selectAllIcon = jsxRuntime.jsx(md.MdOutlineChecklist, {}), clearAllIcon = jsxRuntime.jsx(md.MdClear, {}), selectAllText = "", clearAllText = "", }) => {
|
|
1171
1195
|
const { table } = useDataTableContext();
|
|
1172
1196
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!selectAllText === false && (jsxRuntime.jsx(react.IconButton, { variant: "ghost", "aria-label": table.getIsAllRowsSelected() ? clearAllText : selectAllText, onClick: (event) => {
|
|
@@ -1183,20 +1207,6 @@ const TableSelector = () => {
|
|
|
1183
1207
|
}, "aria-label": "reset selection", children: jsxRuntime.jsx(md.MdClear, {}) }))] }));
|
|
1184
1208
|
};
|
|
1185
1209
|
|
|
1186
|
-
const TableSorter = () => {
|
|
1187
|
-
const { table } = useDataTableContext();
|
|
1188
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: headerGroup.headers.map((header) => {
|
|
1189
|
-
const displayName = header.column.columnDef.meta === undefined
|
|
1190
|
-
? header.column.id
|
|
1191
|
-
: header.column.columnDef.meta.displayName;
|
|
1192
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: header.column.getCanSort() && (jsxRuntime.jsxs(react.Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsxRuntime.jsx(react.Text, { children: displayName }), jsxRuntime.jsxs(react.Button, { variant: "ghost", onClick: () => {
|
|
1193
|
-
header.column.toggleSorting();
|
|
1194
|
-
}, children: [header.column.getIsSorted() === false && jsxRuntime.jsx(fa6.FaUpDown, {}), header.column.getIsSorted() === "asc" && jsxRuntime.jsx(bi.BiDownArrow, {}), header.column.getIsSorted() === "desc" && jsxRuntime.jsx(bi.BiUpArrow, {})] }), header.column.getIsSorted() && (jsxRuntime.jsx(react.Button, { onClick: () => {
|
|
1195
|
-
header.column.clearSorting();
|
|
1196
|
-
}, children: jsxRuntime.jsx(cg.CgClose, {}) }))] })) }));
|
|
1197
|
-
}) }))) }));
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
1210
|
const CheckboxCard = React__namespace.forwardRef(function CheckboxCard(props, ref) {
|
|
1201
1211
|
const { inputProps, label, description, icon, addon, indicator = jsxRuntime.jsx(react.CheckboxCard.Indicator, {}), indicatorPlacement = "end", ...rest } = props;
|
|
1202
1212
|
const hasContent = label || description || icon;
|
|
@@ -1398,7 +1408,7 @@ const useDataTableServer = ({ url, default: { sorting: defaultSorting = [], pagi
|
|
|
1398
1408
|
searching: globalFilter,
|
|
1399
1409
|
};
|
|
1400
1410
|
const query = reactQuery.useQuery({
|
|
1401
|
-
queryKey: [url, params],
|
|
1411
|
+
queryKey: [url, JSON.stringify(params)],
|
|
1402
1412
|
queryFn: () => {
|
|
1403
1413
|
return axios
|
|
1404
1414
|
.get(url, {
|
|
@@ -1490,6 +1500,18 @@ const getColumns = ({ schema, ignore = [], width = [], meta = {}, defaultWidth =
|
|
|
1490
1500
|
return columns;
|
|
1491
1501
|
};
|
|
1492
1502
|
|
|
1503
|
+
const EmptyState = ({ title = "No records", description = "Add a new events to get started or refine your search", }) => {
|
|
1504
|
+
const { query } = useDataTableContext();
|
|
1505
|
+
const { data } = query;
|
|
1506
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (data ?? { count: 0 }).count <= 0 && (jsxRuntime.jsx(react.EmptyState.Root, { children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [jsxRuntime.jsx(react.EmptyState.Indicator, { children: jsxRuntime.jsx(hi.HiColorSwatch, {}) }), jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })] }) })) }));
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
const ErrorAlert = ({ showMessage }) => {
|
|
1510
|
+
const { query } = useDataTableContext();
|
|
1511
|
+
const { isError, error } = query;
|
|
1512
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isError && (jsxRuntime.jsxs(react.Alert.Root, { status: "error", children: [jsxRuntime.jsx(react.Alert.Indicator, {}), jsxRuntime.jsxs(react.Alert.Content, { children: [jsxRuntime.jsx(react.Alert.Title, { children: error.name }), showMessage && (jsxRuntime.jsx(react.Alert.Description, { children: error.message }))] })] })) }));
|
|
1513
|
+
};
|
|
1514
|
+
|
|
1493
1515
|
const FilterOptions = ({ column }) => {
|
|
1494
1516
|
const { table } = useDataTableContext();
|
|
1495
1517
|
const tableColumn = table.getColumn(column);
|
|
@@ -1524,8 +1546,16 @@ const InputGroup = React__namespace.forwardRef(function InputGroup(props, ref) {
|
|
|
1524
1546
|
|
|
1525
1547
|
const GlobalFilter = () => {
|
|
1526
1548
|
const { table } = useDataTableContext();
|
|
1549
|
+
const [searchTerm, setSearchTerm] = React.useState("");
|
|
1550
|
+
const debouncedSearchTerm = usehooks.useDebounce(searchTerm, 500);
|
|
1551
|
+
React.useEffect(() => {
|
|
1552
|
+
const searchHN = async () => {
|
|
1553
|
+
table.setGlobalFilter(debouncedSearchTerm);
|
|
1554
|
+
};
|
|
1555
|
+
searchHN();
|
|
1556
|
+
}, [debouncedSearchTerm]);
|
|
1527
1557
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(InputGroup, { flex: "1", startElement: jsxRuntime.jsx(md.MdSearch, {}), children: jsxRuntime.jsx(react.Input, { placeholder: "Outline", variant: "outline", onChange: (e) => {
|
|
1528
|
-
|
|
1558
|
+
setSearchTerm(e.target.value);
|
|
1529
1559
|
} }) }) }));
|
|
1530
1560
|
};
|
|
1531
1561
|
|
|
@@ -1559,16 +1589,6 @@ const PopoverRoot = react.Popover.Root;
|
|
|
1559
1589
|
const PopoverBody = react.Popover.Body;
|
|
1560
1590
|
const PopoverTrigger = react.Popover.Trigger;
|
|
1561
1591
|
|
|
1562
|
-
const RadioCardItem = React__namespace.forwardRef(function RadioCardItem(props, ref) {
|
|
1563
|
-
const { inputProps, label, description, addon, icon, indicator = jsxRuntime.jsx(react.RadioCard.ItemIndicator, {}), indicatorPlacement = "end", ...rest } = props;
|
|
1564
|
-
const hasContent = label || description || icon;
|
|
1565
|
-
const ContentWrapper = indicator ? react.RadioCard.ItemContent : React__namespace.Fragment;
|
|
1566
|
-
return (jsxRuntime.jsxs(react.RadioCard.Item, { ...rest, children: [jsxRuntime.jsx(react.RadioCard.ItemHiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsxs(react.RadioCard.ItemControl, { children: [indicatorPlacement === "start" && indicator, hasContent && (jsxRuntime.jsxs(ContentWrapper, { children: [icon, label && jsxRuntime.jsx(react.RadioCard.ItemText, { children: label }), description && (jsxRuntime.jsx(react.RadioCard.ItemDescription, { children: description })), indicatorPlacement === "inside" && indicator] })), indicatorPlacement === "end" && indicator] }), addon && jsxRuntime.jsx(react.RadioCard.ItemAddon, { children: addon })] }));
|
|
1567
|
-
});
|
|
1568
|
-
const RadioCardRoot = react.RadioCard.Root;
|
|
1569
|
-
react.RadioCard.Label;
|
|
1570
|
-
react.RadioCard.ItemIndicator;
|
|
1571
|
-
|
|
1572
1592
|
const Field = React__namespace.forwardRef(function Field(props, ref) {
|
|
1573
1593
|
const { label, children, helperText, errorText, optionalText, ...rest } = props;
|
|
1574
1594
|
return (jsxRuntime.jsxs(react.Field.Root, { ref: ref, ...rest, children: [label && (jsxRuntime.jsxs(react.Field.Label, { children: [label, jsxRuntime.jsx(react.Field.RequiredIndicator, { fallback: optionalText })] })), children, helperText && (jsxRuntime.jsx(react.Field.HelperText, { children: helperText })), errorText && (jsxRuntime.jsx(react.Field.ErrorText, { children: errorText }))] }));
|
|
@@ -1628,11 +1648,13 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1628
1648
|
if (schema.properties == undefined) {
|
|
1629
1649
|
throw new Error("schema properties when using DatePicker");
|
|
1630
1650
|
}
|
|
1631
|
-
const {
|
|
1651
|
+
const { total, showing, close, typeToSearch, showMore } = displayText;
|
|
1652
|
+
const { gridColumn, gridRow, title, renderDisplay } = schema.properties[column];
|
|
1632
1653
|
const [selectedIds, setSelectedIds] = React.useState([]);
|
|
1633
1654
|
const [searchText, setSearchText] = React.useState();
|
|
1634
1655
|
const [limit, setLimit] = React.useState(10);
|
|
1635
1656
|
const [openSearchResult, setOpenSearchResult] = React.useState();
|
|
1657
|
+
const [idMap, setIdMap] = React.useState({});
|
|
1636
1658
|
const ref = React.useRef(null);
|
|
1637
1659
|
const query = reactQuery.useQuery({
|
|
1638
1660
|
queryKey: [`idpicker`, searchText, in_table, limit],
|
|
@@ -1654,68 +1676,70 @@ const IdPicker = ({ column, in_table, column_ref, display_column, isMultiple = f
|
|
|
1654
1676
|
setSearchText(event.target.value);
|
|
1655
1677
|
setLimit(10);
|
|
1656
1678
|
};
|
|
1657
|
-
|
|
1658
|
-
const
|
|
1659
|
-
return
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1679
|
+
const ids = (watch(column) ?? []);
|
|
1680
|
+
const newIdMap = React.useMemo(() => Object.fromEntries(dataList.map((item) => {
|
|
1681
|
+
return [
|
|
1682
|
+
item[column_ref],
|
|
1683
|
+
{
|
|
1684
|
+
...item,
|
|
1685
|
+
},
|
|
1686
|
+
];
|
|
1687
|
+
})), [dataList, column_ref]);
|
|
1688
|
+
React.useEffect(() => {
|
|
1689
|
+
setIdMap((state) => {
|
|
1690
|
+
return { ...state, ...newIdMap };
|
|
1665
1691
|
});
|
|
1666
|
-
};
|
|
1667
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1668
|
-
const getIdMap = (data) => {
|
|
1669
|
-
return Object.fromEntries(data.map((item) => {
|
|
1670
|
-
return [
|
|
1671
|
-
item[column_ref],
|
|
1672
|
-
{
|
|
1673
|
-
...item,
|
|
1674
|
-
},
|
|
1675
|
-
];
|
|
1676
|
-
}));
|
|
1677
|
-
};
|
|
1678
|
-
const getSelectedName = (id) => {
|
|
1679
|
-
const selectedItem = getIdMap(dataList)[id];
|
|
1680
|
-
if (selectedItem == undefined) {
|
|
1681
|
-
return "";
|
|
1682
|
-
}
|
|
1683
|
-
return selectedItem[display_column];
|
|
1684
|
-
};
|
|
1685
|
-
if (selectedIds.length >= 1 && isMultiple === false) {
|
|
1686
|
-
return (jsxRuntime.jsx(Field, { label: `${title ?? snakeToLabel(column)}`, required: isRequired, gridColumn,
|
|
1687
|
-
gridRow, children: jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
1688
|
-
setSelectedIds([]);
|
|
1689
|
-
setValue(column, "");
|
|
1690
|
-
}, children: getSelectedName(selectedIds[0]) }) }));
|
|
1691
|
-
}
|
|
1692
|
+
}, [newIdMap]);
|
|
1692
1693
|
return (jsxRuntime.jsxs(Field, { label: `${title ?? snakeToLabel(column)}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
1693
|
-
gridRow, children: [selectedIds.map((id) => {
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1694
|
+
gridRow, children: [isMultiple && (jsxRuntime.jsxs(react.Flex, { flexFlow: "wrap", gap: 1, children: [selectedIds.map((id) => {
|
|
1695
|
+
const item = idMap[id];
|
|
1696
|
+
if (item === undefined) {
|
|
1697
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
1698
|
+
}
|
|
1699
|
+
return (jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
1700
|
+
setSelectedIds((state) => state.filter((id) => id != item[column_ref]));
|
|
1701
|
+
setValue(column, ids.filter((id) => id != item[column_ref]));
|
|
1702
|
+
}, children: !!renderDisplay === true
|
|
1703
|
+
? renderDisplay(item)
|
|
1704
|
+
: item[display_column] }));
|
|
1705
|
+
}), jsxRuntime.jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
1706
|
+
setOpenSearchResult(true);
|
|
1707
|
+
}, children: "Add" })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: (event) => {
|
|
1700
1708
|
setOpenSearchResult(true);
|
|
1701
|
-
},
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
getItemList(dataList).map((item) => (jsxRuntime.jsx(RadioCardItem, { label: item.label, description: item.description, value: item.value, onClick: () => {
|
|
1706
|
-
const ids = watch(column);
|
|
1707
|
-
setSelectedIds((state) => [...state, item.key]);
|
|
1708
|
-
setValue(column, [...(ids ?? []), item.key]);
|
|
1709
|
+
}, children: selectedIds[0] ? idMap[selectedIds[0]][display_column] ?? "" : "" })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(react.Input, { placeholder: typeToSearch, onChange: (event) => {
|
|
1710
|
+
onSearchChange(event);
|
|
1711
|
+
setOpenSearchResult(true);
|
|
1712
|
+
}, autoComplete: "off", ref: ref }), jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsxs(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [isFetching && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isFetching" }), isLoading && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isLoading" }), isPending && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isPending" }), isError && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "isError" }), jsxRuntime.jsx(react.Text, { children: `${total ?? "Total"} ${count}, ${showing ?? "Showing"} ${limit}` }), jsxRuntime.jsx(Button, { onClick: async () => {
|
|
1709
1713
|
setOpenSearchResult(false);
|
|
1710
|
-
},
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1714
|
+
}, children: close ?? "Close" }), jsxRuntime.jsx(react.Flex, { flexFlow: "column wrap", children:
|
|
1715
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1716
|
+
dataList.map((item) => {
|
|
1717
|
+
const selected = ids.some((id) => item[column_ref] === id);
|
|
1718
|
+
return (jsxRuntime.jsx(react.Box, { cursor: "pointer", onClick: () => {
|
|
1719
|
+
if (!isMultiple) {
|
|
1720
|
+
setOpenSearchResult(false);
|
|
1721
|
+
setSelectedIds(() => [item[column_ref]]);
|
|
1722
|
+
setValue(column, [item[column_ref]]);
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
const newSet = new Set([
|
|
1726
|
+
...(ids ?? []),
|
|
1727
|
+
item[column_ref],
|
|
1728
|
+
]);
|
|
1729
|
+
setSelectedIds(() => [...newSet]);
|
|
1730
|
+
setValue(column, [...newSet]);
|
|
1731
|
+
}, opacity: 0.7, _hover: { opacity: 1 }, ...(selected ? { color: "gray.400/50" } : {}), children: !!renderDisplay === true
|
|
1732
|
+
? renderDisplay(item)
|
|
1733
|
+
: item[display_column] }));
|
|
1734
|
+
}) }), isDirty && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [dataList.length <= 0 && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "Empty Search Result" }), " "] })), count > dataList.length && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(Button, { onClick: async () => {
|
|
1735
|
+
setLimit((limit) => limit + 10);
|
|
1736
|
+
await getTableData({
|
|
1737
|
+
serverUrl,
|
|
1738
|
+
searching: searchText ?? "",
|
|
1739
|
+
in_table: in_table,
|
|
1740
|
+
limit: limit + 10,
|
|
1741
|
+
});
|
|
1742
|
+
}, children: showMore ?? "Show More" }) }))] })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
1719
1743
|
};
|
|
1720
1744
|
|
|
1721
1745
|
const ToggleTip = React__namespace.forwardRef(function ToggleTip(props, ref) {
|
|
@@ -1923,7 +1947,6 @@ const DatePicker = ({ column }) => {
|
|
|
1923
1947
|
}, children: getValues(column) !== undefined
|
|
1924
1948
|
? dayjs(getValues(column)).format("YYYY-MM-DD")
|
|
1925
1949
|
: "" }) }), jsxRuntime.jsx(PopoverContent, { width: "auto", children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(DatePicker$1, { selected: new Date(getValues(column)), onDateSelected: ({ selected, selectable, date }) => {
|
|
1926
|
-
console.log(date, selected, selectable, "jasdio");
|
|
1927
1950
|
setValue(column, dayjs(date).format("YYYY-MM-DD"));
|
|
1928
1951
|
setOpen(false);
|
|
1929
1952
|
} })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
@@ -1986,6 +2009,16 @@ const ObjectInput = ({ column }) => {
|
|
|
1986
2009
|
}, children: addNew ?? "Add New" }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
1987
2010
|
};
|
|
1988
2011
|
|
|
2012
|
+
const RadioCardItem = React__namespace.forwardRef(function RadioCardItem(props, ref) {
|
|
2013
|
+
const { inputProps, label, description, addon, icon, indicator = jsxRuntime.jsx(react.RadioCard.ItemIndicator, {}), indicatorPlacement = "end", ...rest } = props;
|
|
2014
|
+
const hasContent = label || description || icon;
|
|
2015
|
+
const ContentWrapper = indicator ? react.RadioCard.ItemContent : React__namespace.Fragment;
|
|
2016
|
+
return (jsxRuntime.jsxs(react.RadioCard.Item, { ...rest, children: [jsxRuntime.jsx(react.RadioCard.ItemHiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsxs(react.RadioCard.ItemControl, { children: [indicatorPlacement === "start" && indicator, hasContent && (jsxRuntime.jsxs(ContentWrapper, { children: [icon, label && jsxRuntime.jsx(react.RadioCard.ItemText, { children: label }), description && (jsxRuntime.jsx(react.RadioCard.ItemDescription, { children: description })), indicatorPlacement === "inside" && indicator] })), indicatorPlacement === "end" && indicator] }), addon && jsxRuntime.jsx(react.RadioCard.ItemAddon, { children: addon })] }));
|
|
2017
|
+
});
|
|
2018
|
+
const RadioCardRoot = react.RadioCard.Root;
|
|
2019
|
+
react.RadioCard.Label;
|
|
2020
|
+
react.RadioCard.ItemIndicator;
|
|
2021
|
+
|
|
1989
2022
|
const TagPicker = ({ column }) => {
|
|
1990
2023
|
const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
1991
2024
|
const { schema, serverUrl } = useSchemaContext();
|
|
@@ -2026,7 +2059,7 @@ const TagPicker = ({ column }) => {
|
|
|
2026
2059
|
where: [
|
|
2027
2060
|
{
|
|
2028
2061
|
id: object_id_column,
|
|
2029
|
-
value: [
|
|
2062
|
+
value: object_id[0],
|
|
2030
2063
|
},
|
|
2031
2064
|
],
|
|
2032
2065
|
limit: 100,
|
|
@@ -2143,6 +2176,65 @@ const FilePicker = ({ column }) => {
|
|
|
2143
2176
|
}) }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
2144
2177
|
};
|
|
2145
2178
|
|
|
2179
|
+
const EnumPicker = ({ column, isMultiple = false }) => {
|
|
2180
|
+
const { watch, formState: { errors }, setValue, } = reactHookForm.useFormContext();
|
|
2181
|
+
const { schema, serverUrl, displayText } = useSchemaContext();
|
|
2182
|
+
const { fieldRequired } = displayText;
|
|
2183
|
+
const { required } = schema;
|
|
2184
|
+
const isRequired = required?.some((columnId) => columnId === column);
|
|
2185
|
+
if (schema.properties == undefined) {
|
|
2186
|
+
throw new Error("schema properties when using DatePicker");
|
|
2187
|
+
}
|
|
2188
|
+
const { gridColumn, gridRow, title, renderDisplay } = schema.properties[column];
|
|
2189
|
+
const [selectedEnums, setSelectedEnums] = React.useState([]);
|
|
2190
|
+
const [searchText, setSearchText] = React.useState();
|
|
2191
|
+
const [limit, setLimit] = React.useState(10);
|
|
2192
|
+
const [openSearchResult, setOpenSearchResult] = React.useState();
|
|
2193
|
+
const ref = React.useRef(null);
|
|
2194
|
+
const watchEnums = (watch(column) ?? []);
|
|
2195
|
+
const properties = (schema.properties[column] ?? {});
|
|
2196
|
+
const dataList = properties.enum ?? [];
|
|
2197
|
+
const count = properties.enum?.length ?? 0;
|
|
2198
|
+
const isDirty = (searchText?.length ?? 0) > 0;
|
|
2199
|
+
const onSearchChange = async (event) => {
|
|
2200
|
+
setSearchText(event.target.value);
|
|
2201
|
+
setLimit(10);
|
|
2202
|
+
};
|
|
2203
|
+
return (jsxRuntime.jsxs(Field, { label: `${title ?? snakeToLabel(column)}`, required: isRequired, alignItems: "stretch", gridColumn,
|
|
2204
|
+
gridRow, children: [isMultiple && (jsxRuntime.jsxs(react.Flex, { flexFlow: "wrap", gap: 1, children: [selectedEnums.map((enumValue) => {
|
|
2205
|
+
const item = enumValue;
|
|
2206
|
+
if (item === undefined) {
|
|
2207
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
2208
|
+
}
|
|
2209
|
+
return (jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
2210
|
+
setSelectedEnums((state) => state.filter((id) => id != item));
|
|
2211
|
+
setValue(column, watchEnums.filter((id) => id != item));
|
|
2212
|
+
}, children: !!renderDisplay === true ? renderDisplay(item) : item }));
|
|
2213
|
+
}), jsxRuntime.jsx(Tag, { cursor: "pointer", onClick: () => {
|
|
2214
|
+
setOpenSearchResult(true);
|
|
2215
|
+
}, children: "Add" })] })), !isMultiple && (jsxRuntime.jsx(Button, { variant: "outline", onClick: (event) => {
|
|
2216
|
+
setOpenSearchResult(true);
|
|
2217
|
+
}, children: selectedEnums[0] })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { children: [jsxRuntime.jsx(react.Input, { placeholder: "Type to search", onChange: (event) => {
|
|
2218
|
+
onSearchChange(event);
|
|
2219
|
+
setOpenSearchResult(true);
|
|
2220
|
+
}, autoComplete: "off", ref: ref }), jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsxs(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [jsxRuntime.jsx(react.Text, { children: `Search Result: ${count}, Showing ${limit}` }), jsxRuntime.jsx(Button, { onClick: async () => {
|
|
2221
|
+
setOpenSearchResult(false);
|
|
2222
|
+
}, children: "close" }), jsxRuntime.jsx(react.Flex, { flexFlow: "column wrap", children: dataList.map((item) => {
|
|
2223
|
+
const selected = watchEnums.some((enumValue) => item === enumValue);
|
|
2224
|
+
return (jsxRuntime.jsx(react.Box, { cursor: "pointer", onClick: () => {
|
|
2225
|
+
if (!isMultiple) {
|
|
2226
|
+
setOpenSearchResult(false);
|
|
2227
|
+
setSelectedEnums(() => [item]);
|
|
2228
|
+
setValue(column, [item]);
|
|
2229
|
+
return;
|
|
2230
|
+
}
|
|
2231
|
+
const newSet = new Set([...(watchEnums ?? []), item]);
|
|
2232
|
+
setSelectedEnums(() => [...newSet]);
|
|
2233
|
+
setValue(column, [...newSet]);
|
|
2234
|
+
}, ...(selected ? { color: "gray.400/50" } : {}), children: !!renderDisplay === true ? renderDisplay(item) : item }, `${column}-${item}`));
|
|
2235
|
+
}) }), isDirty && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [dataList.length <= 0 && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "Empty Search Result" }), " "] }))] })] }) })] }), errors[`${column}`] && (jsxRuntime.jsx(react.Text, { color: "red.400", children: fieldRequired ?? "The field is requried" }))] }));
|
|
2236
|
+
};
|
|
2237
|
+
|
|
2146
2238
|
const idPickerSanityCheck = (column, in_table, column_ref, display_column) => {
|
|
2147
2239
|
if (!!in_table == false) {
|
|
2148
2240
|
throw new Error(`The key in_table does not exist in properties of column ${column}.`);
|
|
@@ -2340,6 +2432,9 @@ const FormInternal = () => {
|
|
|
2340
2432
|
//@ts-expect-error TODO: add more fields to support form-creation
|
|
2341
2433
|
const { type, variant, in_table, column_ref, display_column } = values;
|
|
2342
2434
|
if (type === "string") {
|
|
2435
|
+
if ((values.enum ?? []).length > 0) {
|
|
2436
|
+
return jsxRuntime.jsx(EnumPicker, { column: key }, `form-${key}`);
|
|
2437
|
+
}
|
|
2343
2438
|
if (variant === "id-picker") {
|
|
2344
2439
|
idPickerSanityCheck(column, in_table, column_ref, display_column);
|
|
2345
2440
|
return (jsxRuntime.jsx(IdPicker, { column: key, in_table: in_table, column_ref: column_ref, display_column: display_column }, `form-${key}`));
|
|
@@ -2426,6 +2521,8 @@ exports.EditFilterButton = EditFilterButton;
|
|
|
2426
2521
|
exports.EditOrderButton = EditOrderButton;
|
|
2427
2522
|
exports.EditSortingButton = EditSortingButton;
|
|
2428
2523
|
exports.EditViewButton = EditViewButton;
|
|
2524
|
+
exports.EmptyState = EmptyState;
|
|
2525
|
+
exports.ErrorAlert = ErrorAlert;
|
|
2429
2526
|
exports.FilterOptions = FilterOptions;
|
|
2430
2527
|
exports.Form = Form;
|
|
2431
2528
|
exports.GlobalFilter = GlobalFilter;
|