@loykin/filter-input 0.0.1-dev.4 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/dist/index.cjs +148 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +148 -118
- package/dist/index.js.map +1 -1
- package/dist/styles.css +209 -124
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ function FiSelect({
|
|
|
38
38
|
onOpen,
|
|
39
39
|
onReload,
|
|
40
40
|
className,
|
|
41
|
+
size,
|
|
41
42
|
classNames
|
|
42
43
|
}) {
|
|
43
44
|
return /* @__PURE__ */ jsxs(
|
|
@@ -51,16 +52,16 @@ function FiSelect({
|
|
|
51
52
|
},
|
|
52
53
|
disabled,
|
|
53
54
|
children: [
|
|
54
|
-
/* @__PURE__ */ jsxs(Select.Trigger, { className: cn("
|
|
55
|
-
/* @__PURE__ */ jsx(Select.Value, { placeholder, className: "
|
|
56
|
-
/* @__PURE__ */ jsx(Select.Icon, { className: "
|
|
55
|
+
/* @__PURE__ */ jsxs(Select.Trigger, { className: cn("filter-input-select-trigger", classNames?.trigger, className), "data-size": size, children: [
|
|
56
|
+
/* @__PURE__ */ jsx(Select.Value, { placeholder, className: "filter-input-select-value" }),
|
|
57
|
+
/* @__PURE__ */ jsx(Select.Icon, { className: "filter-input-select-icon", children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) })
|
|
57
58
|
] }),
|
|
58
|
-
/* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, { sideOffset: 4, className: "
|
|
59
|
-
(searchable || onReload) && /* @__PURE__ */ jsxs("div", { className: "
|
|
59
|
+
/* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, { sideOffset: 4, className: "filter-input-positioner", children: /* @__PURE__ */ jsxs(Select.Popup, { className: cn("filter-input-select-popup", classNames?.popup), children: [
|
|
60
|
+
(searchable || onReload) && /* @__PURE__ */ jsxs("div", { className: "filter-input-popup-header", children: [
|
|
60
61
|
searchable && /* @__PURE__ */ jsx(
|
|
61
62
|
"input",
|
|
62
63
|
{
|
|
63
|
-
className: "
|
|
64
|
+
className: "filter-input-control",
|
|
64
65
|
value: query,
|
|
65
66
|
placeholder: "Search...",
|
|
66
67
|
autoFocus: true,
|
|
@@ -71,30 +72,30 @@ function FiSelect({
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
),
|
|
74
|
-
onReload && /* @__PURE__ */ jsx("button", { type: "button", className: "
|
|
75
|
+
onReload && /* @__PURE__ */ jsx("button", { type: "button", className: "filter-input-reload-button", onClick: onReload, disabled: loading, "aria-label": "Reload", children: /* @__PURE__ */ jsx(RefreshIcon, {}) })
|
|
75
76
|
] }),
|
|
76
|
-
(loading || error) && /* @__PURE__ */ jsxs("div", { className: "
|
|
77
|
-
loading ? /* @__PURE__ */ jsx("span", { className: "
|
|
78
|
-
onReload && !loading && /* @__PURE__ */ jsx("button", { type: "button", className: "
|
|
77
|
+
(loading || error) && /* @__PURE__ */ jsxs("div", { className: "filter-input-popup-status", children: [
|
|
78
|
+
loading ? /* @__PURE__ */ jsx("span", { className: "filter-input-loading", children: "Loading\u2026" }) : /* @__PURE__ */ jsx("span", { className: "filter-input-error", children: error }),
|
|
79
|
+
onReload && !loading && /* @__PURE__ */ jsx("button", { type: "button", className: "filter-input-reload-button", onClick: onReload, "aria-label": "Retry", children: /* @__PURE__ */ jsx(RefreshIcon, {}) })
|
|
79
80
|
] }),
|
|
80
81
|
/* @__PURE__ */ jsxs(Select.List, { children: [
|
|
81
|
-
!loading && !error && !required && /* @__PURE__ */ jsx(Select.Item, { value: "", className: cn("
|
|
82
|
+
!loading && !error && !required && /* @__PURE__ */ jsx(Select.Item, { value: "", className: cn("filter-input-select-item", classNames?.item), children: /* @__PURE__ */ jsx(Select.ItemText, { className: "filter-input-select-item-text", children: placeholder }) }),
|
|
82
83
|
!loading && !error && options.map((option) => /* @__PURE__ */ jsxs(
|
|
83
84
|
Select.Item,
|
|
84
85
|
{
|
|
85
86
|
value: option.value,
|
|
86
87
|
disabled: option.disabled,
|
|
87
|
-
className: cn("
|
|
88
|
+
className: cn("filter-input-select-item", classNames?.item),
|
|
88
89
|
children: [
|
|
89
|
-
/* @__PURE__ */ jsx(Select.ItemText, { className: "
|
|
90
|
-
/* @__PURE__ */ jsx(Select.ItemIndicator, { className: "
|
|
90
|
+
/* @__PURE__ */ jsx(Select.ItemText, { className: "filter-input-select-item-text", children: option.label }),
|
|
91
|
+
/* @__PURE__ */ jsx(Select.ItemIndicator, { className: "filter-input-select-item-indicator", children: /* @__PURE__ */ jsx(CheckIcon, {}) })
|
|
91
92
|
]
|
|
92
93
|
},
|
|
93
94
|
option.value
|
|
94
95
|
)),
|
|
95
|
-
!loading && !error && !options.length && !required && /* @__PURE__ */ jsx("div", { className: "
|
|
96
|
+
!loading && !error && !options.length && !required && /* @__PURE__ */ jsx("div", { className: "filter-input-popup-status", children: /* @__PURE__ */ jsx("span", { className: "filter-input-empty", children: "No options" }) })
|
|
96
97
|
] }),
|
|
97
|
-
onReload && !searchable && !loading && !error && /* @__PURE__ */ jsx("div", { className: "
|
|
98
|
+
onReload && !searchable && !loading && !error && /* @__PURE__ */ jsx("div", { className: "filter-input-popup-footer", children: /* @__PURE__ */ jsx("button", { type: "button", className: "filter-input-reload-button", onClick: onReload, "aria-label": "Reload", children: /* @__PURE__ */ jsx(RefreshIcon, {}) }) })
|
|
98
99
|
] }) }) })
|
|
99
100
|
]
|
|
100
101
|
}
|
|
@@ -129,20 +130,20 @@ function FiMultiSelect({
|
|
|
129
130
|
/* @__PURE__ */ jsxs(
|
|
130
131
|
Popover.Trigger,
|
|
131
132
|
{
|
|
132
|
-
className: cn("
|
|
133
|
+
className: cn("filter-input-multi-trigger", classNames?.trigger),
|
|
133
134
|
disabled,
|
|
134
135
|
children: [
|
|
135
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
136
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
136
|
+
/* @__PURE__ */ jsx("span", { className: "filter-input-multi-value", children: renderTriggerValue() }),
|
|
137
|
+
/* @__PURE__ */ jsx("span", { className: "filter-input-chevron", children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) })
|
|
137
138
|
]
|
|
138
139
|
}
|
|
139
140
|
),
|
|
140
|
-
/* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, { sideOffset: 4, align: "start", className: "
|
|
141
|
-
(searchable || onReload) && /* @__PURE__ */ jsxs("div", { className: "
|
|
141
|
+
/* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, { sideOffset: 4, align: "start", className: "filter-input-positioner", children: /* @__PURE__ */ jsxs(Popover.Popup, { className: cn("filter-input-multi-popup", classNames?.popup), children: [
|
|
142
|
+
(searchable || onReload) && /* @__PURE__ */ jsxs("div", { className: "filter-input-popup-header", children: [
|
|
142
143
|
searchable && /* @__PURE__ */ jsx(
|
|
143
144
|
"input",
|
|
144
145
|
{
|
|
145
|
-
className: "
|
|
146
|
+
className: "filter-input-control",
|
|
146
147
|
value: query,
|
|
147
148
|
placeholder,
|
|
148
149
|
onChange: (e) => onQueryChange(e.target.value)
|
|
@@ -152,7 +153,7 @@ function FiMultiSelect({
|
|
|
152
153
|
"button",
|
|
153
154
|
{
|
|
154
155
|
type: "button",
|
|
155
|
-
className: "
|
|
156
|
+
className: "filter-input-reload-button",
|
|
156
157
|
onClick: onReload,
|
|
157
158
|
disabled: loading,
|
|
158
159
|
"aria-label": "Reload",
|
|
@@ -160,27 +161,27 @@ function FiMultiSelect({
|
|
|
160
161
|
}
|
|
161
162
|
)
|
|
162
163
|
] }),
|
|
163
|
-
loading && /* @__PURE__ */ jsx("div", { className: "
|
|
164
|
-
!loading && error && /* @__PURE__ */ jsx("div", { className: "
|
|
164
|
+
loading && /* @__PURE__ */ jsx("div", { className: "filter-input-popup-status", children: /* @__PURE__ */ jsx("span", { className: "filter-input-loading", children: "Loading\u2026" }) }),
|
|
165
|
+
!loading && error && /* @__PURE__ */ jsx("div", { className: "filter-input-popup-status", children: /* @__PURE__ */ jsx("span", { className: "filter-input-error", children: error }) }),
|
|
165
166
|
!loading && !error && options.map((option) => {
|
|
166
167
|
const checked = value.some((item) => optionMatches(option, item));
|
|
167
168
|
return /* @__PURE__ */ jsxs(
|
|
168
169
|
"button",
|
|
169
170
|
{
|
|
170
171
|
type: "button",
|
|
171
|
-
className: cn("
|
|
172
|
+
className: cn("filter-input-option", classNames?.item),
|
|
172
173
|
disabled: option.disabled,
|
|
173
174
|
onMouseDown: (e) => e.preventDefault(),
|
|
174
175
|
onClick: () => onToggle(option),
|
|
175
176
|
children: [
|
|
176
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
177
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
177
|
+
/* @__PURE__ */ jsx("span", { className: "filter-input-option-check", "data-checked": checked || void 0, children: checked && /* @__PURE__ */ jsx(CheckIcon, {}) }),
|
|
178
|
+
/* @__PURE__ */ jsx("span", { className: "filter-input-option-label", children: renderOption ? renderOption(option) : option.label })
|
|
178
179
|
]
|
|
179
180
|
},
|
|
180
181
|
stringifyValue(option.value)
|
|
181
182
|
);
|
|
182
183
|
}),
|
|
183
|
-
!loading && !error && !options.length && /* @__PURE__ */ jsx("div", { className: "
|
|
184
|
+
!loading && !error && !options.length && /* @__PURE__ */ jsx("div", { className: "filter-input-popup-status", children: /* @__PURE__ */ jsx("span", { className: "filter-input-empty", children: "No options" }) })
|
|
184
185
|
] }) }) })
|
|
185
186
|
] });
|
|
186
187
|
}
|
|
@@ -299,16 +300,16 @@ function SelectedValueDisplay({
|
|
|
299
300
|
const emptyText = display.emptyText ?? "No value";
|
|
300
301
|
const variant = display.variant ?? (Array.isArray(value) ? "tags" : "text");
|
|
301
302
|
if (!items.length) {
|
|
302
|
-
return /* @__PURE__ */ jsx("span", { className: "
|
|
303
|
+
return /* @__PURE__ */ jsx("span", { className: "filter-input-selected-empty", children: emptyText });
|
|
303
304
|
}
|
|
304
305
|
if (variant === "count") {
|
|
305
|
-
return /* @__PURE__ */ jsxs("span", { className: "
|
|
306
|
+
return /* @__PURE__ */ jsxs("span", { className: "filter-input-selected-count", children: [
|
|
306
307
|
items.length,
|
|
307
308
|
" selected"
|
|
308
309
|
] });
|
|
309
310
|
}
|
|
310
311
|
if (variant === "summary") {
|
|
311
|
-
return /* @__PURE__ */ jsxs("span", { className: "
|
|
312
|
+
return /* @__PURE__ */ jsxs("span", { className: "filter-input-selected-summary", children: [
|
|
312
313
|
items.length,
|
|
313
314
|
" ",
|
|
314
315
|
display.summaryLabel ?? "selected"
|
|
@@ -318,25 +319,25 @@ function SelectedValueDisplay({
|
|
|
318
319
|
const visible = items.slice(0, maxVisible);
|
|
319
320
|
const hidden = Math.max(0, items.length - visible.length);
|
|
320
321
|
if (variant === "text") {
|
|
321
|
-
return /* @__PURE__ */ jsx("span", { className: "
|
|
322
|
+
return /* @__PURE__ */ jsx("span", { className: "filter-input-selected-text", children: items.map((item) => display.formatLabel?.(item) ?? item.label).join(", ") });
|
|
322
323
|
}
|
|
323
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
324
|
+
return /* @__PURE__ */ jsxs("div", { className: "filter-input-selected-list", children: [
|
|
324
325
|
visible.map((item) => {
|
|
325
326
|
const label = display.formatLabel?.(item) ?? item.label;
|
|
326
327
|
return /* @__PURE__ */ jsxs(
|
|
327
328
|
"span",
|
|
328
329
|
{
|
|
329
|
-
className: "
|
|
330
|
+
className: "filter-input-tag",
|
|
330
331
|
"data-size": display.size ?? "sm",
|
|
331
332
|
title: label,
|
|
332
333
|
style: display.colorBy !== "none" ? { borderColor: optionColor(item), color: optionColor(item) } : void 0,
|
|
333
334
|
children: [
|
|
334
|
-
/* @__PURE__ */ jsx("span", { className: "
|
|
335
|
+
/* @__PURE__ */ jsx("span", { className: "filter-input-tag-label", children: label }),
|
|
335
336
|
display.removable && onRemove && /* @__PURE__ */ jsx(
|
|
336
337
|
"button",
|
|
337
338
|
{
|
|
338
339
|
type: "button",
|
|
339
|
-
className: "
|
|
340
|
+
className: "filter-input-tag-remove",
|
|
340
341
|
"aria-label": `Remove ${label}`,
|
|
341
342
|
onClick: () => onRemove(item.value),
|
|
342
343
|
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
@@ -350,7 +351,7 @@ function SelectedValueDisplay({
|
|
|
350
351
|
hidden > 0 && display.overflow !== "collapse" && /* @__PURE__ */ jsxs(
|
|
351
352
|
"span",
|
|
352
353
|
{
|
|
353
|
-
className: "
|
|
354
|
+
className: "filter-input-tag-overflow",
|
|
354
355
|
title: display.overflow === "tooltip" ? items.slice(maxVisible).map((item) => item.label).join(", ") : void 0,
|
|
355
356
|
children: [
|
|
356
357
|
"+",
|
|
@@ -390,56 +391,77 @@ function FilterInput({
|
|
|
390
391
|
"button",
|
|
391
392
|
{
|
|
392
393
|
type: "button",
|
|
393
|
-
className: cn("
|
|
394
|
+
className: cn("filter-input-clear-button", classNames?.clearButton),
|
|
394
395
|
disabled,
|
|
395
396
|
onClick: () => emit(Array.isArray(value) ? [] : null),
|
|
396
397
|
children: "Clear"
|
|
397
398
|
}
|
|
398
399
|
);
|
|
399
400
|
const commonInputClass = cn(
|
|
400
|
-
"
|
|
401
|
+
"filter-input-control",
|
|
401
402
|
classNames?.control,
|
|
402
403
|
inputClassName
|
|
403
404
|
);
|
|
405
|
+
const leadingIcon = display.leadingIcon;
|
|
406
|
+
const trailingIcon = display.trailingIcon;
|
|
407
|
+
const hasIcons = !!(leadingIcon || trailingIcon);
|
|
408
|
+
const iconAwareInputClass = cn(
|
|
409
|
+
commonInputClass,
|
|
410
|
+
leadingIcon && "filter-input-control-has-leading-icon",
|
|
411
|
+
trailingIcon && "filter-input-control-has-trailing-icon"
|
|
412
|
+
);
|
|
413
|
+
const withIconWrap = (inputEl) => {
|
|
414
|
+
if (!hasIcons) return inputEl;
|
|
415
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-control-wrap", classNames?.controlWrap), children: [
|
|
416
|
+
leadingIcon && /* @__PURE__ */ jsx("span", { className: "filter-input-control-icon filter-input-control-icon-leading", children: leadingIcon }),
|
|
417
|
+
inputEl,
|
|
418
|
+
trailingIcon && /* @__PURE__ */ jsx("span", { className: "filter-input-control-icon filter-input-control-icon-trailing", children: trailingIcon })
|
|
419
|
+
] });
|
|
420
|
+
};
|
|
404
421
|
const control = (() => {
|
|
405
422
|
switch (config.type) {
|
|
406
423
|
case "textarea":
|
|
407
424
|
return /* @__PURE__ */ jsx(
|
|
408
425
|
"textarea",
|
|
409
426
|
{
|
|
410
|
-
className: cn("
|
|
427
|
+
className: cn("filter-input-textarea", classNames?.control, inputClassName),
|
|
411
428
|
value: normalizeText(value),
|
|
412
429
|
placeholder: config.placeholder,
|
|
413
430
|
disabled,
|
|
414
431
|
required: behavior.required,
|
|
432
|
+
"data-size": display.size,
|
|
415
433
|
onChange: (event) => emit(event.target.value)
|
|
416
434
|
}
|
|
417
435
|
);
|
|
418
436
|
case "number":
|
|
419
|
-
return
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
437
|
+
return withIconWrap(
|
|
438
|
+
/* @__PURE__ */ jsx(
|
|
439
|
+
"input",
|
|
440
|
+
{
|
|
441
|
+
className: iconAwareInputClass,
|
|
442
|
+
type: "number",
|
|
443
|
+
value: normalizeText(value),
|
|
444
|
+
min: config.validation?.min,
|
|
445
|
+
max: config.validation?.max,
|
|
446
|
+
placeholder: config.placeholder,
|
|
447
|
+
disabled,
|
|
448
|
+
required: behavior.required,
|
|
449
|
+
"data-size": display.size,
|
|
450
|
+
onKeyDown: (event) => {
|
|
451
|
+
if (["e", "E", "+"].includes(event.key)) event.preventDefault();
|
|
452
|
+
if (event.key === "-" && (config.validation?.min ?? Number.NEGATIVE_INFINITY) >= 0) event.preventDefault();
|
|
453
|
+
},
|
|
454
|
+
onChange: (event) => emit(event.target.value === "" ? null : Number(event.target.value))
|
|
455
|
+
}
|
|
456
|
+
)
|
|
436
457
|
);
|
|
437
458
|
case "boolean":
|
|
438
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("
|
|
459
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-row", classNames?.row), children: [
|
|
439
460
|
/* @__PURE__ */ jsx(
|
|
440
461
|
FiSelect,
|
|
441
462
|
{
|
|
442
|
-
className: "
|
|
463
|
+
className: "filter-input-flex-1",
|
|
464
|
+
size: display.size,
|
|
443
465
|
options: [
|
|
444
466
|
{ label: "True", value: "true" },
|
|
445
467
|
{ label: "False", value: "false" }
|
|
@@ -462,7 +484,7 @@ function FilterInput({
|
|
|
462
484
|
const next = exists ? selected.filter((item) => !optionMatches2(option, item)) : [...selected, option.value];
|
|
463
485
|
emit(next, option);
|
|
464
486
|
};
|
|
465
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("
|
|
487
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-multi", classNames?.multi), children: [
|
|
466
488
|
/* @__PURE__ */ jsx(
|
|
467
489
|
FiMultiSelect,
|
|
468
490
|
{
|
|
@@ -493,15 +515,16 @@ function FilterInput({
|
|
|
493
515
|
classNames: classNames ? { trigger: classNames.multiTrigger, popup: classNames.popover, item: classNames.option } : void 0
|
|
494
516
|
}
|
|
495
517
|
),
|
|
496
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
518
|
+
/* @__PURE__ */ jsx("div", { className: "filter-input-row", children: clearButton })
|
|
497
519
|
] });
|
|
498
520
|
}
|
|
499
521
|
case "select":
|
|
500
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("
|
|
522
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-row", classNames?.row), children: [
|
|
501
523
|
/* @__PURE__ */ jsx(
|
|
502
524
|
FiSelect,
|
|
503
525
|
{
|
|
504
|
-
className: "
|
|
526
|
+
className: "filter-input-flex-1",
|
|
527
|
+
size: display.size,
|
|
505
528
|
options: filteredOptions.map((o) => ({ label: o.label, value: stringifyValue2(o.value), disabled: o.disabled })),
|
|
506
529
|
value: value === null || value === void 0 ? "" : normalizeText(value),
|
|
507
530
|
placeholder: config.placeholder ?? "Select...",
|
|
@@ -527,36 +550,39 @@ function FilterInput({
|
|
|
527
550
|
] });
|
|
528
551
|
case "autocomplete":
|
|
529
552
|
case "combobox":
|
|
530
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("
|
|
531
|
-
/* @__PURE__ */ jsxs("div", { className: cn("
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
553
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-stack", classNames?.stack), children: [
|
|
554
|
+
/* @__PURE__ */ jsxs("div", { className: cn("filter-input-row", classNames?.row), children: [
|
|
555
|
+
withIconWrap(
|
|
556
|
+
/* @__PURE__ */ jsx(
|
|
557
|
+
"input",
|
|
558
|
+
{
|
|
559
|
+
className: iconAwareInputClass,
|
|
560
|
+
value: query,
|
|
561
|
+
placeholder: config.placeholder ?? "Search...",
|
|
562
|
+
disabled,
|
|
563
|
+
"data-size": display.size,
|
|
564
|
+
onChange: (event) => {
|
|
565
|
+
const nextQuery = event.target.value;
|
|
566
|
+
setQuery(nextQuery);
|
|
567
|
+
onSearch?.(nextQuery, { key: config.key });
|
|
568
|
+
if (config.type === "combobox" && behavior.allowCustomValue) emit(nextQuery);
|
|
569
|
+
},
|
|
570
|
+
onBlur: () => {
|
|
571
|
+
if (config.type === "combobox" && behavior.selectOnBlur && query) emit(query);
|
|
572
|
+
}
|
|
547
573
|
}
|
|
548
|
-
|
|
574
|
+
)
|
|
549
575
|
),
|
|
550
576
|
clearButton
|
|
551
577
|
] }),
|
|
552
|
-
(loading || error || filteredOptions.length > 0) && /* @__PURE__ */ jsxs("div", { className: cn("
|
|
553
|
-
loading && /* @__PURE__ */ jsx("div", { className: "
|
|
554
|
-
error && /* @__PURE__ */ jsx("div", { className: "
|
|
578
|
+
(loading || error || filteredOptions.length > 0) && /* @__PURE__ */ jsxs("div", { className: cn("filter-input-popover", classNames?.popover), children: [
|
|
579
|
+
loading && /* @__PURE__ */ jsx("div", { className: "filter-input-loading", children: "Loading..." }),
|
|
580
|
+
error && /* @__PURE__ */ jsx("div", { className: "filter-input-error", children: error }),
|
|
555
581
|
!loading && !error && filteredOptions.map((option) => /* @__PURE__ */ jsxs(
|
|
556
582
|
"button",
|
|
557
583
|
{
|
|
558
584
|
type: "button",
|
|
559
|
-
className: cn("
|
|
585
|
+
className: cn("filter-input-option", classNames?.option),
|
|
560
586
|
disabled: disabled || option.disabled,
|
|
561
587
|
onMouseDown: (event) => event.preventDefault(),
|
|
562
588
|
onClick: () => {
|
|
@@ -564,8 +590,8 @@ function FilterInput({
|
|
|
564
590
|
emit(option.value, option);
|
|
565
591
|
},
|
|
566
592
|
children: [
|
|
567
|
-
/* @__PURE__ */ jsx("span", { className: cn("
|
|
568
|
-
optionMatches2(option, value) && /* @__PURE__ */ jsx("span", { className: "
|
|
593
|
+
/* @__PURE__ */ jsx("span", { className: cn("filter-input-option-label", classNames?.optionLabel), children: renderOption ? renderOption(option) : option.label }),
|
|
594
|
+
optionMatches2(option, value) && /* @__PURE__ */ jsx("span", { className: "filter-input-selected-mark", children: "Selected" })
|
|
569
595
|
]
|
|
570
596
|
},
|
|
571
597
|
stringifyValue2(option.value)
|
|
@@ -584,6 +610,7 @@ function FilterInput({
|
|
|
584
610
|
placeholder: config.placeholder,
|
|
585
611
|
disabled,
|
|
586
612
|
required: behavior.required,
|
|
613
|
+
"data-size": display.size,
|
|
587
614
|
onChange: (event) => emit(event.target.value || null)
|
|
588
615
|
}
|
|
589
616
|
);
|
|
@@ -591,16 +618,16 @@ function FilterInput({
|
|
|
591
618
|
case "datetime-range": {
|
|
592
619
|
const range = getDateRange(value);
|
|
593
620
|
const inputType = config.type === "date-range" ? "date" : "datetime-local";
|
|
594
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("
|
|
595
|
-
/* @__PURE__ */ jsx("input", { className: commonInputClass, type: inputType, value: range.from ?? "", disabled, onChange: (event) => emit({ ...range, from: event.target.value || void 0 }) }),
|
|
596
|
-
/* @__PURE__ */ jsx("input", { className: commonInputClass, type: inputType, value: range.to ?? "", disabled, onChange: (event) => emit({ ...range, to: event.target.value || void 0 }) })
|
|
621
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-range", classNames?.range), children: [
|
|
622
|
+
/* @__PURE__ */ jsx("input", { className: commonInputClass, type: inputType, value: range.from ?? "", disabled, "data-size": display.size, onChange: (event) => emit({ ...range, from: event.target.value || void 0 }) }),
|
|
623
|
+
/* @__PURE__ */ jsx("input", { className: commonInputClass, type: inputType, value: range.to ?? "", disabled, "data-size": display.size, onChange: (event) => emit({ ...range, to: event.target.value || void 0 }) })
|
|
597
624
|
] });
|
|
598
625
|
}
|
|
599
626
|
case "range": {
|
|
600
627
|
const range = getNumberRange(value);
|
|
601
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("
|
|
602
|
-
/* @__PURE__ */ jsx("input", { className: commonInputClass, type: "number", value: range.min ?? "", placeholder: "Min", disabled, min: config.validation?.min, max: config.validation?.max, onChange: (event) => emit({ ...range, min: event.target.value === "" ? void 0 : Number(event.target.value) }) }),
|
|
603
|
-
/* @__PURE__ */ jsx("input", { className: commonInputClass, type: "number", value: range.max ?? "", placeholder: "Max", disabled, min: config.validation?.min, max: config.validation?.max, onChange: (event) => emit({ ...range, max: event.target.value === "" ? void 0 : Number(event.target.value) }) })
|
|
628
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-range", classNames?.range), children: [
|
|
629
|
+
/* @__PURE__ */ jsx("input", { className: commonInputClass, type: "number", value: range.min ?? "", placeholder: "Min", disabled, "data-size": display.size, min: config.validation?.min, max: config.validation?.max, onChange: (event) => emit({ ...range, min: event.target.value === "" ? void 0 : Number(event.target.value) }) }),
|
|
630
|
+
/* @__PURE__ */ jsx("input", { className: commonInputClass, type: "number", value: range.max ?? "", placeholder: "Max", disabled, "data-size": display.size, min: config.validation?.min, max: config.validation?.max, onChange: (event) => emit({ ...range, max: event.target.value === "" ? void 0 : Number(event.target.value) }) })
|
|
604
631
|
] });
|
|
605
632
|
}
|
|
606
633
|
case "tag": {
|
|
@@ -615,7 +642,7 @@ function FilterInput({
|
|
|
615
642
|
"div",
|
|
616
643
|
{
|
|
617
644
|
className: cn(
|
|
618
|
-
"
|
|
645
|
+
"filter-input-tag-input",
|
|
619
646
|
classNames?.tagInput
|
|
620
647
|
),
|
|
621
648
|
"data-disabled": disabled || void 0,
|
|
@@ -629,15 +656,15 @@ function FilterInput({
|
|
|
629
656
|
tags.map((tag) => /* @__PURE__ */ jsxs(
|
|
630
657
|
"span",
|
|
631
658
|
{
|
|
632
|
-
className: cn("
|
|
659
|
+
className: cn("filter-input-tag", classNames?.tag),
|
|
633
660
|
title: tag,
|
|
634
661
|
children: [
|
|
635
|
-
/* @__PURE__ */ jsx("span", { className: cn("
|
|
662
|
+
/* @__PURE__ */ jsx("span", { className: cn("filter-input-tag-label", classNames?.tagLabel), children: tag }),
|
|
636
663
|
/* @__PURE__ */ jsx(
|
|
637
664
|
"button",
|
|
638
665
|
{
|
|
639
666
|
type: "button",
|
|
640
|
-
className: cn("
|
|
667
|
+
className: cn("filter-input-tag-remove", classNames?.tagRemove),
|
|
641
668
|
"aria-label": `Remove ${tag}`,
|
|
642
669
|
disabled,
|
|
643
670
|
onClick: (event) => {
|
|
@@ -655,7 +682,7 @@ function FilterInput({
|
|
|
655
682
|
"input",
|
|
656
683
|
{
|
|
657
684
|
id: `${config.key}-tag-input`,
|
|
658
|
-
className: cn("
|
|
685
|
+
className: cn("filter-input-tag-text-input", classNames?.tagTextInput),
|
|
659
686
|
value: query,
|
|
660
687
|
placeholder: tags.length ? "" : config.placeholder ?? "Add tag...",
|
|
661
688
|
disabled,
|
|
@@ -678,28 +705,31 @@ function FilterInput({
|
|
|
678
705
|
}
|
|
679
706
|
case "text":
|
|
680
707
|
default:
|
|
681
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
708
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-row", classNames?.row), children: [
|
|
709
|
+
withIconWrap(
|
|
710
|
+
/* @__PURE__ */ jsx(
|
|
711
|
+
"input",
|
|
712
|
+
{
|
|
713
|
+
className: iconAwareInputClass,
|
|
714
|
+
type: "text",
|
|
715
|
+
value: normalizeText(value),
|
|
716
|
+
pattern: config.validation?.pattern,
|
|
717
|
+
placeholder: config.placeholder,
|
|
718
|
+
disabled,
|
|
719
|
+
required: behavior.required,
|
|
720
|
+
"data-size": display.size,
|
|
721
|
+
onChange: (event) => emit(event.target.value)
|
|
722
|
+
}
|
|
723
|
+
)
|
|
694
724
|
),
|
|
695
725
|
clearButton
|
|
696
726
|
] });
|
|
697
727
|
}
|
|
698
728
|
})();
|
|
699
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("
|
|
700
|
-
config.label && /* @__PURE__ */ jsxs("label", { className: cn("
|
|
729
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("filter-input-field", classNames?.root, className), children: [
|
|
730
|
+
config.label && /* @__PURE__ */ jsxs("label", { className: cn("filter-input-field-label", classNames?.label), children: [
|
|
701
731
|
config.label,
|
|
702
|
-
behavior.required && /* @__PURE__ */ jsx("span", { className: "
|
|
732
|
+
behavior.required && /* @__PURE__ */ jsx("span", { className: "filter-input-field-required", children: " *" })
|
|
703
733
|
] }),
|
|
704
734
|
control
|
|
705
735
|
] });
|
|
@@ -721,7 +751,7 @@ function FilterVariable({
|
|
|
721
751
|
"div",
|
|
722
752
|
{
|
|
723
753
|
className: cn(
|
|
724
|
-
"
|
|
754
|
+
"filter-input-variable",
|
|
725
755
|
classNames?.root,
|
|
726
756
|
className
|
|
727
757
|
),
|
|
@@ -731,14 +761,14 @@ function FilterVariable({
|
|
|
731
761
|
"div",
|
|
732
762
|
{
|
|
733
763
|
className: cn(
|
|
734
|
-
"
|
|
764
|
+
"filter-input-variable-label",
|
|
735
765
|
classNames?.label,
|
|
736
766
|
labelClassName
|
|
737
767
|
),
|
|
738
768
|
children: label
|
|
739
769
|
}
|
|
740
770
|
),
|
|
741
|
-
/* @__PURE__ */ jsx("div", { className: cn("
|
|
771
|
+
/* @__PURE__ */ jsx("div", { className: cn("filter-input-variable-value", classNames?.value, valueClassName), children: /* @__PURE__ */ jsx(
|
|
742
772
|
FilterInput,
|
|
743
773
|
{
|
|
744
774
|
config: valueConfig,
|