@loykin/filter-input 0.0.1-dev.3 → 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/README.md
CHANGED
|
@@ -26,6 +26,35 @@ import '@loykin/filter-input/styles'
|
|
|
26
26
|
/>
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
## Sizing and icons
|
|
30
|
+
|
|
31
|
+
`config.display` controls a control's size and icon slots:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
<FilterVariable
|
|
35
|
+
config={{
|
|
36
|
+
key: 'search',
|
|
37
|
+
type: 'text',
|
|
38
|
+
display: {
|
|
39
|
+
size: 'lg', // 'sm' | 'md' (default) | 'lg'
|
|
40
|
+
leadingIcon: <SearchIcon />,
|
|
41
|
+
trailingIcon: <span>⌘K</span>, // any ReactNode — set either, both, or neither
|
|
42
|
+
},
|
|
43
|
+
}}
|
|
44
|
+
value={query}
|
|
45
|
+
onChange={setQuery}
|
|
46
|
+
/>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Theming
|
|
50
|
+
|
|
51
|
+
`FilterInput` renders as one opaque field rather than being composed from
|
|
52
|
+
swappable Button/Popover/Select primitives, so there's no `uiAdapter` here (unlike
|
|
53
|
+
`@loykin/datetime-range` and `@loykin/cron-input`). Instead it leans entirely on the
|
|
54
|
+
`--basekit-*` → `var(--background|border|ring|...)` fallback chain — drop it into an
|
|
55
|
+
app that already defines shadcn/ui's CSS variables and its border, radius, and focus
|
|
56
|
+
ring pick those up automatically with zero extra config.
|
|
57
|
+
|
|
29
58
|
React 18 and React 19 are supported. See the
|
|
30
|
-
[BaseKit repository](https://github.com/loykin/basekit) for remote data source
|
|
31
|
-
|
|
59
|
+
[BaseKit repository](https://github.com/loykin/basekit) for remote data source and
|
|
60
|
+
full theming token documentation.
|
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ function FiSelect({
|
|
|
40
40
|
onOpen,
|
|
41
41
|
onReload,
|
|
42
42
|
className,
|
|
43
|
+
size,
|
|
43
44
|
classNames
|
|
44
45
|
}) {
|
|
45
46
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -53,16 +54,16 @@ function FiSelect({
|
|
|
53
54
|
},
|
|
54
55
|
disabled,
|
|
55
56
|
children: [
|
|
56
|
-
/* @__PURE__ */ jsxRuntime.jsxs(select.Select.Trigger, { className: cn("
|
|
57
|
-
/* @__PURE__ */ jsxRuntime.jsx(select.Select.Value, { placeholder, className: "
|
|
58
|
-
/* @__PURE__ */ jsxRuntime.jsx(select.Select.Icon, { className: "
|
|
57
|
+
/* @__PURE__ */ jsxRuntime.jsxs(select.Select.Trigger, { className: cn("filter-input-select-trigger", classNames?.trigger, className), "data-size": size, children: [
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.Select.Value, { placeholder, className: "filter-input-select-value" }),
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.Select.Icon, { className: "filter-input-select-icon", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, {}) })
|
|
59
60
|
] }),
|
|
60
|
-
/* @__PURE__ */ jsxRuntime.jsx(select.Select.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(select.Select.Positioner, { sideOffset: 4, className: "
|
|
61
|
-
(searchable || onReload) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.Select.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(select.Select.Positioner, { sideOffset: 4, className: "filter-input-positioner", children: /* @__PURE__ */ jsxRuntime.jsxs(select.Select.Popup, { className: cn("filter-input-select-popup", classNames?.popup), children: [
|
|
62
|
+
(searchable || onReload) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "filter-input-popup-header", children: [
|
|
62
63
|
searchable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
63
64
|
"input",
|
|
64
65
|
{
|
|
65
|
-
className: "
|
|
66
|
+
className: "filter-input-control",
|
|
66
67
|
value: query,
|
|
67
68
|
placeholder: "Search...",
|
|
68
69
|
autoFocus: true,
|
|
@@ -73,30 +74,30 @@ function FiSelect({
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
),
|
|
76
|
-
onReload && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "
|
|
77
|
+
onReload && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "filter-input-reload-button", onClick: onReload, disabled: loading, "aria-label": "Reload", children: /* @__PURE__ */ jsxRuntime.jsx(RefreshIcon, {}) })
|
|
77
78
|
] }),
|
|
78
|
-
(loading || error) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
79
|
-
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
80
|
-
onReload && !loading && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "
|
|
79
|
+
(loading || error) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "filter-input-popup-status", children: [
|
|
80
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-loading", children: "Loading\u2026" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-error", children: error }),
|
|
81
|
+
onReload && !loading && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "filter-input-reload-button", onClick: onReload, "aria-label": "Retry", children: /* @__PURE__ */ jsxRuntime.jsx(RefreshIcon, {}) })
|
|
81
82
|
] }),
|
|
82
83
|
/* @__PURE__ */ jsxRuntime.jsxs(select.Select.List, { children: [
|
|
83
|
-
!loading && !error && !required && /* @__PURE__ */ jsxRuntime.jsx(select.Select.Item, { value: "", className: cn("
|
|
84
|
+
!loading && !error && !required && /* @__PURE__ */ jsxRuntime.jsx(select.Select.Item, { value: "", className: cn("filter-input-select-item", classNames?.item), children: /* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { className: "filter-input-select-item-text", children: placeholder }) }),
|
|
84
85
|
!loading && !error && options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
85
86
|
select.Select.Item,
|
|
86
87
|
{
|
|
87
88
|
value: option.value,
|
|
88
89
|
disabled: option.disabled,
|
|
89
|
-
className: cn("
|
|
90
|
+
className: cn("filter-input-select-item", classNames?.item),
|
|
90
91
|
children: [
|
|
91
|
-
/* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { className: "
|
|
92
|
-
/* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemIndicator, { className: "
|
|
92
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { className: "filter-input-select-item-text", children: option.label }),
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemIndicator, { className: "filter-input-select-item-indicator", children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) })
|
|
93
94
|
]
|
|
94
95
|
},
|
|
95
96
|
option.value
|
|
96
97
|
)),
|
|
97
|
-
!loading && !error && !options.length && !required && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
98
|
+
!loading && !error && !options.length && !required && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "filter-input-popup-status", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-empty", children: "No options" }) })
|
|
98
99
|
] }),
|
|
99
|
-
onReload && !searchable && !loading && !error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
100
|
+
onReload && !searchable && !loading && !error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "filter-input-popup-footer", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "filter-input-reload-button", onClick: onReload, "aria-label": "Reload", children: /* @__PURE__ */ jsxRuntime.jsx(RefreshIcon, {}) }) })
|
|
100
101
|
] }) }) })
|
|
101
102
|
]
|
|
102
103
|
}
|
|
@@ -131,20 +132,20 @@ function FiMultiSelect({
|
|
|
131
132
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
132
133
|
popover.Popover.Trigger,
|
|
133
134
|
{
|
|
134
|
-
className: cn("
|
|
135
|
+
className: cn("filter-input-multi-trigger", classNames?.trigger),
|
|
135
136
|
disabled,
|
|
136
137
|
children: [
|
|
137
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
138
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-multi-value", children: renderTriggerValue() }),
|
|
139
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-chevron", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, {}) })
|
|
139
140
|
]
|
|
140
141
|
}
|
|
141
142
|
),
|
|
142
|
-
/* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Positioner, { sideOffset: 4, align: "start", className: "
|
|
143
|
-
(searchable || onReload) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
143
|
+
/* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Positioner, { sideOffset: 4, align: "start", className: "filter-input-positioner", children: /* @__PURE__ */ jsxRuntime.jsxs(popover.Popover.Popup, { className: cn("filter-input-multi-popup", classNames?.popup), children: [
|
|
144
|
+
(searchable || onReload) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "filter-input-popup-header", children: [
|
|
144
145
|
searchable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
145
146
|
"input",
|
|
146
147
|
{
|
|
147
|
-
className: "
|
|
148
|
+
className: "filter-input-control",
|
|
148
149
|
value: query,
|
|
149
150
|
placeholder,
|
|
150
151
|
onChange: (e) => onQueryChange(e.target.value)
|
|
@@ -154,7 +155,7 @@ function FiMultiSelect({
|
|
|
154
155
|
"button",
|
|
155
156
|
{
|
|
156
157
|
type: "button",
|
|
157
|
-
className: "
|
|
158
|
+
className: "filter-input-reload-button",
|
|
158
159
|
onClick: onReload,
|
|
159
160
|
disabled: loading,
|
|
160
161
|
"aria-label": "Reload",
|
|
@@ -162,27 +163,27 @@ function FiMultiSelect({
|
|
|
162
163
|
}
|
|
163
164
|
)
|
|
164
165
|
] }),
|
|
165
|
-
loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
166
|
-
!loading && error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
166
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "filter-input-popup-status", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-loading", children: "Loading\u2026" }) }),
|
|
167
|
+
!loading && error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "filter-input-popup-status", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-error", children: error }) }),
|
|
167
168
|
!loading && !error && options.map((option) => {
|
|
168
169
|
const checked = value.some((item) => optionMatches(option, item));
|
|
169
170
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
170
171
|
"button",
|
|
171
172
|
{
|
|
172
173
|
type: "button",
|
|
173
|
-
className: cn("
|
|
174
|
+
className: cn("filter-input-option", classNames?.item),
|
|
174
175
|
disabled: option.disabled,
|
|
175
176
|
onMouseDown: (e) => e.preventDefault(),
|
|
176
177
|
onClick: () => onToggle(option),
|
|
177
178
|
children: [
|
|
178
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
179
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-option-check", "data-checked": checked || void 0, children: checked && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) }),
|
|
180
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-option-label", children: renderOption ? renderOption(option) : option.label })
|
|
180
181
|
]
|
|
181
182
|
},
|
|
182
183
|
stringifyValue(option.value)
|
|
183
184
|
);
|
|
184
185
|
}),
|
|
185
|
-
!loading && !error && !options.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
186
|
+
!loading && !error && !options.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "filter-input-popup-status", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-empty", children: "No options" }) })
|
|
186
187
|
] }) }) })
|
|
187
188
|
] });
|
|
188
189
|
}
|
|
@@ -301,16 +302,16 @@ function SelectedValueDisplay({
|
|
|
301
302
|
const emptyText = display.emptyText ?? "No value";
|
|
302
303
|
const variant = display.variant ?? (Array.isArray(value) ? "tags" : "text");
|
|
303
304
|
if (!items.length) {
|
|
304
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
305
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-selected-empty", children: emptyText });
|
|
305
306
|
}
|
|
306
307
|
if (variant === "count") {
|
|
307
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "
|
|
308
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "filter-input-selected-count", children: [
|
|
308
309
|
items.length,
|
|
309
310
|
" selected"
|
|
310
311
|
] });
|
|
311
312
|
}
|
|
312
313
|
if (variant === "summary") {
|
|
313
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "
|
|
314
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "filter-input-selected-summary", children: [
|
|
314
315
|
items.length,
|
|
315
316
|
" ",
|
|
316
317
|
display.summaryLabel ?? "selected"
|
|
@@ -320,25 +321,25 @@ function SelectedValueDisplay({
|
|
|
320
321
|
const visible = items.slice(0, maxVisible);
|
|
321
322
|
const hidden = Math.max(0, items.length - visible.length);
|
|
322
323
|
if (variant === "text") {
|
|
323
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
324
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-selected-text", children: items.map((item) => display.formatLabel?.(item) ?? item.label).join(", ") });
|
|
324
325
|
}
|
|
325
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
326
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "filter-input-selected-list", children: [
|
|
326
327
|
visible.map((item) => {
|
|
327
328
|
const label = display.formatLabel?.(item) ?? item.label;
|
|
328
329
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
329
330
|
"span",
|
|
330
331
|
{
|
|
331
|
-
className: "
|
|
332
|
+
className: "filter-input-tag",
|
|
332
333
|
"data-size": display.size ?? "sm",
|
|
333
334
|
title: label,
|
|
334
335
|
style: display.colorBy !== "none" ? { borderColor: optionColor(item), color: optionColor(item) } : void 0,
|
|
335
336
|
children: [
|
|
336
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
337
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-tag-label", children: label }),
|
|
337
338
|
display.removable && onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
338
339
|
"button",
|
|
339
340
|
{
|
|
340
341
|
type: "button",
|
|
341
|
-
className: "
|
|
342
|
+
className: "filter-input-tag-remove",
|
|
342
343
|
"aria-label": `Remove ${label}`,
|
|
343
344
|
onClick: () => onRemove(item.value),
|
|
344
345
|
children: /* @__PURE__ */ jsxRuntime.jsx(XIcon, {})
|
|
@@ -352,7 +353,7 @@ function SelectedValueDisplay({
|
|
|
352
353
|
hidden > 0 && display.overflow !== "collapse" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
353
354
|
"span",
|
|
354
355
|
{
|
|
355
|
-
className: "
|
|
356
|
+
className: "filter-input-tag-overflow",
|
|
356
357
|
title: display.overflow === "tooltip" ? items.slice(maxVisible).map((item) => item.label).join(", ") : void 0,
|
|
357
358
|
children: [
|
|
358
359
|
"+",
|
|
@@ -392,56 +393,77 @@ function FilterInput({
|
|
|
392
393
|
"button",
|
|
393
394
|
{
|
|
394
395
|
type: "button",
|
|
395
|
-
className: cn("
|
|
396
|
+
className: cn("filter-input-clear-button", classNames?.clearButton),
|
|
396
397
|
disabled,
|
|
397
398
|
onClick: () => emit(Array.isArray(value) ? [] : null),
|
|
398
399
|
children: "Clear"
|
|
399
400
|
}
|
|
400
401
|
);
|
|
401
402
|
const commonInputClass = cn(
|
|
402
|
-
"
|
|
403
|
+
"filter-input-control",
|
|
403
404
|
classNames?.control,
|
|
404
405
|
inputClassName
|
|
405
406
|
);
|
|
407
|
+
const leadingIcon = display.leadingIcon;
|
|
408
|
+
const trailingIcon = display.trailingIcon;
|
|
409
|
+
const hasIcons = !!(leadingIcon || trailingIcon);
|
|
410
|
+
const iconAwareInputClass = cn(
|
|
411
|
+
commonInputClass,
|
|
412
|
+
leadingIcon && "filter-input-control-has-leading-icon",
|
|
413
|
+
trailingIcon && "filter-input-control-has-trailing-icon"
|
|
414
|
+
);
|
|
415
|
+
const withIconWrap = (inputEl) => {
|
|
416
|
+
if (!hasIcons) return inputEl;
|
|
417
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-control-wrap", classNames?.controlWrap), children: [
|
|
418
|
+
leadingIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-control-icon filter-input-control-icon-leading", children: leadingIcon }),
|
|
419
|
+
inputEl,
|
|
420
|
+
trailingIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-control-icon filter-input-control-icon-trailing", children: trailingIcon })
|
|
421
|
+
] });
|
|
422
|
+
};
|
|
406
423
|
const control = (() => {
|
|
407
424
|
switch (config.type) {
|
|
408
425
|
case "textarea":
|
|
409
426
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
410
427
|
"textarea",
|
|
411
428
|
{
|
|
412
|
-
className: cn("
|
|
429
|
+
className: cn("filter-input-textarea", classNames?.control, inputClassName),
|
|
413
430
|
value: normalizeText(value),
|
|
414
431
|
placeholder: config.placeholder,
|
|
415
432
|
disabled,
|
|
416
433
|
required: behavior.required,
|
|
434
|
+
"data-size": display.size,
|
|
417
435
|
onChange: (event) => emit(event.target.value)
|
|
418
436
|
}
|
|
419
437
|
);
|
|
420
438
|
case "number":
|
|
421
|
-
return
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
439
|
+
return withIconWrap(
|
|
440
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
441
|
+
"input",
|
|
442
|
+
{
|
|
443
|
+
className: iconAwareInputClass,
|
|
444
|
+
type: "number",
|
|
445
|
+
value: normalizeText(value),
|
|
446
|
+
min: config.validation?.min,
|
|
447
|
+
max: config.validation?.max,
|
|
448
|
+
placeholder: config.placeholder,
|
|
449
|
+
disabled,
|
|
450
|
+
required: behavior.required,
|
|
451
|
+
"data-size": display.size,
|
|
452
|
+
onKeyDown: (event) => {
|
|
453
|
+
if (["e", "E", "+"].includes(event.key)) event.preventDefault();
|
|
454
|
+
if (event.key === "-" && (config.validation?.min ?? Number.NEGATIVE_INFINITY) >= 0) event.preventDefault();
|
|
455
|
+
},
|
|
456
|
+
onChange: (event) => emit(event.target.value === "" ? null : Number(event.target.value))
|
|
457
|
+
}
|
|
458
|
+
)
|
|
438
459
|
);
|
|
439
460
|
case "boolean":
|
|
440
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
461
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-row", classNames?.row), children: [
|
|
441
462
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
442
463
|
FiSelect,
|
|
443
464
|
{
|
|
444
|
-
className: "
|
|
465
|
+
className: "filter-input-flex-1",
|
|
466
|
+
size: display.size,
|
|
445
467
|
options: [
|
|
446
468
|
{ label: "True", value: "true" },
|
|
447
469
|
{ label: "False", value: "false" }
|
|
@@ -464,7 +486,7 @@ function FilterInput({
|
|
|
464
486
|
const next = exists ? selected.filter((item) => !optionMatches2(option, item)) : [...selected, option.value];
|
|
465
487
|
emit(next, option);
|
|
466
488
|
};
|
|
467
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
489
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-multi", classNames?.multi), children: [
|
|
468
490
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
469
491
|
FiMultiSelect,
|
|
470
492
|
{
|
|
@@ -495,15 +517,16 @@ function FilterInput({
|
|
|
495
517
|
classNames: classNames ? { trigger: classNames.multiTrigger, popup: classNames.popover, item: classNames.option } : void 0
|
|
496
518
|
}
|
|
497
519
|
),
|
|
498
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
520
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "filter-input-row", children: clearButton })
|
|
499
521
|
] });
|
|
500
522
|
}
|
|
501
523
|
case "select":
|
|
502
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
524
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-row", classNames?.row), children: [
|
|
503
525
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
504
526
|
FiSelect,
|
|
505
527
|
{
|
|
506
|
-
className: "
|
|
528
|
+
className: "filter-input-flex-1",
|
|
529
|
+
size: display.size,
|
|
507
530
|
options: filteredOptions.map((o) => ({ label: o.label, value: stringifyValue2(o.value), disabled: o.disabled })),
|
|
508
531
|
value: value === null || value === void 0 ? "" : normalizeText(value),
|
|
509
532
|
placeholder: config.placeholder ?? "Select...",
|
|
@@ -529,36 +552,39 @@ function FilterInput({
|
|
|
529
552
|
] });
|
|
530
553
|
case "autocomplete":
|
|
531
554
|
case "combobox":
|
|
532
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
533
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
555
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-stack", classNames?.stack), children: [
|
|
556
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-row", classNames?.row), children: [
|
|
557
|
+
withIconWrap(
|
|
558
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
559
|
+
"input",
|
|
560
|
+
{
|
|
561
|
+
className: iconAwareInputClass,
|
|
562
|
+
value: query,
|
|
563
|
+
placeholder: config.placeholder ?? "Search...",
|
|
564
|
+
disabled,
|
|
565
|
+
"data-size": display.size,
|
|
566
|
+
onChange: (event) => {
|
|
567
|
+
const nextQuery = event.target.value;
|
|
568
|
+
setQuery(nextQuery);
|
|
569
|
+
onSearch?.(nextQuery, { key: config.key });
|
|
570
|
+
if (config.type === "combobox" && behavior.allowCustomValue) emit(nextQuery);
|
|
571
|
+
},
|
|
572
|
+
onBlur: () => {
|
|
573
|
+
if (config.type === "combobox" && behavior.selectOnBlur && query) emit(query);
|
|
574
|
+
}
|
|
549
575
|
}
|
|
550
|
-
|
|
576
|
+
)
|
|
551
577
|
),
|
|
552
578
|
clearButton
|
|
553
579
|
] }),
|
|
554
|
-
(loading || error || filteredOptions.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
555
|
-
loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
556
|
-
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
580
|
+
(loading || error || filteredOptions.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-popover", classNames?.popover), children: [
|
|
581
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "filter-input-loading", children: "Loading..." }),
|
|
582
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "filter-input-error", children: error }),
|
|
557
583
|
!loading && !error && filteredOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
558
584
|
"button",
|
|
559
585
|
{
|
|
560
586
|
type: "button",
|
|
561
|
-
className: cn("
|
|
587
|
+
className: cn("filter-input-option", classNames?.option),
|
|
562
588
|
disabled: disabled || option.disabled,
|
|
563
589
|
onMouseDown: (event) => event.preventDefault(),
|
|
564
590
|
onClick: () => {
|
|
@@ -566,8 +592,8 @@ function FilterInput({
|
|
|
566
592
|
emit(option.value, option);
|
|
567
593
|
},
|
|
568
594
|
children: [
|
|
569
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("
|
|
570
|
-
optionMatches2(option, value) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
595
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("filter-input-option-label", classNames?.optionLabel), children: renderOption ? renderOption(option) : option.label }),
|
|
596
|
+
optionMatches2(option, value) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-selected-mark", children: "Selected" })
|
|
571
597
|
]
|
|
572
598
|
},
|
|
573
599
|
stringifyValue2(option.value)
|
|
@@ -586,6 +612,7 @@ function FilterInput({
|
|
|
586
612
|
placeholder: config.placeholder,
|
|
587
613
|
disabled,
|
|
588
614
|
required: behavior.required,
|
|
615
|
+
"data-size": display.size,
|
|
589
616
|
onChange: (event) => emit(event.target.value || null)
|
|
590
617
|
}
|
|
591
618
|
);
|
|
@@ -593,16 +620,16 @@ function FilterInput({
|
|
|
593
620
|
case "datetime-range": {
|
|
594
621
|
const range = getDateRange(value);
|
|
595
622
|
const inputType = config.type === "date-range" ? "date" : "datetime-local";
|
|
596
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
597
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { className: commonInputClass, type: inputType, value: range.from ?? "", disabled, onChange: (event) => emit({ ...range, from: event.target.value || void 0 }) }),
|
|
598
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { className: commonInputClass, type: inputType, value: range.to ?? "", disabled, onChange: (event) => emit({ ...range, to: event.target.value || void 0 }) })
|
|
623
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-range", classNames?.range), children: [
|
|
624
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { className: commonInputClass, type: inputType, value: range.from ?? "", disabled, "data-size": display.size, onChange: (event) => emit({ ...range, from: event.target.value || void 0 }) }),
|
|
625
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { className: commonInputClass, type: inputType, value: range.to ?? "", disabled, "data-size": display.size, onChange: (event) => emit({ ...range, to: event.target.value || void 0 }) })
|
|
599
626
|
] });
|
|
600
627
|
}
|
|
601
628
|
case "range": {
|
|
602
629
|
const range = getNumberRange(value);
|
|
603
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
604
|
-
/* @__PURE__ */ jsxRuntime.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) }) }),
|
|
605
|
-
/* @__PURE__ */ jsxRuntime.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) }) })
|
|
630
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-range", classNames?.range), children: [
|
|
631
|
+
/* @__PURE__ */ jsxRuntime.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) }) }),
|
|
632
|
+
/* @__PURE__ */ jsxRuntime.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) }) })
|
|
606
633
|
] });
|
|
607
634
|
}
|
|
608
635
|
case "tag": {
|
|
@@ -617,7 +644,7 @@ function FilterInput({
|
|
|
617
644
|
"div",
|
|
618
645
|
{
|
|
619
646
|
className: cn(
|
|
620
|
-
"
|
|
647
|
+
"filter-input-tag-input",
|
|
621
648
|
classNames?.tagInput
|
|
622
649
|
),
|
|
623
650
|
"data-disabled": disabled || void 0,
|
|
@@ -631,15 +658,15 @@ function FilterInput({
|
|
|
631
658
|
tags.map((tag) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
632
659
|
"span",
|
|
633
660
|
{
|
|
634
|
-
className: cn("
|
|
661
|
+
className: cn("filter-input-tag", classNames?.tag),
|
|
635
662
|
title: tag,
|
|
636
663
|
children: [
|
|
637
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("
|
|
664
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("filter-input-tag-label", classNames?.tagLabel), children: tag }),
|
|
638
665
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
639
666
|
"button",
|
|
640
667
|
{
|
|
641
668
|
type: "button",
|
|
642
|
-
className: cn("
|
|
669
|
+
className: cn("filter-input-tag-remove", classNames?.tagRemove),
|
|
643
670
|
"aria-label": `Remove ${tag}`,
|
|
644
671
|
disabled,
|
|
645
672
|
onClick: (event) => {
|
|
@@ -657,7 +684,7 @@ function FilterInput({
|
|
|
657
684
|
"input",
|
|
658
685
|
{
|
|
659
686
|
id: `${config.key}-tag-input`,
|
|
660
|
-
className: cn("
|
|
687
|
+
className: cn("filter-input-tag-text-input", classNames?.tagTextInput),
|
|
661
688
|
value: query,
|
|
662
689
|
placeholder: tags.length ? "" : config.placeholder ?? "Add tag...",
|
|
663
690
|
disabled,
|
|
@@ -680,28 +707,31 @@ function FilterInput({
|
|
|
680
707
|
}
|
|
681
708
|
case "text":
|
|
682
709
|
default:
|
|
683
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
710
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-row", classNames?.row), children: [
|
|
711
|
+
withIconWrap(
|
|
712
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
713
|
+
"input",
|
|
714
|
+
{
|
|
715
|
+
className: iconAwareInputClass,
|
|
716
|
+
type: "text",
|
|
717
|
+
value: normalizeText(value),
|
|
718
|
+
pattern: config.validation?.pattern,
|
|
719
|
+
placeholder: config.placeholder,
|
|
720
|
+
disabled,
|
|
721
|
+
required: behavior.required,
|
|
722
|
+
"data-size": display.size,
|
|
723
|
+
onChange: (event) => emit(event.target.value)
|
|
724
|
+
}
|
|
725
|
+
)
|
|
696
726
|
),
|
|
697
727
|
clearButton
|
|
698
728
|
] });
|
|
699
729
|
}
|
|
700
730
|
})();
|
|
701
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("
|
|
702
|
-
config.label && /* @__PURE__ */ jsxRuntime.jsxs("label", { className: cn("
|
|
731
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("filter-input-field", classNames?.root, className), children: [
|
|
732
|
+
config.label && /* @__PURE__ */ jsxRuntime.jsxs("label", { className: cn("filter-input-field-label", classNames?.label), children: [
|
|
703
733
|
config.label,
|
|
704
|
-
behavior.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
734
|
+
behavior.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "filter-input-field-required", children: " *" })
|
|
705
735
|
] }),
|
|
706
736
|
control
|
|
707
737
|
] });
|
|
@@ -723,7 +753,7 @@ function FilterVariable({
|
|
|
723
753
|
"div",
|
|
724
754
|
{
|
|
725
755
|
className: cn(
|
|
726
|
-
"
|
|
756
|
+
"filter-input-variable",
|
|
727
757
|
classNames?.root,
|
|
728
758
|
className
|
|
729
759
|
),
|
|
@@ -733,14 +763,14 @@ function FilterVariable({
|
|
|
733
763
|
"div",
|
|
734
764
|
{
|
|
735
765
|
className: cn(
|
|
736
|
-
"
|
|
766
|
+
"filter-input-variable-label",
|
|
737
767
|
classNames?.label,
|
|
738
768
|
labelClassName
|
|
739
769
|
),
|
|
740
770
|
children: label
|
|
741
771
|
}
|
|
742
772
|
),
|
|
743
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("
|
|
773
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("filter-input-variable-value", classNames?.value, valueClassName), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
744
774
|
FilterInput,
|
|
745
775
|
{
|
|
746
776
|
config: valueConfig,
|