@konstructio/ui 0.1.2-alpha.70 → 0.1.2-alpha.71

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.
@@ -1,5 +1,5 @@
1
1
  import { FilterComponentProps } from './Filter.types';
2
- import { BadgeMultiSelect, DateFilterDropdown, DateRangeFilterDropdown } from './components';
2
+ import { BadgeMultiSelect, DateFilterDropdown, DateRangeFilterDropdown, TextMultiSelect } from './components';
3
3
  /**
4
4
  * A compound component for building filter interfaces.
5
5
  * Includes sub-components for badge multi-select, date filtering, and reset actions.
@@ -23,4 +23,4 @@ import { BadgeMultiSelect, DateFilterDropdown, DateRangeFilterDropdown } from '.
23
23
  * @see {@link https://konstructio.github.io/konstruct-ui/?path=/docs/components-filter--docs Storybook}
24
24
  */
25
25
  declare const Filter: FilterComponentProps;
26
- export { Filter, BadgeMultiSelect, DateFilterDropdown, DateRangeFilterDropdown, };
26
+ export { Filter, BadgeMultiSelect, TextMultiSelect, DateFilterDropdown, DateRangeFilterDropdown, };
@@ -1,23 +1,26 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
2
  import { cn as m } from "../../utils/index.js";
3
- import { filterVariants as a } from "./Filter.variants.js";
4
- import { BadgeMultiSelect as l } from "./components/BadgeDropdown/BadgeMultiSelect.js";
5
- import { DateFilterDropdown as p } from "./components/DateFilterDropdown/DateFilterDropdown.js";
6
- import { DateRangeFilterDropdown as n } from "./components/DateRangeFilterDropdown/DateRangeFilterDropdown.js";
3
+ import { filterVariants as l } from "./Filter.variants.js";
4
+ import { BadgeMultiSelect as a } from "./components/BadgeDropdown/BadgeMultiSelect.js";
5
+ import { TextMultiSelect as p } from "./components/TextMultiSelect/TextMultiSelect.js";
6
+ import { DateFilterDropdown as n } from "./components/DateFilterDropdown/DateFilterDropdown.js";
7
+ import { DateRangeFilterDropdown as c } from "./components/DateRangeFilterDropdown/DateRangeFilterDropdown.js";
7
8
  import { ResetButton as d } from "./components/ResetButton/ResetButton.js";
8
9
  const t = ({
9
10
  className: e,
10
11
  theme: o = "civo",
11
12
  children: r
12
- }) => /* @__PURE__ */ i("div", { className: m(a({ className: e })), "data-theme": o, children: r });
13
+ }) => /* @__PURE__ */ i("div", { className: m(l({ className: e })), "data-theme": o, children: r });
13
14
  t.displayName = "KonstructFilter";
14
- t.BadgeMultiSelect = l;
15
- t.DateFilterDropdown = p;
16
- t.DateRangeFilterDropdown = n;
15
+ t.BadgeMultiSelect = a;
16
+ t.TextMultiSelect = p;
17
+ t.DateFilterDropdown = n;
18
+ t.DateRangeFilterDropdown = c;
17
19
  t.ResetButton = d;
18
20
  export {
19
- l as BadgeMultiSelect,
20
- p as DateFilterDropdown,
21
- n as DateRangeFilterDropdown,
22
- t as Filter
21
+ a as BadgeMultiSelect,
22
+ n as DateFilterDropdown,
23
+ c as DateRangeFilterDropdown,
24
+ t as Filter,
25
+ p as TextMultiSelect
23
26
  };
@@ -3,7 +3,7 @@ import { FC, PropsWithChildren } from 'react';
3
3
  import { Theme } from '../../domain/theme';
4
4
  import { BadgeProps } from '../Badge/Badge.types';
5
5
  import { filterVariants } from './Filter.variants';
