@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 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.jsxs)("span", { className: "fd-filterbar-chips", children: [
4679
- onClearAll && activeCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Button, { size: "sm", variant: "ghost", onClick: () => onClearAll(), children: "Clear all" }) : null,
4680
- fields.map((field) => {
4681
- const value = filters[field.key];
4682
- const editing = panel?.kind === "edit" && panel.key === field.key;
4683
- if (editing && field.type === "text") {
4684
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: ["fd-tag", "fd-filterbar-text"].join(" "), children: [
4685
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4686
- "input",
4687
- {
4688
- ref: textInputRef,
4689
- className: "fd-filterbar-text-input",
4690
- value: value ?? "",
4691
- placeholder: field.placeholder || field.label,
4692
- "aria-label": field.label,
4693
- onChange: (e) => commit(field, e.target.value),
4694
- onKeyDown: (e) => {
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
- children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("i", { className: "ph ph-x", "aria-hidden": "true" })
4716
- }
4717
- ) : null
4718
- ] }, field.key);
4719
- }
4720
- const set = isFieldSet(field, value);
4721
- if (!editing && !set) return null;
4722
- const chipRef = editing ? editAnchorRef : void 0;
4723
- const toggleOrClose = () => editing ? closeEditing() : startEditing(field.key);
4724
- const remove = () => {
4725
- removeField(field);
4726
- closeEditing();
4727
- };
4728
- const chipText = field.label + (set ? ": " + chipLabel(field, value) : "");
4729
- 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 }) });
4730
- if (field.type === "text") {
4731
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "fd-filterbar-chip", children: chip }, field.key);
4732
- }
4733
- if (field.type === "select") {
4734
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-chip", children: [
4735
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: chipRef, children: chip }),
4736
- editing ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4737
- Popover,
4738
- {
4739
- open: true,
4740
- anchorRef: editAnchorRef,
4741
- onClose: closeEditing,
4742
- placement: align === "right" ? "bottom-end" : "bottom-start",
4743
- offset: 6,
4744
- minWidth: 200,
4745
- label: field.label,
4746
- 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) => {
4747
- const on = o.value === value;
4748
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4749
- "button",
4750
- {
4751
- type: "button",
4752
- role: "option",
4753
- "aria-selected": on,
4754
- className: ["fd-opt", on ? "is-selected" : ""].filter(Boolean).join(" "),
4755
- onClick: () => {
4756
- commit(field, o.value);
4757
- setPanel(null);
4758
- },
4759
- children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "fd-opt-label", children: o.label })
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.value
4762
- );
4763
- }) })
4764
- }
4765
- ) : null
4766
- ] }, field.key);
4767
- }
4768
- if (field.type === "multiSelect") {
4769
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-chip", children: [
4770
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: chipRef, children: chip }),
4771
- editing ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4772
- MultiSelectPanel,
4773
- {
4774
- field,
4775
- value,
4776
- anchorRef: editAnchorRef,
4777
- onCommit: (v) => commit(field, v),
4778
- onClose: closeEditing
4779
- }
4780
- ) : null
4781
- ] }, field.key);
4782
- }
4783
- if (field.type === "range") {
4784
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-chip", children: [
4785
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: chipRef, children: chip }),
4786
- editing ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4787
- RangePanel,
4788
- {
4789
- field,
4790
- value,
4791
- anchorRef: editAnchorRef,
4792
- onCommit: (v) => commit(field, v),
4793
- onClose: closeEditing
4794
- }
4795
- ) : null
4796
- ] }, field.key);
4797
- }
4798
- if (field.type === "date") {
4799
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "fd-filterbar-chip", children: [
4800
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ref: chipRef, children: chip }),
4801
- editing ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4802
- DatePanel,
4803
- {
4804
- field,
4805
- value,
4806
- anchorRef: editAnchorRef,
4807
- onCommit: (v) => commit(field, v),
4808
- onClose: closeEditing
4809
- }
4810
- ) : null
4811
- ] }, field.key);
4812
- }
4813
- return null;
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
  ] });