@flytedan/flytebot-design-system 0.51.0 → 0.51.2
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.cjs +138 -138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +138 -138
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/components.css +18 -0
package/dist/index.cjs
CHANGED
|
@@ -4630,14 +4630,16 @@ function FilterBar({ fields = [], filters, onFilterChange, onFilterRemove, align
|
|
|
4630
4630
|
const activeCount = activeFilterCount(fields, filters);
|
|
4631
4631
|
const canAdd = addableFields.length > 0;
|
|
4632
4632
|
const showCount = showActiveCount && activeCount > 0;
|
|
4633
|
+
const clearAll = activeCount > 0 ? onClearAll : void 0;
|
|
4634
|
+
const showClear = clearAll !== void 0;
|
|
4633
4635
|
const addMenuItems = [
|
|
4634
4636
|
{ kind: "section", label: "Add filter" },
|
|
4635
4637
|
...addableFields.map((f) => ({ id: f.key, label: f.label, onSelect: () => startEditing(f.key) }))
|
|
4636
4638
|
];
|
|
4637
4639
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: ["fd-filterbar", className].filter(Boolean).join(" "), ...rest, children: [
|
|
4638
4640
|
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-main", children: [
|
|
4639
|
-
canAdd || showCount ? /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-trigger", children: [
|
|
4640
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: addAnchorRef, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
4641
|
+
canAdd || showCount || showClear ? /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-trigger", children: [
|
|
4642
|
+
canAdd || showCount ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: addAnchorRef, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
4641
4643
|
Button,
|
|
4642
4644
|
{
|
|
4643
4645
|
size: "md",
|
|
@@ -4660,7 +4662,8 @@ function FilterBar({ fields = [], filters, onFilterChange, onFilterRemove, align
|
|
|
4660
4662
|
] }) : null
|
|
4661
4663
|
]
|
|
4662
4664
|
}
|
|
4663
|
-
) }),
|
|
4665
|
+
) }) : null,
|
|
4666
|
+
clearAll ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Button, { size: "sm", variant: "ghost", onClick: () => clearAll(), children: "Clear all" }) : null,
|
|
4664
4667
|
canAdd ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4665
4668
|
Popover,
|
|
4666
4669
|
{
|
|
@@ -4675,144 +4678,141 @@ function FilterBar({ fields = [], filters, onFilterChange, onFilterRemove, align
|
|
|
4675
4678
|
}
|
|
4676
4679
|
) : null
|
|
4677
4680
|
] }) : null,
|
|
4678
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
if (e.key === "Enter") setPanel(null);
|
|
4696
|
-
else if (e.key === "Escape") {
|
|
4697
|
-
e.stopPropagation();
|
|
4698
|
-
setPanel(null);
|
|
4699
|
-
}
|
|
4700
|
-
},
|
|
4701
|
-
onBlur: () => setPanel(null)
|
|
4702
|
-
}
|
|
4703
|
-
),
|
|
4704
|
-
isSet(value) ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4705
|
-
"span",
|
|
4706
|
-
{
|
|
4707
|
-
className: "fd-tag-remove",
|
|
4708
|
-
role: "button",
|
|
4709
|
-
"aria-label": "Remove " + field.label,
|
|
4710
|
-
onClick: (e) => {
|
|
4681
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "fd-filterbar-chips", children: fields.map((field) => {
|
|
4682
|
+
const value = filters[field.key];
|
|
4683
|
+
const editing = panel?.kind === "edit" && panel.key === field.key;
|
|
4684
|
+
if (editing && field.type === "text") {
|
|
4685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: ["fd-tag", "fd-filterbar-text"].join(" "), children: [
|
|
4686
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4687
|
+
"input",
|
|
4688
|
+
{
|
|
4689
|
+
ref: textInputRef,
|
|
4690
|
+
className: "fd-filterbar-text-input",
|
|
4691
|
+
value: value ?? "",
|
|
4692
|
+
placeholder: field.placeholder || field.label,
|
|
4693
|
+
"aria-label": field.label,
|
|
4694
|
+
onChange: (e) => commit(field, e.target.value),
|
|
4695
|
+
onKeyDown: (e) => {
|
|
4696
|
+
if (e.key === "Enter") setPanel(null);
|
|
4697
|
+
else if (e.key === "Escape") {
|
|
4711
4698
|
e.stopPropagation();
|
|
4712
|
-
removeField(field);
|
|
4713
4699
|
setPanel(null);
|
|
4714
|
-
}
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4700
|
+
}
|
|
4701
|
+
},
|
|
4702
|
+
onBlur: () => setPanel(null)
|
|
4703
|
+
}
|
|
4704
|
+
),
|
|
4705
|
+
isSet(value) ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4706
|
+
"span",
|
|
4707
|
+
{
|
|
4708
|
+
className: "fd-tag-remove",
|
|
4709
|
+
role: "button",
|
|
4710
|
+
"aria-label": "Remove " + field.label,
|
|
4711
|
+
onClick: (e) => {
|
|
4712
|
+
e.stopPropagation();
|
|
4713
|
+
removeField(field);
|
|
4714
|
+
setPanel(null);
|
|
4715
|
+
},
|
|
4716
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("i", { className: "ph ph-x", "aria-hidden": "true" })
|
|
4717
|
+
}
|
|
4718
|
+
) : null
|
|
4719
|
+
] }, field.key);
|
|
4720
|
+
}
|
|
4721
|
+
const set = isFieldSet(field, value);
|
|
4722
|
+
if (!editing && !set) return null;
|
|
4723
|
+
const chipRef = editing ? editAnchorRef : void 0;
|
|
4724
|
+
const toggleOrClose = () => editing ? closeEditing() : startEditing(field.key);
|
|
4725
|
+
const remove = () => {
|
|
4726
|
+
removeField(field);
|
|
4727
|
+
closeEditing();
|
|
4728
|
+
};
|
|
4729
|
+
const chipText = field.label + (set ? ": " + chipLabel(field, value) : "");
|
|
4730
|
+
const chip = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Tag, { icon: field.icon, selected: true, onClick: toggleOrClose, onRemove: remove, title: chipText, "aria-label": chipText, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(MiddleEllipsis, { text: chipText }) });
|
|
4731
|
+
if (field.type === "text") {
|
|
4732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "fd-filterbar-chip", children: chip }, field.key);
|
|
4733
|
+
}
|
|
4734
|
+
if (field.type === "select") {
|
|
4735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-chip", children: [
|
|
4736
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: chipRef, children: chip }),
|
|
4737
|
+
editing ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4738
|
+
Popover,
|
|
4739
|
+
{
|
|
4740
|
+
open: true,
|
|
4741
|
+
anchorRef: editAnchorRef,
|
|
4742
|
+
onClose: closeEditing,
|
|
4743
|
+
placement: align === "right" ? "bottom-end" : "bottom-start",
|
|
4744
|
+
offset: 6,
|
|
4745
|
+
minWidth: 200,
|
|
4746
|
+
label: field.label,
|
|
4747
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { role: "listbox", "aria-label": field.label, ref: optionsRef, className: "fd-pop-list", children: field.options.map((o) => {
|
|
4748
|
+
const on = o.value === value;
|
|
4749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4750
|
+
"button",
|
|
4751
|
+
{
|
|
4752
|
+
type: "button",
|
|
4753
|
+
role: "option",
|
|
4754
|
+
"aria-selected": on,
|
|
4755
|
+
className: ["fd-opt", on ? "is-selected" : ""].filter(Boolean).join(" "),
|
|
4756
|
+
onClick: () => {
|
|
4757
|
+
commit(field, o.value);
|
|
4758
|
+
setPanel(null);
|
|
4760
4759
|
},
|
|
4761
|
-
o.
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
}
|
|
4815
|
-
|
|
4760
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "fd-opt-label", children: o.label })
|
|
4761
|
+
},
|
|
4762
|
+
o.value
|
|
4763
|
+
);
|
|
4764
|
+
}) })
|
|
4765
|
+
}
|
|
4766
|
+
) : null
|
|
4767
|
+
] }, field.key);
|
|
4768
|
+
}
|
|
4769
|
+
if (field.type === "multiSelect") {
|
|
4770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-chip", children: [
|
|
4771
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: chipRef, children: chip }),
|
|
4772
|
+
editing ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4773
|
+
MultiSelectPanel,
|
|
4774
|
+
{
|
|
4775
|
+
field,
|
|
4776
|
+
value,
|
|
4777
|
+
anchorRef: editAnchorRef,
|
|
4778
|
+
onCommit: (v) => commit(field, v),
|
|
4779
|
+
onClose: closeEditing
|
|
4780
|
+
}
|
|
4781
|
+
) : null
|
|
4782
|
+
] }, field.key);
|
|
4783
|
+
}
|
|
4784
|
+
if (field.type === "range") {
|
|
4785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-chip", children: [
|
|
4786
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: chipRef, children: chip }),
|
|
4787
|
+
editing ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4788
|
+
RangePanel,
|
|
4789
|
+
{
|
|
4790
|
+
field,
|
|
4791
|
+
value,
|
|
4792
|
+
anchorRef: editAnchorRef,
|
|
4793
|
+
onCommit: (v) => commit(field, v),
|
|
4794
|
+
onClose: closeEditing
|
|
4795
|
+
}
|
|
4796
|
+
) : null
|
|
4797
|
+
] }, field.key);
|
|
4798
|
+
}
|
|
4799
|
+
if (field.type === "date") {
|
|
4800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-chip", children: [
|
|
4801
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: chipRef, children: chip }),
|
|
4802
|
+
editing ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4803
|
+
DatePanel,
|
|
4804
|
+
{
|
|
4805
|
+
field,
|
|
4806
|
+
value,
|
|
4807
|
+
anchorRef: editAnchorRef,
|
|
4808
|
+
onCommit: (v) => commit(field, v),
|
|
4809
|
+
onClose: closeEditing
|
|
4810
|
+
}
|
|
4811
|
+
) : null
|
|
4812
|
+
] }, field.key);
|
|
4813
|
+
}
|
|
4814
|
+
return null;
|
|
4815
|
+
}) })
|
|
4816
4816
|
] }),
|
|
4817
4817
|
actions ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "fd-filterbar-actions", children: actions }) : null
|
|
4818
4818
|
] });
|