@antadesign/anta 0.3.3 → 0.3.5

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.
Files changed (50) hide show
  1. package/dist/anta_helpers.d.ts +0 -4
  2. package/dist/anta_helpers.js +0 -7
  3. package/dist/components/Calendar.d.ts +9 -3
  4. package/dist/components/Calendar.js +24 -7
  5. package/dist/components/InputDate.d.ts +9 -6
  6. package/dist/components/InputDate.js +83 -143
  7. package/dist/components/InputDate.module.css +1 -1
  8. package/dist/components/InputTime.d.ts +105 -0
  9. package/dist/components/InputTime.js +110 -0
  10. package/dist/components/Menu.d.ts +15 -1
  11. package/dist/components/Menu.js +2 -0
  12. package/dist/components/MenuItem.js +1 -7
  13. package/dist/components/Select.d.ts +96 -14
  14. package/dist/components/Select.js +69 -8
  15. package/dist/components/Select.module.css +1 -1
  16. package/dist/components/SelectFaceted.d.ts +184 -0
  17. package/dist/components/SelectFaceted.js +331 -0
  18. package/dist/components/SelectFaceted.module.css +1 -0
  19. package/dist/components/TabPanel.d.ts +21 -13
  20. package/dist/components/TabPanel.js +13 -2
  21. package/dist/components/Tabs.d.ts +76 -52
  22. package/dist/components/Tabs.js +18 -86
  23. package/dist/elements/a-button.css +1 -1
  24. package/dist/elements/a-calendar.css +1 -1
  25. package/dist/elements/a-checkbox.css +1 -1
  26. package/dist/elements/a-input-time.css +1 -0
  27. package/dist/elements/a-input-time.d.ts +27 -0
  28. package/dist/elements/a-input-time.js +856 -0
  29. package/dist/elements/a-input.css +1 -1
  30. package/dist/elements/a-input.js +8 -1
  31. package/dist/elements/a-menu-item.css +1 -1
  32. package/dist/elements/a-menu-item.d.ts +8 -6
  33. package/dist/elements/a-menu.d.ts +13 -15
  34. package/dist/elements/a-menu.js +71 -25
  35. package/dist/elements/a-radio.css +1 -1
  36. package/dist/elements/a-tab.css +1 -1
  37. package/dist/elements/a-tabpanel.css +1 -1
  38. package/dist/elements/a-tabpanel.d.ts +17 -0
  39. package/dist/elements/a-tabpanel.js +66 -0
  40. package/dist/elements/a-tabs.css +1 -1
  41. package/dist/elements/a-tooltip.js +1 -1
  42. package/dist/elements/index.d.ts +2 -1
  43. package/dist/elements/index.js +6 -1
  44. package/dist/general_types.d.ts +83 -11
  45. package/dist/index.d.ts +7 -5
  46. package/dist/index.js +6 -3
  47. package/dist/jsx-runtime.d.ts +2 -1
  48. package/dist/reset.css +1 -1
  49. package/dist/tokens.css +1 -1
  50. package/package.json +1 -1
