@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.d.cts CHANGED
@@ -1366,7 +1366,7 @@ interface FilterBarProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "on
1366
1366
  * drop below the chips on a row of their own, still right-aligned, when the bar is too
1367
1367
  * narrow to hold them all on one line. */
1368
1368
  actions?: React.ReactNode;
1369
- /** Shows a "Clear all" button, ahead of the chips, while any filter is applied; it never
1369
+ /** Shows a "Clear all" button, right after the Filter button (under it on a bar too narrow to hold both), while any filter is applied; it never
1370
1370
  * shows without one. Fires once, with no arguments: the host clears every filter in a
1371
1371
  * single update (applied synchronously, like onFilterChange/onFilterRemove), so FilterBar
1372
1372
  * never fans one click out into a removal per filter. */
package/dist/index.d.ts CHANGED
@@ -1366,7 +1366,7 @@ interface FilterBarProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "on
1366
1366
  * drop below the chips on a row of their own, still right-aligned, when the bar is too
1367
1367
  * narrow to hold them all on one line. */
1368
1368
  actions?: React.ReactNode;
1369
- /** Shows a "Clear all" button, ahead of the chips, while any filter is applied; it never
1369
+ /** Shows a "Clear all" button, right after the Filter button (under it on a bar too narrow to hold both), while any filter is applied; it never
1370
1370
  * shows without one. Fires once, with no arguments: the host clears every filter in a
1371
1371
  * single update (applied synchronously, like onFilterChange/onFilterRemove), so FilterBar
1372
1372
  * never fans one click out into a removal per filter. */