6
- import { BadgeMultiSelectProps, DateFilterDropdownProps, DateRangeFilterDropdownProps, ResetButtonProps } from './components';
6
+ import { BadgeMultiSelectProps, DateFilterDropdownProps, DateRangeFilterDropdownProps, ResetButtonProps, TextMultiSelectProps } from './components';
7
7
  /**
8
8
  * Configuration for a filter option.
9
9
  */
@@ -47,6 +47,7 @@ export type FilterProps = VariantProps<typeof filterVariants> & PropsWithChildre
47
47
  */
48
48
  export type FilterComponentProps = FC<FilterProps> & {
49
49
  BadgeMultiSelect: FC<BadgeMultiSelectProps>;
50
+ TextMultiSelect: FC<TextMultiSelectProps>;
50
51
  DateFilterDropdown: FC<DateFilterDropdownProps>;
51
52
  DateRangeFilterDropdown: FC<DateRangeFilterDropdownProps>;
52
53
  ResetButton: FC<ResetButtonProps>;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { TextMultiSelectProps } from './TextMultiSelect.types';
3
+ export declare const TextMultiSelect: FC<TextMultiSelectProps>;
@@ -0,0 +1,122 @@
1
+ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
+ import { Badge as k } from "../../../Badge/Badge.js";
3
+ import { Button as o } from "../../../Button/Button.js";
4
+ import { Checkbox as v } from "../../../Checkbox/Checkbox.js";
5
+ import { filterButtonIconVariants as C, filterButtonVariants as N } from "../../Filter.variants.js";
6
+ import { cn as r } from "../../../../utils/index.js";
7
+ import { useBadgeMultiSelect as y } from "../BadgeDropdown/BadgeMultiSelect.hook.js";
8
+ import { C as w } from "../../../../chevron-down-BBFYYzZq.js";
9
+ const $ = ({
10
+ options: n,
11
+ label: m,
12
+ position: i = "left",
13
+ onApply: p
14
+ }) => {
15
+ const {
16
+ wrapperRef: h,
17
+ isOpen: l,
18
+ selectedOptions: f,
19
+ selectedCount: c,
20
+ handleOpen: u,
21
+ handleResetOptions: x,
22
+ handleApplyOptions: g,
23
+ handleSelectOption: b
24
+ } = y({ onApply: p });
25
+ return n.length === 0 ? null : /* @__PURE__ */ a("div", { ref: h, className: "relative", children: [
26
+ /* @__PURE__ */ a(
27
+ "button",
28
+ {
29
+ className: r(N(), {
30
+ "text-slate-700 dark:text-metal-50": l
31
+ }),
32
+ onClick: u,
33
+ children: [
34
+ m,
35
+ c.length > 0 && /* @__PURE__ */ e(k, { label: c.length.toString() }),
36
+ /* @__PURE__ */ e(
37
+ w,
38
+ {
39
+ className: r(C(), {
40
+ "rotate-180 text-blue-600 dark:text-aurora-500": l
41
+ })
42
+ }
43
+ )
44
+ ]
45
+ }
46
+ ),
47
+ l && /* @__PURE__ */ a(
48
+ "div",
49
+ {
50
+ className: r(
51
+ "absolute",
52
+ "top-full",
53
+ "mt-1",
54
+ "bg-white",
55
+ "rounded-md",
56
+ "shadow-md",
57
+ "animate-in",
58
+ "fade-in-0",
59
+ "z-10",
60
+ "border",
61
+ "border-gray-200",
62
+ "dark:bg-metal-800",
63
+ "dark:border-metal-700",
64
+ {
65
+ "left-0": i === "left",
66
+ "right-0": i === "right"
67
+ }
68
+ ),
69
+ children: [
70
+ /* @__PURE__ */ e("div", { className: "px-6 py-4", children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-2", children: n.map((t) => {
71
+ const s = !!f.find(
72
+ (d) => d.id === t.id
73
+ );
74
+ return /* @__PURE__ */ a("div", { className: "flex gap-4", children: [
75
+ /* @__PURE__ */ e(
76
+ v,
77
+ {
78
+ defaultChecked: s,
79
+ "data-label": t.id,
80
+ onChange: (d) => b(t, d)
81
+ },
82
+ `${t.id}-${s}`
83
+ ),
84
+ /* @__PURE__ */ e("span", { className: "text-sm text-slate-700 dark:text-metal-200 whitespace-nowrap", children: t.label })
85
+ ] }, t.id);
86
+ }) }) }),
87
+ /* @__PURE__ */ a(
88
+ "div",
89
+ {
90
+ className: r(
91
+ "flex",
92
+ "justify-center",
93
+ "items-center",
94
+ "gap-4",
95
+ "px-6",
96
+ "py-4",
97
+ "border-t",
98
+ "border-gray-200",
99
+ "dark:border-metal-700"
100
+ ),
101
+ children: [
102
+ /* @__PURE__ */ e(
103
+ o,
104
+ {
105
+ variant: "secondary",
106
+ appearance: "compact",
107
+ onClick: x,
108
+ children: "Reset"
109
+ }
110
+ ),
111
+ /* @__PURE__ */ e(o, { appearance: "compact", onClick: g, children: "Apply" })
112
+ ]
113
+ }
114
+ )
115
+ ]
116
+ }
117
+ )
118
+ ] });
119
+ };
120
+ export {
121
+ $ as TextMultiSelect
122
+ };
@@ -0,0 +1,7 @@
1
+ import { Option } from '../../Filter.types';
2
+ export type TextMultiSelectProps = {
3
+ label: string;
4
+ options: Option[];
5
+ position?: 'left' | 'right';
6
+ onApply?: (selectedOptions: Option[]) => void;
7
+ };
@@ -6,3 +6,5 @@ export * from './DateRangeFilterDropdown/DateRangeFilterDropdown';
6
6
  export * from './DateRangeFilterDropdown/DateRangeFilterDropdown.types';