@@ -0,0 +1,184 @@
1
+ import type { BaseProps } from '../general_types';
2
+ import type { IconShape } from '../elements/a-icon.shapes';
3
+ import type { SelectItem, SelectOption } from './Select';
4
+ interface FacetBase {
5
+ /** The facet's namespace — the key its value is stored under in the value
6
+ * record, and what `onValueChange`'s `attrs.facet` reports. Unique across
7
+ * `facets`. */
8
+ key: string;
9
+ /** The facet's row label in the menu. */
10
+ label: string;
11
+ /** Leading icon on the facet's row. */
12
+ icon?: IconShape;
13
+ }
14
+ /** A per-facet option-list filter (like `Select`'s `filter`): `true` uses the
15
+ * built-in case-insensitive substring match on an option's value / label /
16
+ * hint; a function `(option, query) => boolean` does custom matching. */
17
+ export type FacetFilter = boolean | ((option: SelectOption, query: string) => boolean);
18
+ /** Pick **one** option. Value: the chosen option's `value` string (or
19
+ * `undefined` when cleared). Re-picking the selected option clears it. Options
20
+ * are `Select`'s `SelectItem`s — bare strings or `SelectOption`s carrying the
21
+ * same fields (`value`, `label`, `hint`, `icon`, `tone`, `disabled`). */
22
+ export interface SelectFacetSingle extends FacetBase {
23
+ kind: 'single';
24
+ /** The options — bare strings or `SelectOption`s (groups / submenus are
25
+ * flattened to their leaves). */
26
+ options: SelectItem[];
27
+ /** Add a search field atop this facet's flyout that filters its options. */
28
+ filter?: FacetFilter;
29
+ }
30
+ /** Pick **any number** of options. Value: an array of the chosen `value`
31
+ * strings (empty array clears the facet). Options are the same `SelectItem`s
32
+ * as `single`. */
33
+ export interface SelectFacetMultiple extends FacetBase {
34
+ kind: 'multiple';
35
+ /** The options — bare strings or `SelectOption`s (groups / submenus flattened). */
36
+ options: SelectItem[];
37
+ /** Add a search field atop this facet's flyout that filters its options. */
38
+ filter?: FacetFilter;
39
+ /** Add a "Select all" row that toggles every option. */
40
+ selectAll?: boolean;
41
+ /** Label for the `selectAll` row.
42
+ * @defaultValue Select all */
43
+ selectAllLabel?: string;
44
+ }
45
+ /** Free-form substring. Value: the typed string (or `undefined` when empty).
46
+ * Applies on Enter or blur — not on every keystroke. */
47
+ export interface SelectFacetText extends FacetBase {
48
+ kind: 'text';
49
+ /** Placeholder for the text field. */
50
+ placeholder?: string;
51
+ }
52
+ /** Context handed to a `custom` facet's `render`. */
53
+ export interface SelectFacetCustomContext<V> {
54
+ /** The facet's current value (`undefined` when unset). */
55
+ value: V | undefined;
56
+ /** Apply a new value for this facet — pass `undefined` to clear it. */
57
+ onChange: (next: V | undefined) => void;
58
+ /** Close the whole filter menu (e.g. after applying from a custom editor). */
59
+ close: () => void;
60
+ }
61
+ /** Bring your own editor and value type — the escape hatch for anything the
62
+ * built-in kinds don't cover, including object-shaped values (a date range, a
63
+ * numeric comparator, …). */
64
+ export interface SelectFacetCustom<V = unknown> extends FacetBase {
65
+ kind: 'custom';
66
+ /** Render the facet's editor inside its flyout. The returned node stays
67
+ * mounted while the menu is open. */
68
+ render: (ctx: SelectFacetCustomContext<V>) => React.ReactNode;
69
+ /** Reduce an active value to a short summary shown on the facet's row (a
70
+ * string or any node). Called only when the value is set. */
71
+ summary: (value: V) => React.ReactNode;
72
+ }
73
+ /** One facet (dimension) of the filter, discriminated by `kind`. */
74
+ export type SelectFacet = SelectFacetSingle | SelectFacetMultiple | SelectFacetText | SelectFacetCustom;
75
+ /** The filter value: a facet key → that facet's value. Per kind the value is a
76
+ * `string` (single / text), a `string[]` (multiple), or your own `V` (custom).
77
+ * A cleared facet is absent from the record (not a falsy entry). */
78
+ export type SelectFacetedValue = Record<string, unknown>;
79
+ /** Second argument to `onValueChange` — what changed. A single-facet edit
80
+ * carries `facet` / `kind` / the facet's new `value`; the "Clear all" row
81
+ * carries `all: true`. Narrow on `'all' in attrs`. */
82
+ export type SelectFacetedChangeAttrs = {
83
+ /** The facet key that changed. */
84
+ facet: string;
85
+ /** That facet's kind. */
86
+ kind: SelectFacet['kind'];
87
+ /** The facet's new value (`undefined` when the facet was cleared). */
88
+ value: unknown;
89
+ } | {
90
+ /** Marks the change as the "Clear all" row emptying every facet. */
91
+ all: true;
92
+ };
93
+ /** Snapshot passed to `renderTrigger` so a custom trigger can reflect the
94
+ * current filter and open state. */
95
+ export interface SelectFacetedTriggerState {
96
+ /** Whether the menu is open — use it for `aria-expanded` and a chevron. */
97
+ open: boolean;
98
+ /** The whole current value record. */
99
+ value: SelectFacetedValue;
100
+ /** Number of **active facets** (each facet with a value counts once,
101
+ * regardless of how many options it holds) — the default badge count. */
102
+ count: number;
103
+ /** Whether the whole control is disabled. */
104
+ disabled: boolean;
105
+ }
106
+ export interface SelectFacetedProps extends Omit<BaseProps, 'children'> {
107
+ /** The facets (dimensions) to filter across, each with its own editor kind. */
108
+ facets: SelectFacet[];
109
+ /** Controlled value — the facet-keyed record. When provided, the consumer
110
+ * owns state: a pick only *requests* a change via `onValueChange` (reject by
111
+ * not updating). Leave undefined for uncontrolled. */
112
+ value?: SelectFacetedValue;
113
+ /** Initial value for the uncontrolled case (the wrapper then owns it). */
114
+ defaultValue?: SelectFacetedValue;
115
+ /** Fires after any facet changes, with the new full value record and an
116
+ * attrs snapshot of what changed. */
117
+ onValueChange?: (value: SelectFacetedValue, attrs: SelectFacetedChangeAttrs) => void;
118
+ /** Default trigger's button label.
119
+ * @defaultValue Filter */
120
+ label?: string;
121
+ /** Default trigger's leading icon.
122
+ * @defaultValue filter */
123
+ icon?: IconShape;
124
+ /** Default trigger's button size.
125
+ * @defaultValue medium */
126
+ size?: 'small' | 'medium' | 'large';
127
+ /** Default trigger's button priority.
128
+ * @defaultValue secondary */
129
+ priority?: 'primary' | 'secondary';
130
+ /** Disable the whole control. */
131
+ disabled?: boolean;
132
+ /** Add a single search field to the top of the root menu that flattens every
133
+ * `single` / `multiple` facet's options into one list and searches across them
134
+ * — typing "alice" surfaces it under both an Assignee and an Owner facet, each
135
+ * selectable in place. `text` / `custom` facets are reachable when the search is
136
+ * empty. Matching uses each facet's `filter` function if it has one, else the
137
+ * built-in substring match. */
138
+ searchable?: boolean;
139
+ /** Placeholder for the global search field.
140
+ * @defaultValue Filter… */
141
+ searchPlaceholder?: string;
142
+ /** Show the per-facet "Clear" row and the "Clear all" row.
143
+ * @defaultValue true */
144
+ clearable?: boolean;
145
+ /** Label for the "Clear all" row.
146
+ * @defaultValue Clear all */
147
+ clearAllLabel?: string;
148
+ /** Render your own trigger in place of the default `Button`. Receives a
149
+ * `SelectFacetedTriggerState`; **return exactly one focusable element** (the
150
+ * menu anchors to it as its previous sibling and opens it on click). Give it
151
+ * `aria-haspopup="menu"` plus `aria-expanded={state.open}`. The custom trigger
152
+ * owns its own styling — `className` / `style` / other props apply to the
153
+ * *default* trigger only, so put your own on the element you return. */
154
+ renderTrigger?: (state: SelectFacetedTriggerState) => React.ReactNode;
155
+ }
156
+ /**
157
+ * `<SelectFaceted>` — a faceted filter: one trigger opens a menu of facets
158
+ * (dimensions), each a submenu flyout with its own editor. Facet kinds:
159
+ * `'single'` (pick one), `'multiple'` (pick many), `'text'` (free-form
160
+ * substring, applied on Enter / blur), and `'custom'` (bring your own editor +
161
+ * value, including object-shaped values). The value is a
162
+ * `Record<facetKey, value>`, so the same option value under two facets stays
163
+ * distinct.
164
+ *
165
+ * Controlled (`value` + `onValueChange`) or uncontrolled (`defaultValue`).
166
+ * There is no `a-select-faceted` element — this wrapper is the coordinator.
167
+ *
168
+ * Requires `@antadesign/anta/elements` (client-side only).
169
+ *
170
+ * @example
171
+ * ```tsx
172
+ * <SelectFaceted
173
+ * facets={[
174
+ * { key: 'assignee', label: 'Assignee', kind: 'multiple', options: people },
175
+ * { key: 'owner', label: 'Owner', kind: 'single', options: people },
176
+ * { key: 'title', label: 'Title', kind: 'text' },
177
+ * ]}
178
+ * value={filters}
179
+ * onValueChange={setFilters}
180
+ * />
181
+ * ```
182
+ */
183
+ export declare const SelectFaceted: (props: SelectFacetedProps) => any;
184
+ export {};
@@ -0,0 +1,331 @@
1
+ import { Fragment, jsx, jsxs } from "@antadesign/anta/jsx-runtime";
2
+ import { useState, useMemo } from "../jsx-runtime";
3
+ import { nativeStateChange } from "../anta_helpers";
4
+ import { Button } from "./Button";
5
+ import { Menu } from "./Menu";
6
+ import { MenuItem } from "./MenuItem";
7
+ import { MenuGroup } from "./MenuGroup";
8
+ import { MenuSeparator } from "./MenuSeparator";
9
+ import { Tag } from "./Tag";
10
+ import { Input } from "./Input";
11
+ import styles from "./SelectFaceted.module.css";
12
+ const normalizeOpt = (o) => typeof o === "string" ? { value: o, label: o } : o;
13
+ const leavesOf = (items) => {
14
+ const out = [];
15
+ for (const it of items) {
16
+ if (typeof it !== "string" && Array.isArray(it.submenu))
17
+ out.push(...leavesOf(it.submenu));
18
+ else if (typeof it !== "string" && Array.isArray(it.options))
19
+ out.push(...leavesOf(it.options));
20
+ else out.push(normalizeOpt(it));
21
+ }
22
+ return out;
23
+ };
24
+ const isEmpty = (v) => v == null || v === "" || Array.isArray(v) && v.length === 0;
25
+ const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
26
+ const defaultMatch = (o, query) => {
27
+ const q = query.trim();
28
+ if (!q) return true;
29
+ const re = new RegExp(q.split(/\s+/).map(escapeRe).join("\\s+"), "i");
30
+ return [o.value, o.label, o.hint].some((v) => typeof v === "string" && re.test(v));
31
+ };
32
+ const SelectFaceted = (props) => {
33
+ const {
34
+ facets,
35
+ value,
36
+ defaultValue,
37
+ onValueChange,
38
+ label = "Filter",
39
+ icon = "filter",
40
+ size,
41
+ priority = "secondary",
42
+ disabled,
43
+ searchable,
44
+ searchPlaceholder = "Filter\u2026",
45
+ clearable = true,
46
+ clearAllLabel = "Clear all",
47
+ renderTrigger,
48
+ className,
49
+ style,
50
+ ...rest
51
+ } = props;
52
+ const controlled = value !== void 0;
53
+ const [internal, setInternal] = useState(defaultValue ?? {});
54
+ const current = controlled ? value : internal;
55
+ const [open, setOpen] = useState(false);
56
+ const [drafts, setDrafts] = useState({});
57
+ const [seenText, setSeenText] = useState({});
58
+ {
59
+ let nextSeen = null;
60
+ let nextDrafts = drafts;
61
+ for (const f of facets) {
62
+ if (f.kind !== "text") continue;
63
+ if (seenText[f.key] !== current[f.key]) {
64
+ nextSeen = { ...nextSeen ?? seenText, [f.key]: current[f.key] };
65
+ nextDrafts = { ...nextDrafts, [f.key]: current[f.key] ?? "" };
66
+ }
67
+ }
68
+ if (nextSeen) {
69
+ setSeenText(nextSeen);
70
+ setDrafts(nextDrafts);
71
+ }
72
+ }
73
+ const [queries, setQueries] = useState({});
74
+ const [rootQuery, setRootQuery] = useState("");
75
+ const [activeIds, setActiveIds] = useState({});
76
+ const onActive = (key) => (e) => {
77
+ const id = nativeStateChange(e).detail?.id ?? null;
78
+ setActiveIds((s) => s[key] === id ? s : { ...s, [key]: id });
79
+ };
80
+ const activeCount = facets.reduce((n, f) => n + (isEmpty(current[f.key]) ? 0 : 1), 0);
81
+ const leavesByKey = useMemo(
82
+ () => new Map(
83
+ facets.map((f) => [
84
+ f.key,
85
+ f.kind === "single" || f.kind === "multiple" ? leavesOf(f.options) : []
86
+ ])
87
+ ),
88
+ [facets]
89
+ );
90
+ const commit = (next, attrs) => {
91
+ if (!controlled) setInternal(next);
92
+ onValueChange?.(next, attrs);
93
+ };
94
+ const setFacet = (facet, nextValue) => {
95
+ const cleared = isEmpty(nextValue);
96
+ const next = { ...current };
97
+ if (cleared) delete next[facet.key];
98
+ else next[facet.key] = nextValue;
99
+ commit(next, { facet: facet.key, kind: facet.kind, value: cleared ? void 0 : nextValue });
100
+ };
101
+ const clearAll = () => commit({}, { all: true });
102
+ const visibleLeavesOf = (facet) => {
103
+ const leaves = leavesByKey.get(facet.key) ?? [];
104
+ if (!facet.filter) return leaves;
105
+ const q = queries[facet.key] ?? "";
106
+ const match = typeof facet.filter === "function" ? facet.filter : defaultMatch;
107
+ return leaves.filter((o) => match(o, q));
108
+ };
109
+ const filterHeader = (facet) => facet.filter ? /* @__PURE__ */ jsx("div", { slot: "header", "data-menu-open": "", style: { padding: "4px" }, children: /* @__PURE__ */ jsx(
110
+ Input,
111
+ {
112
+ "data-menu-search": "",
113
+ size: "small",
114
+ value: queries[facet.key] ?? "",
115
+ placeholder: "Filter\u2026",
116
+ "aria-label": `Filter ${facet.label}`,
117
+ "aria-autocomplete": "list",
118
+ "aria-activedescendant": activeIds[facet.key] ?? void 0,
119
+ onInput: (e) => setQueries((s) => ({ ...s, [facet.key]: e.currentTarget.value }))
120
+ }
121
+ ) }) : null;
122
+ const optionRow = (facet, opt, keyPrefix = "") => {
123
+ const shared = {
124
+ icon: opt.icon,
125
+ label: opt.label ?? opt.value,
126
+ hint: opt.hint,
127
+ tone: opt.tone,
128
+ disabled: opt.disabled,
129
+ "data-menu-open": ""
130
+ };
131
+ if (facet.kind === "single") {
132
+ const cur = current[facet.key];
133
+ return /* @__PURE__ */ jsx(
134
+ MenuItem,
135
+ {
136
+ ...shared,
137
+ selectionIndicator: "check",
138
+ selected: cur === opt.value,
139
+ onSelect: () => setFacet(facet, cur === opt.value ? void 0 : opt.value)
140
+ },
141
+ `${keyPrefix}${opt.value}`
142
+ );
143
+ }
144
+ const arr = current[facet.key] ?? [];
145
+ return /* @__PURE__ */ jsx(
146
+ MenuItem,
147
+ {
148
+ ...shared,
149
+ selectionIndicator: "checkbox",
150
+ selected: arr.includes(opt.value),
151
+ onSelect: () => setFacet(facet, arr.includes(opt.value) ? arr.filter((v) => v !== opt.value) : [...arr, opt.value])
152
+ },
153
+ `${keyPrefix}${opt.value}`
154
+ );
155
+ };
156
+ const renderSingle = (facet) => visibleLeavesOf(facet).map((opt) => optionRow(facet, opt));
157
+ const renderMultiple = (facet) => {
158
+ const arr = current[facet.key] ?? [];
159
+ const leaves = visibleLeavesOf(facet);
160
+ const enabled = leaves.filter((o) => !o.disabled).map((o) => o.value);
161
+ const allOn = enabled.length > 0 && enabled.every((v) => arr.includes(v));
162
+ const someOn = enabled.some((v) => arr.includes(v));
163
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
164
+ facet.selectAll && leaves.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
165
+ /* @__PURE__ */ jsx(
166
+ MenuItem,
167
+ {
168
+ selectionIndicator: "checkbox",
169
+ selected: allOn,
170
+ indeterminate: someOn && !allOn,
171
+ label: facet.selectAllLabel ?? "Select all",
172
+ "data-menu-open": "",
173
+ onSelect: () => setFacet(
174
+ facet,
175
+ // Toggle only the visible set, preserving picks hidden by the filter.
176
+ allOn ? arr.filter((v) => !enabled.includes(v)) : [.../* @__PURE__ */ new Set([...arr, ...enabled])]
177
+ )
178
+ }
179
+ ),
180
+ /* @__PURE__ */ jsx(MenuSeparator, {})
181
+ ] }),
182
+ leaves.map((opt) => optionRow(facet, opt))
183
+ ] });
184
+ };
185
+ const renderFlatResults = () => {
186
+ const groups = facets.filter((f) => f.kind === "single" || f.kind === "multiple").map((facet) => {
187
+ const match = typeof facet.filter === "function" ? facet.filter : defaultMatch;
188
+ return { facet, matched: (leavesByKey.get(facet.key) ?? []).filter((o) => match(o, rootQuery)) };
189
+ }).filter((g) => g.matched.length > 0);
190
+ return groups.map(({ facet, matched }) => /* @__PURE__ */ jsx(MenuGroup, { label: facet.label, children: matched.map((opt) => optionRow(facet, opt, `${facet.key}:`)) }, facet.key));
191
+ };
192
+ const renderText = (facet) => {
193
+ const applied = current[facet.key] ?? "";
194
+ const draft = drafts[facet.key] ?? applied;
195
+ const apply = () => {
196
+ const next = draft.trim() || void 0;
197
+ if (next !== (applied || void 0)) setFacet(facet, next);
198
+ };
199
+ return (
200
+ // `data-menu-open` keeps the menu open through typing; the value commits on
201
+ // Enter / blur, not per keystroke.
202
+ /* @__PURE__ */ jsx("div", { "data-menu-open": "", style: { padding: "4px" }, children: /* @__PURE__ */ jsx(
203
+ Input,
204
+ {
205
+ size: "small",
206
+ value: draft,
207
+ placeholder: facet.placeholder,
208
+ "aria-label": facet.label,
209
+ onInput: (e) => setDrafts((d) => ({ ...d, [facet.key]: e.currentTarget.value })),
210
+ onKeyDown: (e) => {
211
+ if (e.key === "Enter") {
212
+ e.preventDefault();
213
+ apply();
214
+ }
215
+ },
216
+ onBlur: apply
217
+ }
218
+ ) })
219
+ );
220
+ };
221
+ const renderCustom = (facet) => /* @__PURE__ */ jsx("div", { "data-menu-open": "", children: facet.render({
222
+ value: current[facet.key],
223
+ onChange: (next) => setFacet(facet, next),
224
+ close: () => setOpen(false)
225
+ }) });
226
+ const renderEditor = (facet) => {
227
+ const isOptions = facet.kind === "single" || facet.kind === "multiple";
228
+ const body = facet.kind === "single" ? renderSingle(facet) : facet.kind === "multiple" ? renderMultiple(facet) : facet.kind === "text" ? renderText(facet) : renderCustom(facet);
229
+ const hasValue = !isEmpty(current[facet.key]);
230
+ return /* @__PURE__ */ jsxs(Menu, { onactivedescendant: isOptions && facet.filter ? onActive(facet.key) : void 0, children: [
231
+ isOptions && filterHeader(facet),
232
+ body,
233
+ clearable && hasValue && /* @__PURE__ */ jsx("div", { slot: "footer", className: styles.footer, children: /* @__PURE__ */ jsx(
234
+ MenuItem,
235
+ {
236
+ icon: "x",
237
+ label: "Clear",
238
+ "data-menu-open": "",
239
+ onSelect: () => setFacet(facet, void 0)
240
+ }
241
+ ) })
242
+ ] });
243
+ };
244
+ const summaryOf = (facet) => {
245
+ const v = current[facet.key];
246
+ if (isEmpty(v)) return null;
247
+ switch (facet.kind) {
248
+ case "single": {
249
+ const opt = (leavesByKey.get(facet.key) ?? []).find((o) => o.value === v);
250
+ return opt?.label ?? String(v);
251
+ }
252
+ case "multiple":
253
+ return String(v.length);
254
+ case "text":
255
+ return String(v);
256
+ case "custom":
257
+ return facet.summary(v);
258
+ }
259
+ };
260
+ const triggerState = {
261
+ open,
262
+ value: current,
263
+ count: activeCount,
264
+ disabled: !!disabled
265
+ };
266
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
267
+ renderTrigger ? renderTrigger(triggerState) : /* @__PURE__ */ jsx(
268
+ Button,
269
+ {
270
+ icon,
271
+ label,
272
+ priority,
273
+ size,
274
+ disabled,
275
+ "aria-haspopup": "menu",
276
+ "aria-expanded": open ? "true" : "false",
277
+ className,
278
+ style,
279
+ ...rest,
280
+ children: activeCount > 0 && /* @__PURE__ */ jsx(Tag, { size: "small", priority: "primary", tone: "brand", children: String(activeCount) })
281
+ }
282
+ ),
283
+ /* @__PURE__ */ jsxs(
284
+ Menu,
285
+ {
286
+ open,
287
+ onStateChange: (_e, { next }) => {
288
+ setOpen(next);
289
+ if (!next) setRootQuery("");
290
+ },
291
+ onactivedescendant: searchable ? onActive("__root__") : void 0,
292
+ children: [
293
+ searchable && // Pinned global search: flattens all options facets while a query is active.
294
+ /* @__PURE__ */ jsx("div", { slot: "header", "data-menu-open": "", className: styles.search, children: /* @__PURE__ */ jsx(
295
+ Input,
296
+ {
297
+ "data-menu-search": "",
298
+ size: "small",
299
+ value: rootQuery,
300
+ placeholder: searchPlaceholder,
301
+ "aria-label": "Filter all facets",
302
+ "aria-autocomplete": "list",
303
+ "aria-activedescendant": activeIds["__root__"] ?? void 0,
304
+ onInput: (e) => setRootQuery(e.currentTarget.value)
305
+ }
306
+ ) }),
307
+ searchable && rootQuery.trim() ? renderFlatResults() : facets.map((facet) => /* @__PURE__ */ jsxs(MenuItem, { submenu: true, icon: facet.icon, label: facet.label, children: [
308
+ (() => {
309
+ const s = summaryOf(facet);
310
+ return s != null ? /* @__PURE__ */ jsx(Tag, { size: "small", tone: "brand", children: s }) : null;
311
+ })(),
312
+ renderEditor(facet)
313
+ ] }, facet.key)),
314
+ clearable && /* @__PURE__ */ jsx("div", { slot: "footer", className: styles.footer, children: /* @__PURE__ */ jsx(
315
+ MenuItem,
316
+ {
317
+ icon: "filter-x",
318
+ label: clearAllLabel,
319
+ disabled: activeCount === 0,
320
+ "data-menu-open": "",
321
+ onSelect: clearAll
322
+ }
323
+ ) })
324
+ ]
325
+ }
326
+ )
327
+ ] });
328
+ };
329
+ export {
330
+ SelectFaceted
331
+ };
@@ -0,0 +1 @@
1
+ .search{padding:var(--menu-padding, 4px)}.footer{padding:var(--menu-padding, 4px);border-top:1px solid var(--border-4)}
@@ -1,22 +1,30 @@
1
- import type { TabsMounting } from "./Tabs";
2
- /** A panel paired to the `<Tab>` of the same `value`. A **config component**: `Tabs`
3
- * reads these props and renders the underlying `<a-tabpanel>` (id wiring, show/hide,
4
- * `inert`, and the mounting strategy are all `Tabs`' job). */
1
+ /**
2
+ * A tab panel inside `<Tabs>`. Renders a self-managing `<a-tabpanel>` the element
3
+ * finds its `<a-tabs>` (its flat sibling under the same parent — `Tabs` renders the
4
+ * strip and panels with no wrapper), matches by `value`, and shows/hides itself
5
+ * off-DOM. This wrapper is a pure projection: it sets the static ARIA (`role`,
6
+ * `tabindex`, `value`) and passes `children` straight through; `Tabs` never reads
7
+ * or toggles it.
8
+ *
9
+ * Use it as a direct child of `<Tabs>`, paired to an `options` entry by `value`.
10
+ * For a strip and panels in different layout regions (no shared parent), or to
11
+ * unmount an inactive panel (the old `mounting="active" | "lazy"`), drive selection
12
+ * with a controlled `value` and render the content yourself — see the Tabs docs.
13
+ */
5
14
  export interface TabPanelProps {
6
- /** Pairs this panel with the `<Tab value="…">` of the same value. */
15
+ /** Pairs this panel with the tab (`options` entry) of the same `value`. */
7
16
  value: string;
8
17
  /** Panel content — arbitrary React/Preact. */
9
18
  children?: React.ReactNode;
10
- /** Override the `<Tabs mounting>` strategy for just this panel. See `TabsMounting`. */
11
- mounting?: TabsMounting;
19
+ /** How this panel hides while inactive: `display` (default removed from layout
20
+ * and the a11y tree) or `visibility` (keeps its layout box, to measure it or
21
+ * avoid reflow). Both stay mounted; to *not render* an inactive panel, render it
22
+ * conditionally off a controlled `value` (see the Tabs docs).
23
+ * @defaultValue display */
24
+ hideMode?: "display" | "visibility";
12
25
  /** CSS class on the rendered `<a-tabpanel>`. */
13
26
  className?: string;
14
27
  /** Inline style on the rendered `<a-tabpanel>`. */
15
28
  style?: React.CSSProperties;
16
29
  }
17
- /**
18
- * A tab panel inside `<Tabs>`. Configuration only — `Tabs` reads its props and renders
19
- * the real `<a-tabpanel>`, so this component itself produces no DOM. Use it as a direct
20
- * child of `<Tabs>`; rendering it elsewhere does nothing.
21
- */
22
- export declare const TabPanel: (_props: TabPanelProps) => null;
30
+ export declare const TabPanel: ({ value, children, hideMode, className, style }: TabPanelProps) => any;
@@ -1,5 +1,16 @@
1
- import { markTabsKind } from "../anta_helpers";
2
- const TabPanel = markTabsKind((_props) => null, "panel");
1
+ import { jsx } from "@antadesign/anta/jsx-runtime";
2
+ const TabPanel = ({ value, children, hideMode, className, style }) => /* @__PURE__ */ jsx(
3
+ "a-tabpanel",
4
+ {
5
+ value,
6
+ role: "tabpanel",
7
+ tabIndex: 0,
8
+ "hide-mode": hideMode === "visibility" ? "visibility" : void 0,
9
+ class: className,
10
+ style,
11
+ children
12
+ }
13
+ );
3
14
  export {
4
15
  TabPanel
5
16
  };