package/dist/index.js CHANGED
@@ -4374,14 +4374,16 @@ function FilterBar({ fields = [], filters, onFilterChange, onFilterRemove, align
4374
4374
  const activeCount = activeFilterCount(fields, filters);
4375
4375
  const canAdd = addableFields.length > 0;
4376
4376
  const showCount = showActiveCount && activeCount > 0;
4377
+ const clearAll = activeCount > 0 ? onClearAll : void 0;
4378
+ const showClear = clearAll !== void 0;
4377
4379
  const addMenuItems = [
4378
4380
  { kind: "section", label: "Add filter" },
4379
4381
  ...addableFields.map((f) => ({ id: f.key, label: f.label, onSelect: () => startEditing(f.key) }))
4380
4382
  ];
4381
4383
  return /* @__PURE__ */ jsxs41("span", { className: ["fd-filterbar", className].filter(Boolean).join(" "), ...rest, children: [
4382
4384
  /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-main", children: [
4383
- canAdd || showCount ? /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-trigger", children: [
4384
- /* @__PURE__ */ jsx49("span", { ref: addAnchorRef, children: /* @__PURE__ */ jsxs41(
4385
+ canAdd || showCount || showClear ? /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-trigger", children: [
4386
+ canAdd || showCount ? /* @__PURE__ */ jsx49("span", { ref: addAnchorRef, children: /* @__PURE__ */ jsxs41(
4385
4387
  Button,
4386
4388
  {
4387
4389
  size: "md",
@@ -4404,7 +4406,8 @@ function FilterBar({ fields = [], filters, onFilterChange, onFilterRemove, align
4404
4406
  ] }) : null
4405
4407
  ]
4406
4408
  }
4407
- ) }),
4409
+ ) }) : null,
4410
+ clearAll ? /* @__PURE__ */ jsx49(Button, { size: "sm", variant: "ghost", onClick: () => clearAll(), children: "Clear all" }) : null,
4408
4411
  canAdd ? /* @__PURE__ */ jsx49(
4409
4412
  Popover,
4410
4413
  {
@@ -4419,144 +4422,141 @@ function FilterBar({ fields = [], filters, onFilterChange, onFilterRemove, align
4419
4422
  }
4420
4423
  ) : null
4421
4424
  ] }) : null,
4422
- /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chips", children: [
4423
- onClearAll && activeCount > 0 ? /* @__PURE__ */ jsx49(Button, { size: "sm", variant: "ghost", onClick: () => onClearAll(), children: "Clear all" }) : null,
4424
- fields.map((field) => {
4425
- const value = filters[field.key];
4426
- const editing = panel?.kind === "edit" && panel.key === field.key;
4427
- if (editing && field.type === "text") {
4428
- return /* @__PURE__ */ jsxs41("span", { className: ["fd-tag", "fd-filterbar-text"].join(" "), children: [
4429
- /* @__PURE__ */ jsx49(
4430
- "input",
4431
- {
4432
- ref: textInputRef,
4433
- className: "fd-filterbar-text-input",
4434
- value: value ?? "",
4435
- placeholder: field.placeholder || field.label,
4436
- "aria-label": field.label,
4437
- onChange: (e) => commit(field, e.target.value),
4438
- onKeyDown: (e) => {
4439
- if (e.key === "Enter") setPanel(null);
4440
- else if (e.key === "Escape") {
4441
- e.stopPropagation();
4442
- setPanel(null);
4443
- }
4444
- },
4445
- onBlur: () => setPanel(null)
4446
- }
4447
- ),
4448
- isSet(value) ? /* @__PURE__ */ jsx49(
4449
- "span",
4450
- {
4451
- className: "fd-tag-remove",
4452
- role: "button",
4453
- "aria-label": "Remove " + field.label,
4454
- onClick: (e) => {
4425
+ /* @__PURE__ */ jsx49("span", { className: "fd-filterbar-chips", children: fields.map((field) => {
4426
+ const value = filters[field.key];
4427
+ const editing = panel?.kind === "edit" && panel.key === field.key;
4428
+ if (editing && field.type === "text") {
4429
+ return /* @__PURE__ */ jsxs41("span", { className: ["fd-tag", "fd-filterbar-text"].join(" "), children: [
4430
+ /* @__PURE__ */ jsx49(
4431
+ "input",
4432
+ {
4433
+ ref: textInputRef,
4434
+ className: "fd-filterbar-text-input",
4435
+ value: value ?? "",
4436
+ placeholder: field.placeholder || field.label,
4437
+ "aria-label": field.label,
4438
+ onChange: (e) => commit(field, e.target.value),
4439
+ onKeyDown: (e) => {
4440
+ if (e.key === "Enter") setPanel(null);
4441
+ else if (e.key === "Escape") {
4455
4442
  e.stopPropagation();
4456
- removeField(field);
4457
4443
  setPanel(null);
4458
- },
4459
- children: /* @__PURE__ */ jsx49("i", { className: "ph ph-x", "aria-hidden": "true" })
4460
- }
4461
- ) : null
4462
- ] }, field.key);
4463
- }
4464
- const set = isFieldSet(field, value);
4465
- if (!editing && !set) return null;
4466
- const chipRef = editing ? editAnchorRef : void 0;
4467
- const toggleOrClose = () => editing ? closeEditing() : startEditing(field.key);
4468
- const remove = () => {
4469
- removeField(field);
4470
- closeEditing();
4471
- };
4472
- const chipText = field.label + (set ? ": " + chipLabel(field, value) : "");
4473
- const chip = /* @__PURE__ */ jsx49(Tag, { icon: field.icon, selected: true, onClick: toggleOrClose, onRemove: remove, title: chipText, "aria-label": chipText, children: /* @__PURE__ */ jsx49(MiddleEllipsis, { text: chipText }) });
4474
- if (field.type === "text") {
4475
- return /* @__PURE__ */ jsx49("span", { className: "fd-filterbar-chip", children: chip }, field.key);
4476
- }
4477
- if (field.type === "select") {
4478
- return /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chip", children: [
4479
- /* @__PURE__ */ jsx49("span", { ref: chipRef, children: chip }),
4480
- editing ? /* @__PURE__ */ jsx49(
4481
- Popover,
4482
- {
4483
- open: true,
4484
- anchorRef: editAnchorRef,
4485
- onClose: closeEditing,
4486
- placement: align === "right" ? "bottom-end" : "bottom-start",
4487
- offset: 6,
4488
- minWidth: 200,
4489
- label: field.label,
4490
- children: /* @__PURE__ */ jsx49("span", { role: "listbox", "aria-label": field.label, ref: optionsRef, className: "fd-pop-list", children: field.options.map((o) => {
4491
- const on = o.value === value;
4492
- return /* @__PURE__ */ jsx49(
4493
- "button",
4494
- {
4495
- type: "button",
4496
- role: "option",
4497
- "aria-selected": on,
4498
- className: ["fd-opt", on ? "is-selected" : ""].filter(Boolean).join(" "),
4499
- onClick: () => {
4500
- commit(field, o.value);
4501
- setPanel(null);
4502
- },
4503
- children: /* @__PURE__ */ jsx49("span", { className: "fd-opt-label", children: o.label })
4444
+ }
4445
+ },
4446
+ onBlur: () => setPanel(null)
4447
+ }
4448
+ ),
4449
+ isSet(value) ? /* @__PURE__ */ jsx49(
4450
+ "span",
4451
+ {
4452
+ className: "fd-tag-remove",
4453
+ role: "button",
4454
+ "aria-label": "Remove " + field.label,
4455
+ onClick: (e) => {
4456
+ e.stopPropagation();
4457
+ removeField(field);
4458
+ setPanel(null);
4459
+ },
4460
+ children: /* @__PURE__ */ jsx49("i", { className: "ph ph-x", "aria-hidden": "true" })
4461
+ }
4462
+ ) : null
4463
+ ] }, field.key);
4464
+ }
4465
+ const set = isFieldSet(field, value);
4466
+ if (!editing && !set) return null;
4467
+ const chipRef = editing ? editAnchorRef : void 0;
4468
+ const toggleOrClose = () => editing ? closeEditing() : startEditing(field.key);
4469
+ const remove = () => {
4470
+ removeField(field);
4471
+ closeEditing();
4472
+ };
4473
+ const chipText = field.label + (set ? ": " + chipLabel(field, value) : "");
4474
+ const chip = /* @__PURE__ */ jsx49(Tag, { icon: field.icon, selected: true, onClick: toggleOrClose, onRemove: remove, title: chipText, "aria-label": chipText, children: /* @__PURE__ */ jsx49(MiddleEllipsis, { text: chipText }) });
4475
+ if (field.type === "text") {
4476
+ return /* @__PURE__ */ jsx49("span", { className: "fd-filterbar-chip", children: chip }, field.key);
4477
+ }
4478
+ if (field.type === "select") {
4479
+ return /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chip", children: [
4480
+ /* @__PURE__ */ jsx49("span", { ref: chipRef, children: chip }),
4481
+ editing ? /* @__PURE__ */ jsx49(
4482
+ Popover,
4483
+ {
4484
+ open: true,
4485
+ anchorRef: editAnchorRef,
4486
+ onClose: closeEditing,
4487
+ placement: align === "right" ? "bottom-end" : "bottom-start",
4488
+ offset: 6,
4489
+ minWidth: 200,
4490
+ label: field.label,
4491
+ children: /* @__PURE__ */ jsx49("span", { role: "listbox", "aria-label": field.label, ref: optionsRef, className: "fd-pop-list", children: field.options.map((o) => {
4492
+ const on = o.value === value;
4493
+ return /* @__PURE__ */ jsx49(
4494
+ "button",
4495
+ {
4496
+ type: "button",
4497
+ role: "option",
4498
+ "aria-selected": on,
4499
+ className: ["fd-opt", on ? "is-selected" : ""].filter(Boolean).join(" "),
4500
+ onClick: () => {
4501
+ commit(field, o.value);
4502
+ setPanel(null);
4504
4503
  },
4505
- o.value
4506
- );
4507
- }) })
4508
- }
4509
- ) : null
4510
- ] }, field.key);
4511
- }
4512
- if (field.type === "multiSelect") {
4513
- return /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chip", children: [
4514
- /* @__PURE__ */ jsx49("span", { ref: chipRef, children: chip }),
4515
- editing ? /* @__PURE__ */ jsx49(
4516
- MultiSelectPanel,
4517
- {
4518
- field,
4519
- value,
4520
- anchorRef: editAnchorRef,
4521
- onCommit: (v) => commit(field, v),
4522
- onClose: closeEditing
4523
- }
4524
- ) : null
4525
- ] }, field.key);
4526
- }
4527
- if (field.type === "range") {
4528
- return /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chip", children: [
4529
- /* @__PURE__ */ jsx49("span", { ref: chipRef, children: chip }),
4530
- editing ? /* @__PURE__ */ jsx49(
4531
- RangePanel,
4532
- {
4533
- field,
4534
- value,
4535
- anchorRef: editAnchorRef,
4536
- onCommit: (v) => commit(field, v),
4537
- onClose: closeEditing
4538
- }
4539
- ) : null
4540
- ] }, field.key);
4541
- }
4542
- if (field.type === "date") {
4543
- return /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chip", children: [
4544
- /* @__PURE__ */ jsx49("span", { ref: chipRef, children: chip }),
4545
- editing ? /* @__PURE__ */ jsx49(
4546
- DatePanel,
4547
- {
4548
- field,
4549
- value,
4550
- anchorRef: editAnchorRef,
4551
- onCommit: (v) => commit(field, v),
4552
- onClose: closeEditing
4553
- }
4554
- ) : null
4555
- ] }, field.key);
4556
- }
4557
- return null;
4558
- })
4559
- ] })
4504
+ children: /* @__PURE__ */ jsx49("span", { className: "fd-opt-label", children: o.label })
4505
+ },
4506
+ o.value
4507
+ );
4508
+ }) })
4509
+ }
4510
+ ) : null
4511
+ ] }, field.key);
4512
+ }
4513
+ if (field.type === "multiSelect") {
4514
+ return /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chip", children: [
4515
+ /* @__PURE__ */ jsx49("span", { ref: chipRef, children: chip }),
4516
+ editing ? /* @__PURE__ */ jsx49(
4517
+ MultiSelectPanel,
4518
+ {
4519
+ field,
4520
+ value,
4521
+ anchorRef: editAnchorRef,
4522
+ onCommit: (v) => commit(field, v),
4523
+ onClose: closeEditing
4524
+ }
4525
+ ) : null
4526
+ ] }, field.key);
4527
+ }
4528
+ if (field.type === "range") {
4529
+ return /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chip", children: [
4530
+ /* @__PURE__ */ jsx49("span", { ref: chipRef, children: chip }),
4531
+ editing ? /* @__PURE__ */ jsx49(
4532
+ RangePanel,
4533
+ {
4534
+ field,
4535
+ value,
4536
+ anchorRef: editAnchorRef,
4537
+ onCommit: (v) => commit(field, v),
4538
+ onClose: closeEditing
4539
+ }
4540
+ ) : null
4541
+ ] }, field.key);
4542
+ }
4543
+ if (field.type === "date") {
4544
+ return /* @__PURE__ */ jsxs41("span", { className: "fd-filterbar-chip", children: [
4545
+ /* @__PURE__ */ jsx49("span", { ref: chipRef, children: chip }),
4546
+ editing ? /* @__PURE__ */ jsx49(
4547
+ DatePanel,
4548
+ {
4549
+ field,
4550
+ value,
4551
+ anchorRef: editAnchorRef,
4552
+ onCommit: (v) => commit(field, v),
4553
+ onClose: closeEditing
4554
+ }
4555
+ ) : null
4556
+ ] }, field.key);
4557
+ }
4558
+ return null;
4559
+ }) })
4560
4560
  ] }),
4561
4561
  actions ? /* @__PURE__ */ jsx49("span", { className: "fd-filterbar-actions", children: actions }) : null
4562
4562
  ] });