7
7
  export * from './ResetButton/ResetButton';
8
8
  export * from './ResetButton/ResetButton.types';
9
+ export * from './TextMultiSelect/TextMultiSelect';
10
+ export * from './TextMultiSelect/TextMultiSelect.types';
@@ -1,10 +1,12 @@
1
- import { BadgeMultiSelect as t } from "./BadgeDropdown/BadgeMultiSelect.js";
1
+ import { BadgeMultiSelect as o } from "./BadgeDropdown/BadgeMultiSelect.js";
2
2
  import { DateFilterDropdown as p } from "./DateFilterDropdown/DateFilterDropdown.js";
3
- import { DateRangeFilterDropdown as f } from "./DateRangeFilterDropdown/DateRangeFilterDropdown.js";
3
+ import { DateRangeFilterDropdown as x } from "./DateRangeFilterDropdown/DateRangeFilterDropdown.js";
4
4
  import { ResetButton as m } from "./ResetButton/ResetButton.js";
5
+ import { TextMultiSelect as i } from "./TextMultiSelect/TextMultiSelect.js";
5
6
  export {
6
- t as BadgeMultiSelect,
7
+ o as BadgeMultiSelect,
7
8
  p as DateFilterDropdown,
8
- f as DateRangeFilterDropdown,
9
- m as ResetButton
9
+ x as DateRangeFilterDropdown,
10
+ m as ResetButton,
11
+ i as TextMultiSelect
10
12
  };
@@ -1,16 +1,16 @@
1
1
  import { jsx as r, jsxs as n } from "react/jsx-runtime";
2
- import { useMemo as U } from "react";
2
+ import { useMemo as X } from "react";
3
3
  import { cn as s } from "../../utils/index.js";
