@l3mpire/ui 2.16.4 → 2.17.0

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.mjs CHANGED
@@ -5328,6 +5328,23 @@ function updateNodeInTree(nodes, id, updater) {
5328
5328
  return node;
5329
5329
  });
5330
5330
  }
5331
+ function toggleGroupLogicInTree(nodes, id) {
5332
+ const idx = nodes.findIndex((n) => n.id === id);
5333
+ if (idx >= 0) {
5334
+ const current = nodes[idx].logicOperator ?? "and";
5335
+ const next = current === "and" ? "or" : "and";
5336
+ return nodes.map(
5337
+ (n, i) => i === 0 ? n : { ...n, logicOperator: next }
5338
+ );
5339
+ }
5340
+ return nodes.map((node) => {
5341
+ if (isFilterGroup(node)) {
5342
+ const updated = toggleGroupLogicInTree(node.children, id);
5343
+ if (updated !== node.children) return { ...node, children: updated };
5344
+ }
5345
+ return node;
5346
+ });
5347
+ }
5331
5348
  function removeNodeFromTree(nodes, id) {
5332
5349
  const result = [];
5333
5350
  for (const node of nodes) {
@@ -7470,7 +7487,7 @@ InteractiveFilterChip.displayName = "InteractiveFilterChip";
7470
7487
 
7471
7488
  // src/components/ui/filter/filter-system.tsx
7472
7489
  import * as React54 from "react";
7473
- import { Icon as Icon37, faXmarkOutline as faXmarkOutline6, faPlusOutline as faPlusOutline5 } from "@l3mpire/icons";
7490
+ import { Icon as Icon37, faPlusOutline as faPlusOutline5 } from "@l3mpire/icons";
7474
7491
 
7475
7492
  // src/components/ui/filter/advanced-chip.tsx
7476
7493
  import * as React47 from "react";
@@ -8028,12 +8045,7 @@ var AdvancedPopover = ({
8028
8045
  }
8029
8046
  };
8030
8047
  const toggleLogicOp = (id) => {
8031
- onFiltersChange(
8032
- updateNodeInTree(filters, id, (n) => ({
8033
- ...n,
8034
- logicOperator: (n.logicOperator ?? "and") === "and" ? "or" : "and"
8035
- }))
8036
- );
8048
+ onFiltersChange(toggleGroupLogicInTree(filters, id));
8037
8049
  };
8038
8050
  const handleGroupChildrenChange = (groupId, children2) => {
8039
8051
  onFiltersChange(
@@ -8325,12 +8337,7 @@ var SummaryChip = ({
8325
8337
  }
8326
8338
  };
8327
8339
  const toggleLogicOp = (id) => {
8328
- onFiltersChange(
8329
- updateNodeInTree(filters, id, (n) => ({
8330
- ...n,
8331
- logicOperator: (n.logicOperator ?? "and") === "and" ? "or" : "and"
8332
- }))
8333
- );
8340
+ onFiltersChange(toggleGroupLogicInTree(filters, id));
8334
8341
  };
8335
8342
  const handleGroupChildrenChange = (groupId, newChildren) => {
8336
8343
  onFiltersChange(
@@ -8623,7 +8630,8 @@ var FilterSystem = ({
8623
8630
  };
8624
8631
  const getPropertyDef = (propertyId) => properties.find((p) => p.id === propertyId);
8625
8632
  const hasAdvanced = filterState.advancedFilters.length > 0;
8626
- const isMinimal = mode === "minimal";
8633
+ const isMinimal = mode === "minimal" || mode === "icon";
8634
+ const isIconOnly = mode === "icon";
8627
8635
  const handleOpenAdvanced = () => {
8628
8636
  setPropertySelectorOpen(false);
8629
8637
  requestAnimationFrame(() => {
@@ -8636,7 +8644,6 @@ var FilterSystem = ({
8636
8644
  };
8637
8645
  const advancedFilterCount = filterState.advancedFilters.length;
8638
8646
  const showAdvancedChip = hasAdvanced || advancedOpen;
8639
- const showSummaryChip = totalCount > 0 || summaryOpen;
8640
8647
  return /* @__PURE__ */ jsxs54(FilterBar, { ref: containerRef, className, children: [
8641
8648
  /* @__PURE__ */ jsxs54(FilterBarLeft, { className: "flex-nowrap flex-1 min-w-0 overflow-x-auto scrollbar-none outline-none [&>*]:shrink-0", children: [
8642
8649
  children,
@@ -8650,38 +8657,32 @@ var FilterSystem = ({
8650
8657
  iconOnly: isMinimal
8651
8658
  }
8652
8659
  ),
8653
- isMinimal ? /* @__PURE__ */ jsxs54(Fragment5, { children: [
8654
- showSummaryChip && /* @__PURE__ */ jsx60(
8655
- SummaryChip,
8656
- {
8657
- count: totalCount,
8658
- filters: [...filterState.basicFilters, ...filterState.advancedFilters],
8659
- properties,
8660
- onFiltersChange: (nodes) => {
8661
- onFilterStateChange({
8662
- ...filterState,
8663
- basicFilters: [],
8664
- advancedFilters: nodes
8665
- });
8666
- },
8667
- onClearAll: handleClearAll,
8668
- open: summaryOpen,
8669
- onOpenChange: setSummaryOpen
8670
- }
8671
- ),
8672
- !showSummaryChip && /* @__PURE__ */ jsx60(
8673
- PropertySelector,
8674
- {
8675
- properties,
8676
- onSelect: handleAddFilter,
8677
- open: propertySelectorOpen,
8678
- onOpenChange: setPropertySelectorOpen,
8679
- onAdvancedFilter: handleOpenAdvanced,
8680
- advancedFilterCount,
8681
- children: /* @__PURE__ */ jsx60(FilterBarButton, { iconOnly: true })
8682
- }
8683
- )
8684
- ] }) : (
8660
+ isMinimal ? /* @__PURE__ */ jsx60(Fragment5, { children: /* @__PURE__ */ jsx60(
8661
+ SummaryChip,
8662
+ {
8663
+ count: totalCount,
8664
+ filters: [...filterState.basicFilters, ...filterState.advancedFilters],
8665
+ properties,
8666
+ onFiltersChange: (nodes) => {
8667
+ onFilterStateChange({
8668
+ ...filterState,
8669
+ basicFilters: [],
8670
+ advancedFilters: nodes
8671
+ });
8672
+ },
8673
+ onClearAll: handleClearAll,
8674
+ open: summaryOpen,
8675
+ onOpenChange: setSummaryOpen,
8676
+ children: /* @__PURE__ */ jsx60(
8677
+ FilterBarButton,
8678
+ {
8679
+ iconOnly: isIconOnly,
8680
+ count: totalCount > 0 ? totalCount : void 0,
8681
+ title: buildFilterSummary(filterState.basicFilters, filterState.advancedFilters.length, properties)
8682
+ }
8683
+ )
8684
+ }
8685
+ ) }) : (
8685
8686
  /* ── DEFAULT MODE ────────────────────────────────────── */
8686
8687
  /* @__PURE__ */ jsxs54(Fragment5, { children: [
8687
8688
  showAdvancedChip && /* @__PURE__ */ jsx60(
@@ -8742,13 +8743,13 @@ var FilterSystem = ({
8742
8743
  )
8743
8744
  ] })
8744
8745
  ),
8745
- totalCount > 0 && /* @__PURE__ */ jsx60(
8746
+ totalCount > 0 && !isIconOnly && /* @__PURE__ */ jsx60(
8746
8747
  "button",
8747
8748
  {
8748
8749
  type: "button",
8749
8750
  onClick: handleClearAll,
8750
- className: "shrink-0 flex items-center gap-sm px-base py-sm min-h-[32px] max-h-[32px] rounded-md cursor-pointer transition-colors hover:bg-[var(--color-accent)]",
8751
- children: isMinimal ? /* @__PURE__ */ jsx60(Icon37, { icon: faXmarkOutline6, size: "sm", className: "text-[var(--color-foreground)]" }) : /* @__PURE__ */ jsx60("span", { className: "text-sm font-semibold leading-sm text-[var(--color-foreground)]", children: "Clear" })
8751
+ className: "shrink-0 flex items-center gap-sm px-base py-sm min-h-[32px] max-h-[32px] rounded-md cursor-pointer transition-colors text-btn-ghost-brand-text-default hover:bg-btn-ghost-brand-bg-hover hover:text-btn-ghost-brand-text-hover active:bg-btn-ghost-brand-bg-pressed active:text-btn-ghost-brand-text-pressed",
8752
+ children: /* @__PURE__ */ jsx60("span", { className: "text-sm font-semibold leading-sm", children: "Clear" })
8752
8753
  }
8753
8754
  )
8754
8755
  ] }),
@@ -8756,6 +8757,20 @@ var FilterSystem = ({
8756
8757
  ] });
8757
8758
  };
8758
8759
  FilterSystem.displayName = "FilterSystem";
8760
+ function buildFilterSummary(filters, advancedCount, properties) {
8761
+ if (filters.length === 0 && advancedCount === 0) return void 0;
8762
+ const lines = [];
8763
+ for (const f of filters) {
8764
+ const prop = properties.find((p) => p.id === f.propertyId);
8765
+ if (!prop) continue;
8766
+ const val = formatFilterValue(f.value, prop.dynamicOptions);
8767
+ lines.push(val ? `${prop.label} ${f.operator} ${val}` : `${prop.label} ${f.operator ?? ""}`);
8768
+ }
8769
+ if (advancedCount > 0) {
8770
+ lines.push(`+ ${advancedCount} advanced filter${advancedCount > 1 ? "s" : ""}`);
8771
+ }
8772
+ return lines.join("\n");
8773
+ }
8759
8774
  export {
8760
8775
  AdvancedChip,
8761
8776
  AdvancedPopover,