4
- import { sendToggleRowEvent as X, sendCollapseRowEvent as Y, sendExpandRowEvent as Z } from "./events/index.js";
5
- import { TableProvider as _ } from "./contexts/table.provider.js";
6
- import { Filter as $ } from "./components/Filter/Filter.js";
7
- import { WrapperBody as D } from "./components/WrapperBody/WrapperBody.js";
8
- import { Header as L } from "./components/Header/Header.js";
9
- import { Body as rr } from "./components/Body/Body.js";
10
- import { Pagination as er } from "./components/Pagination/Pagination.js";
11
- import { TruncateText as or } from "./components/TruncateText/TruncateText.js";
12
- import { Actions as ar } from "./components/Actions/Actions.js";
13
- const tr = ({
4
+ import { sendToggleRowEvent as Y, sendCollapseRowEvent as Z, sendExpandRowEvent as _ } from "./events/index.js";
5
+ import { TableProvider as $ } from "./contexts/table.provider.js";
6
+ import { Filter as D } from "./components/Filter/Filter.js";
7
+ import { WrapperBody as L } from "./components/WrapperBody/WrapperBody.js";
8
+ import { Header as rr } from "./components/Header/Header.js";
9
+ import { Body as er } from "./components/Body/Body.js";
10
+ import { Pagination as or } from "./components/Pagination/Pagination.js";
11
+ import { TruncateText as ar } from "./components/TruncateText/TruncateText.js";
12
+ import { Actions as tr } from "./components/Actions/Actions.js";
13
+ const ir = ({
14
14
  id: c,
15
15
  ariaLabel: p,
16
16
  columns: d,
@@ -37,27 +37,28 @@ const tr = ({
37
37
  showFilter: B = !1,
38
38
  showFilterInput: R,
39
39
  filterSearchPlaceholder: V = "",
40
- multiSelectFilter: g,
41
- filterActions: j,
42
- showResetButton: k = !0,
43
- resetButtonClassName: P,
40
+ filters: g,
41
+ multiSelectFilter: j,
42
+ filterActions: k,
43
+ showResetButton: P = !0,
44
+ resetButtonClassName: C,
44
45
  // Hover row
45
- enableHoverRow: C,
46
- classNameHoverRow: H,
46
+ enableHoverRow: H,
47
+ classNameHoverRow: I,
47
48
  // Expandable rows
48
- enableExpandedRow: I,
49
- expandedState: K,
50
- defaultExpanded: M,
51
- classNameExpandedRow: W,
52
- classNameExpandedCell: q,
53
- classNameExpandedContent: F,
54
- classNameExpandedHeader: G,
55
- classNameActiveExpandedRow: J,
56
- onExpandedChange: O,
57
- renderExpandedRow: Q,
58
- keepExpandColumnVisible: S
49
+ enableExpandedRow: K,
50
+ expandedState: M,
51
+ defaultExpanded: W,
52
+ classNameExpandedRow: q,
53
+ classNameExpandedCell: F,
54
+ classNameExpandedContent: G,
55
+ classNameExpandedHeader: J,
56
+ classNameActiveExpandedRow: O,
57
+ onExpandedChange: Q,
58
+ renderExpandedRow: S,
59
+ keepExpandColumnVisible: U
59
60
  }) => {
60
- const e = U(
61
+ const e = X(
61
62
  () => h || [
62
63
  t,
63
64
  i,
@@ -67,7 +68,7 @@ const tr = ({
67
68
  []
68
69
  );
69
70
  return /* @__PURE__ */ r(
70
- _,
71
+ $,
71
72
  {
72
73
  id: c,
73
74
  columns: d,
@@ -77,33 +78,34 @@ const tr = ({
77
78
  totalItems: u,
78
79
  queryOptions: y,
79
80
  isPaginationEnabled: e,
80
- enableExpandedRow: I,
81
- expandedState: K,
82
- onExpandedChange: O,
83
- defaultExpanded: M,
84
- classNameExpandedRow: W,
85
- classNameExpandedCell: q,
86
- classNameExpandedContent: F,
87
- classNameExpandedHeader: G,
88
- classNameActiveExpandedRow: J,
89
- enableHoverRow: C,
90
- classNameHoverRow: H,
91
- renderExpandedRow: Q,
92
- keepExpandColumnVisible: S,
81
+ enableExpandedRow: K,
82
+ expandedState: M,
83
+ onExpandedChange: Q,
84
+ defaultExpanded: W,
85
+ classNameExpandedRow: q,
86
+ classNameExpandedCell: F,
87
+ classNameExpandedContent: G,
88
+ classNameExpandedHeader: J,
89
+ classNameActiveExpandedRow: O,
90
+ enableHoverRow: H,
91
+ classNameHoverRow: I,
92
+ renderExpandedRow: S,
93
+ keepExpandColumnVisible: U,
93
94
  children: /* @__PURE__ */ n("section", { className: s("w-full min-w-fit", b), children: [
94
95
  B && /* @__PURE__ */ r(
95
- $,
96
+ D,
96
97
  {
97
- actions: j,
98
- multiSelectFilter: g,
98
+ actions: k,
99
+ filters: g,
100
+ multiSelectFilter: j,
99
101
  placeholder: V,
100
102
  showFilterInput: R,
101
- showResetButton: k,
102
- resetButtonClassName: P
103
+ showResetButton: P,
104
+ resetButtonClassName: C
103
105
  }
104
106
  ),
105
107
  /* @__PURE__ */ r(
106
- D,
108
+ L,
107
109
  {
108
110
  showPagination: e,
109
111
  classNameWrapperTable: N,
@@ -119,21 +121,21 @@ const tr = ({
119
121
  "aria-label": p,
120
122
  children: [
121
123
  /* @__PURE__ */ r(
122
- L,
124
+ rr,
123
125
  {
124
126
  className: x,
125
127
  classNameArrows: v,
126
128
  classNameActiveArrows: T
127
129
  }
128
130
  ),
129
- /* @__PURE__ */ r(rr, { isLoading: a, showPagination: e })
131
+ /* @__PURE__ */ r(er, { isLoading: a, showPagination: e })
130
132
  ]
131
133
  }
132
134
  )
133
135
  }
134
136
  ),
135
137
  e && /* @__PURE__ */ r(
136
- er,
138
+ or,
137
139
  {
138
140
  showTotalItems: t,
139
141
  showDropdownPagination: i,
@@ -146,16 +148,16 @@ const tr = ({
146
148
  ] })
147
149
  }
148
150
  );
149
- }, o = tr;
151
+ }, o = ir;
150
152
  o.displayName = "KonstructVirtualizedTable";
151
- o.TruncateText = or;
152
- o.Actions = ar;
153
+ o.TruncateText = ar;
154
+ o.Actions = tr;
153
155
  o.Events = {
154
- sendExpandRowEvent: Z,
155
- sendCollapseRowEvent: Y,
156
- sendToggleRowEvent: X
156
+ sendExpandRowEvent: _,
157
+ sendCollapseRowEvent: Z,
158
+ sendToggleRowEvent: Y
157
159
  };
158
160
  export {
159
- or as TruncateText,
161
+ ar as TruncateText,
160
162
  o as VirtualizedTable
161
163
  };
@@ -1,6 +1,7 @@
1
1
  import { ColumnDef as ColumnDefPrimitive, ExpandedState, OnChangeFn, RowData as RowDataPrimitive } from '@tanstack/react-table';
2
2
  import { VariantProps } from 'class-variance-authority';
3
3
  import { ReactNode } from 'react';
4
+ import { DateRange, DateRangeWithTime } from '../DateRangePicker/DateRangePicker.types';
4
5
  import { virtualizeTableVariants } from './VirtualizedTable.variants';
5
6
  import { FilterAction, Option } from './components/Filter/Filter.types';
6
7
  import { UseQueryOptions } from '@tanstack/react-query';
@@ -24,18 +25,73 @@ export type RowDataWithMeta = Record<string, unknown> & {
24
25
  meta?: RowMetadata;
25
26
  };
26
27
  /**
27
- * Configuration for a multi-select filter in the table.
28
+ * Base shape shared by all filter configurations.
28
29
  */
29
- export type MultiSelectFilter = {
30
- /** Unique key for the filter */
30
+ type FilterConfigBase = {
31
+ /** Unique key for the filter, used as query parameter key */
31
32
  key: string;
32
- /** Display label for the filter */
33
+ /** Display label for the filter trigger button */
33
34
  label: string;
34
- /** Position of the filter dropdown */
35
+ /** Position of the dropdown relative to the button */
35
36
  position?: 'right' | 'left';
37
+ };
38
+ /**
39
+ * Configuration for a badge multi-select filter.
40
+ * Options are displayed with Badge components.
41
+ */
42
+ export type BadgeMultiSelectFilterConfig = FilterConfigBase & {
43
+ /** Filter type — defaults to 'badgeMultiSelect' when omitted */
44
+ type?: 'badgeMultiSelect';
36
45
  /** Available filter options */
37
46
  options: Option[];
38
47
  };
48
+ /**
49
+ * Configuration for a text multi-select filter.
50
+ * Options are displayed as plain text labels.
51
+ */
52
+ export type TextMultiSelectFilterConfig = FilterConfigBase & {
53
+ type: 'textMultiSelect';
54
+ /** Available filter options */
55
+ options: Option[];
56
+ };
57
+ /**
58
+ * Configuration for a single date filter.
59
+ */
60
+ export type DateFilterConfig = FilterConfigBase & {
61
+ type: 'date';
62
+ /** Country code for locale formatting (default: 'US') */
63
+ countryCode?: string;
64
+ };
65
+ /**
66
+ * Configuration for a date range filter.
67
+ */
68
+ export type DateRangeFilterConfig = FilterConfigBase & {
69
+ type: 'dateRange';
70
+ /** Whether to show time inputs (default: false) */
71
+ showTime?: boolean;
72
+ /** Time format: '12' for 12-hour or '24' for 24-hour */
73
+ timeFormat?: '12' | '24';
74
+ /** Whether to show preset options (default: true) */
75
+ showPresets?: boolean;
76
+ /** Initial date range */
77
+ defaultRange?: DateRange;
78
+ /** Minimum selectable date */
79
+ minDate?: Date;
80
+ /** Maximum selectable date */
81
+ maxDate?: Date;
82
+ /** Country code for locale formatting (default: 'US') */
83
+ countryCode?: string;
84
+ /** Callback when the date range changes */
85
+ onRangeChange?: (range: DateRangeWithTime) => void;
86
+ };
87
+ /**
88
+ * Union of all supported filter configurations.
89
+ */
90
+ export type FilterConfig = BadgeMultiSelectFilterConfig | TextMultiSelectFilterConfig | DateFilterConfig | DateRangeFilterConfig;
91
+ /**
92
+ * @deprecated Use FilterConfig instead
93
+ */
94
+ export type MultiSelectFilter = BadgeMultiSelectFilterConfig;
39
95
  /**
40
96
  * Props for the VirtualizedTable component.
41
97
  * A feature-rich data table with filtering, pagination, and sorting.
@@ -96,7 +152,9 @@ export type Props<TData extends RowDataPrimitive> = VariantProps<typeof virtuali
96
152
  totalItems?: never;
97
153
  }) & ({
98
154
  filterSearchPlaceholder?: string;
155
+ /** @deprecated Use `filters` instead */
99
156
  multiSelectFilter?: MultiSelectFilter[];
157
+ filters?: FilterConfig[];
100
158
  showFilter: true;
101
159
  showFilterInput?: boolean;
102
160
  filterActions?: FilterAction[];
@@ -104,7 +162,9 @@ export type Props<TData extends RowDataPrimitive> = VariantProps<typeof virtuali
104
162
  resetButtonClassName?: string;
105
163
  } | {
106
164
  filterSearchPlaceholder?: never;
165
+ /** @deprecated Use `filters` instead */
107
166
  multiSelectFilter?: never;
167
+ filters?: never;
108
168
  showFilter?: false | undefined;
109
169
  showFilterInput?: never;
110
170
  filterActions?: FilterAction[];
@@ -135,3 +195,4 @@ export type Props<TData extends RowDataPrimitive> = VariantProps<typeof virtuali
135
195
  renderExpandedRow?: never;
136
196
  keepExpandColumnVisible?: never;
137
197
  });
198
+ export {};