@stackone/malachite 2.105.0 → 2.106.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/COMPONENTS.md +1 -1
- package/dist/components/Accordion.js +80 -79
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Button.js +53 -58
- package/dist/components/Button.js.map +1 -1
- package/dist/components/ButtonList.js +10 -10
- package/dist/components/ButtonList.js.map +1 -1
- package/dist/components/FilterSearch.js +392 -355
- package/dist/components/FilterSearch.js.map +1 -1
- package/dist/components/FilterSearchPanel.js +167 -0
- package/dist/components/FilterSearchPanel.js.map +1 -0
- package/dist/components/LinkCard.js +78 -55
- package/dist/components/LinkCard.js.map +1 -1
- package/dist/components/SegmentedControl.js +25 -23
- package/dist/components/SegmentedControl.js.map +1 -1
- package/dist/components/Surface.js +45 -44
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/Timeline.js +77 -66
- package/dist/components/Timeline.js.map +1 -1
- package/dist/components/chromeStyles.js +4 -2
- package/dist/components/chromeStyles.js.map +1 -1
- package/dist/components/filterSearchModel.js +32 -31
- package/dist/components/filterSearchModel.js.map +1 -1
- package/dist/components/focusRing.js +16 -9
- package/dist/components/focusRing.js.map +1 -1
- package/dist/index.d.ts +18 -9
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -3,74 +3,74 @@ const w = (e, t) => e !== null ? "items" : t.trim().length > 0 ? "search" : "fil
|
|
|
3
3
|
return e.label.toLowerCase().includes(s) || e.value.toLowerCase().includes(s);
|
|
4
4
|
}, d = (e, t) => {
|
|
5
5
|
var s;
|
|
6
|
-
return new Set(((s = e.find((
|
|
6
|
+
return new Set(((s = e.find((r) => r.filter === t)) == null ? void 0 : s.items) ?? []);
|
|
7
7
|
}, p = (e, t) => e.flatMap((s) => {
|
|
8
|
-
const
|
|
9
|
-
return s.items.map((o) => ({ item: o, filter: s, selected:
|
|
8
|
+
const r = d(t, s.value);
|
|
9
|
+
return s.items.map((o) => ({ item: o, filter: s, selected: r.has(o.value) }));
|
|
10
10
|
}), g = (e, t) => {
|
|
11
11
|
const s = e.filter((n) => m(n.item, t));
|
|
12
12
|
if (!s.some((n) => !n.item.disabled)) return null;
|
|
13
|
-
const
|
|
14
|
-
return
|
|
13
|
+
const r = e.every((n) => n.item.disabled || n.selected), o = t.trim().length > 0 && s.filter((n) => !n.item.disabled).every((n) => n.selected);
|
|
14
|
+
return r || o ? "deselect" : "select";
|
|
15
15
|
}, v = (e, t) => ({
|
|
16
16
|
toggle: g(e, t),
|
|
17
17
|
items: e.filter((s) => m(s.item, t))
|
|
18
|
-
}), S = (e, t, s,
|
|
18
|
+
}), S = (e, t, s, r) => {
|
|
19
19
|
var f;
|
|
20
20
|
if (e === null) return;
|
|
21
21
|
const o = t.find((i) => i.value === e), n = s == null ? void 0 : s.find((i) => i.value === e);
|
|
22
22
|
if (!o || !n) return o ?? n;
|
|
23
|
-
const
|
|
23
|
+
const l = new Set((f = r.find((i) => i.filter === e)) == null ? void 0 : f.items), u = new Set(o.items.map((i) => i.value)), a = n.items.filter((i) => l.has(i.value) && !u.has(i.value));
|
|
24
24
|
return a.length ? { ...o, items: [...o.items, ...a] } : o;
|
|
25
25
|
}, y = (e, t, s) => e ? v(p([e], t), s) : { toggle: null, items: [] }, x = (e, t, s) => v(p(e, t), s), h = (e, t) => {
|
|
26
26
|
const s = new Set(t);
|
|
27
|
-
return e.length === s.size && e.every((
|
|
27
|
+
return e.length === s.size && e.every((r) => s.has(r));
|
|
28
28
|
}, c = (e, t) => {
|
|
29
29
|
const s = t.filter(
|
|
30
|
-
(
|
|
31
|
-
),
|
|
32
|
-
filter:
|
|
33
|
-
items:
|
|
34
|
-
})).filter((
|
|
35
|
-
(
|
|
30
|
+
(l) => !h(l.items, [...d(e, l.filter)])
|
|
31
|
+
), r = new Map(s.map((l) => [l.filter, l.items])), o = e.map((l) => ({
|
|
32
|
+
filter: l.filter,
|
|
33
|
+
items: r.get(l.filter) ?? l.items
|
|
34
|
+
})).filter((l) => l.items.length > 0), n = s.filter(
|
|
35
|
+
(l) => l.items.length > 0 && !e.some((u) => u.filter === l.filter)
|
|
36
36
|
);
|
|
37
37
|
return { next: [...o, ...n], changes: s };
|
|
38
38
|
}, C = (e, t, s) => {
|
|
39
|
-
const
|
|
39
|
+
const r = [...d(e, t)], o = r.includes(s) ? r.filter((n) => n !== s) : [...r, s];
|
|
40
40
|
return c(e, [{ filter: t, items: o }]);
|
|
41
41
|
}, M = (e, t, s) => c(
|
|
42
42
|
t,
|
|
43
|
-
e.map((
|
|
44
|
-
const o = d(t,
|
|
45
|
-
(
|
|
46
|
-
).map((
|
|
47
|
-
return { filter:
|
|
43
|
+
e.map((r) => {
|
|
44
|
+
const o = d(t, r.value), n = r.items.filter(
|
|
45
|
+
(l) => !o.has(l.value) && !l.disabled && m(l, s)
|
|
46
|
+
).map((l) => l.value);
|
|
47
|
+
return { filter: r.value, items: [...o, ...n] };
|
|
48
48
|
})
|
|
49
49
|
), $ = (e, t, s) => c(
|
|
50
50
|
t,
|
|
51
|
-
e.map((
|
|
52
|
-
const o = d(t,
|
|
53
|
-
|
|
51
|
+
e.map((r) => {
|
|
52
|
+
const o = d(t, r.value), n = new Set(
|
|
53
|
+
r.items.filter((l) => !l.disabled && m(l, s)).map((l) => l.value)
|
|
54
54
|
);
|
|
55
55
|
return {
|
|
56
|
-
filter:
|
|
57
|
-
items: [...o].filter((
|
|
56
|
+
filter: r.value,
|
|
57
|
+
items: [...o].filter((l) => !n.has(l))
|
|
58
58
|
};
|
|
59
59
|
})
|
|
60
|
-
), b = (e, t) => c(e, [{ filter: t, items: [] }]), k = (e) => c(
|
|
60
|
+
), b = (e, t) => c(e, [{ filter: t, items: [] }]), k = (e, t = null) => c(
|
|
61
61
|
e,
|
|
62
|
-
e.
|
|
63
|
-
), A = (e, t, s) => c(e, [{ filter: t, items: [s] }]),
|
|
64
|
-
const
|
|
62
|
+
e.filter((s) => s.filter !== t).map((s) => ({ filter: s.filter, items: [] }))
|
|
63
|
+
), A = (e, t, s) => c(e, [{ filter: t, items: s }]), R = (e, t, s) => c(e, [{ filter: t, items: [s] }]), V = (e, t) => t.length === 0 ? e : t.length === 1 ? `${e}: ${t[0]}` : `${e}: (${t.join(", ")})`, T = (e, t, s = null) => {
|
|
64
|
+
const r = new Set(e.map((n) => n.filter)), o = t.filter((n) => r.has(n) || n === s);
|
|
65
65
|
return [
|
|
66
66
|
...o,
|
|
67
67
|
...e.map((n) => n.filter).filter((n) => !o.includes(n))
|
|
68
68
|
];
|
|
69
69
|
};
|
|
70
70
|
export {
|
|
71
|
-
|
|
71
|
+
V as chipText,
|
|
72
72
|
k as clearAll,
|
|
73
|
-
|
|
73
|
+
R as commitText,
|
|
74
74
|
$ as deselectAll,
|
|
75
75
|
y as filterRows,
|
|
76
76
|
m as matchesQuery,
|
|
@@ -80,6 +80,7 @@ export {
|
|
|
80
80
|
w as resolveMode,
|
|
81
81
|
x as searchRows,
|
|
82
82
|
M as selectAll,
|
|
83
|
+
A as setValues,
|
|
83
84
|
C as toggleValue
|
|
84
85
|
};
|
|
85
86
|
//# sourceMappingURL=filterSearchModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterSearchModel.js","sources":["../../src/components/filterSearchModel.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nexport interface FilterSearchItem {\n value: string;\n label: string;\n disabled?: boolean;\n /** Drawn before the label in the menu and in the applied chip: a logo, a status dot. Keep it 12px. */\n icon?: ReactNode;\n}\n\nexport interface FilterSearchFilter {\n value: string;\n label: string;\n /** Shown beside the filter's name in the menu, and beside its values in a cross-filter search. */\n info?: string;\n /** Right-aligned hint on the filter's row, e.g. `e.g. Attio, Ashby`. */\n example?: string;\n /** `false` drops the filter's name from its chip, for a value that reads alone: `Configured only`. */\n chipLabel?: boolean;\n items: FilterSearchItem[];\n}\n\nexport interface FilterSearchSelection {\n filter: string;\n items: string[];\n}\n\n/** One filter's new values. An empty `items` means the filter was removed. */\nexport interface FilterSearchChange {\n filter: string;\n items: string[];\n}\n\nexport interface FilterSearchUpdate {\n next: FilterSearchSelection[];\n changes: FilterSearchChange[];\n}\n\nexport type FilterSearchMode = 'filters' | 'items' | 'search';\n\nexport type FilterSearchToggle = 'select' | 'deselect';\n\nexport interface FilterSearchItemRow {\n item: FilterSearchItem;\n filter: FilterSearchFilter;\n selected: boolean;\n}\n\nexport interface FilterSearchRows {\n /** The Select All / Deselect All row, absent when no enabled value matches. */\n toggle: FilterSearchToggle | null;\n items: FilterSearchItemRow[];\n}\n\nexport const resolveMode = (activeFilter: string | null, query: string): FilterSearchMode => {\n if (activeFilter !== null) return 'items';\n return query.trim().length > 0 ? 'search' : 'filters';\n};\n\nexport const matchesQuery = (item: FilterSearchItem, query: string): boolean => {\n const needle = query.trim().toLowerCase();\n return item.label.toLowerCase().includes(needle) || item.value.toLowerCase().includes(needle);\n};\n\nconst selectedValues = (selections: FilterSearchSelection[], filter: string): Set<string> =>\n new Set(selections.find((selection) => selection.filter === filter)?.items ?? []);\n\nconst toRows = (\n filters: FilterSearchFilter[],\n selections: FilterSearchSelection[],\n): FilterSearchItemRow[] =>\n filters.flatMap((filter) => {\n const selected = selectedValues(selections, filter.value);\n return filter.items.map((item) => ({ item, filter, selected: selected.has(item.value) }));\n });\n\n/**\n * \"Deselect All\" replaces \"Select All\" once every enabled value is chosen, or once every value\n * the query matches is.\n */\nconst toggleFor = (all: FilterSearchItemRow[], query: string): FilterSearchToggle | null => {\n const matched = all.filter((row) => matchesQuery(row.item, query));\n if (!matched.some((row) => !row.item.disabled)) return null;\n\n const everyEnabledSelected = all.every((row) => row.item.disabled || row.selected);\n const everyMatchSelected =\n query.trim().length > 0 &&\n matched.filter((row) => !row.item.disabled).every((row) => row.selected);\n\n return everyEnabledSelected || everyMatchSelected ? 'deselect' : 'select';\n};\n\nconst rowsFor = (all: FilterSearchItemRow[], query: string): FilterSearchRows => ({\n toggle: toggleFor(all, query),\n items: all.filter((row) => matchesQuery(row.item, query)),\n});\n\n/** The values of one filter, as the menu lists them once that filter is picked. */\n/**\n * The open filter as its menu lists it: `filters`' entry, with any picked value only\n * `searchFilters` holds added back, so a value picked through search can be unticked from its\n * own chip. A filter only `searchFilters` holds is listed from there.\n */\nexport const openFilterOf = (\n active: string | null,\n filters: FilterSearchFilter[],\n searchFilters: FilterSearchFilter[] | undefined,\n selections: FilterSearchSelection[],\n): FilterSearchFilter | undefined => {\n if (active === null) return undefined;\n const narrowed = filters.find((filter) => filter.value === active);\n const wide = searchFilters?.find((filter) => filter.value === active);\n if (!narrowed || !wide) return narrowed ?? wide;\n const picked = new Set(selections.find((selection) => selection.filter === active)?.items);\n const listed = new Set(narrowed.items.map((item) => item.value));\n const missing = wide.items.filter((item) => picked.has(item.value) && !listed.has(item.value));\n return missing.length ? { ...narrowed, items: [...narrowed.items, ...missing] } : narrowed;\n};\n\nexport const filterRows = (\n filter: FilterSearchFilter | undefined,\n selections: FilterSearchSelection[],\n query: string,\n): FilterSearchRows =>\n filter ? rowsFor(toRows([filter], selections), query) : { toggle: null, items: [] };\n\n/** The values of every filter that match a query typed before any filter was picked. */\nexport const searchRows = (\n filters: FilterSearchFilter[],\n selections: FilterSearchSelection[],\n query: string,\n): FilterSearchRows => rowsFor(toRows(filters, selections), query);\n\n// As sets: a Select All that adds nothing returns the values in item order, not the order chosen.\nconst sameItems = (a: string[], b: string[]) => {\n const set = new Set(b);\n return a.length === set.size && a.every((value) => set.has(value));\n};\n\n/** Applies per-filter changes, keeping each filter where it already was and dropping the emptied. */\nconst applyChanges = (\n selections: FilterSearchSelection[],\n proposed: FilterSearchChange[],\n): FilterSearchUpdate => {\n const changes = proposed.filter(\n (change) => !sameItems(change.items, [...selectedValues(selections, change.filter)]),\n );\n const byFilter = new Map(changes.map((change) => [change.filter, change.items]));\n const kept = selections\n .map((selection) => ({\n filter: selection.filter,\n items: byFilter.get(selection.filter) ?? selection.items,\n }))\n .filter((selection) => selection.items.length > 0);\n const added = changes.filter(\n (change) =>\n change.items.length > 0 &&\n !selections.some((selection) => selection.filter === change.filter),\n );\n\n return { next: [...kept, ...added], changes };\n};\n\nexport const toggleValue = (\n selections: FilterSearchSelection[],\n filter: string,\n value: string,\n): FilterSearchUpdate => {\n const current = [...selectedValues(selections, filter)];\n const items = current.includes(value)\n ? current.filter((item) => item !== value)\n : [...current, value];\n\n return applyChanges(selections, [{ filter, items }]);\n};\n\n/** Select All keeps what is already chosen and adds every enabled value the query matches. */\nexport const selectAll = (\n filters: FilterSearchFilter[],\n selections: FilterSearchSelection[],\n query: string,\n): FilterSearchUpdate =>\n applyChanges(\n selections,\n filters.map((filter) => {\n const selected = selectedValues(selections, filter.value);\n const added = filter.items\n .filter(\n (item) =>\n !selected.has(item.value) && !item.disabled && matchesQuery(item, query),\n )\n .map((item) => item.value);\n // Chosen values stay even when `items` no longer lists them (a stale or lazy list).\n return { filter: filter.value, items: [...selected, ...added] };\n }),\n );\n\n/** Deselect All drops every enabled value the query matches and keeps the rest. */\nexport const deselectAll = (\n filters: FilterSearchFilter[],\n selections: FilterSearchSelection[],\n query: string,\n): FilterSearchUpdate =>\n applyChanges(\n selections,\n filters.map((filter) => {\n const selected = selectedValues(selections, filter.value);\n const dropped = new Set(\n filter.items\n .filter((item) => !item.disabled && matchesQuery(item, query))\n .map((item) => item.value),\n );\n return {\n filter: filter.value,\n items: [...selected].filter((value) => !dropped.has(value)),\n };\n }),\n );\n\nexport const removeFilter = (\n selections: FilterSearchSelection[],\n filter: string,\n): FilterSearchUpdate => applyChanges(selections, [{ filter, items: [] }]);\n\nexport const clearAll = (selections: FilterSearchSelection[]): FilterSearchUpdate =>\n applyChanges(\n selections,\n selections.map((selection) => ({ filter: selection.filter, items: [] })),\n );\n\nexport const commitText = (\n selections: FilterSearchSelection[],\n filter: string,\n text: string,\n): FilterSearchUpdate => applyChanges(selections, [{ filter, items: [text] }]);\n\n/** `Connector: Notion`, or `Connector: (Notion, Attio)` once there is more than one value. */\nexport const chipText = (filterLabel: string, itemLabels: string[]): string => {\n if (itemLabels.length === 0) return filterLabel;\n if (itemLabels.length === 1) return `${filterLabel}: ${itemLabels[0]}`;\n return `${filterLabel}: (${itemLabels.join(', ')})`;\n};\n\n/**\n * The order chips show filters in: when each was first added. A consumer reading its selection back\n * from the URL gets it in a fixed key order, which would reshuffle the chips on every change.\n */\nexport const orderSelections = (\n selections: FilterSearchSelection[],\n order: string[],\n /** A filter to hold its place in `order` while it has no values, e.g. the one being edited. */\n keep: string | null = null,\n): string[] => {\n const present = new Set(selections.map((selection) => selection.filter));\n const kept = order.filter((filter) => present.has(filter) || filter === keep);\n return [\n ...kept,\n ...selections.map((selection) => selection.filter).filter((f) => !kept.includes(f)),\n ];\n};\n"],"names":["resolveMode","activeFilter","query","matchesQuery","item","needle","selectedValues","selections","filter","_a","selection","toRows","filters","selected","toggleFor","all","matched","row","everyEnabledSelected","everyMatchSelected","rowsFor","openFilterOf","active","searchFilters","narrowed","wide","picked","listed","missing","filterRows","searchRows","sameItems","a","b","set","value","applyChanges","proposed","changes","change","byFilter","kept","added","toggleValue","current","items","selectAll","deselectAll","dropped","removeFilter","clearAll","commitText","text","chipText","filterLabel","itemLabels","orderSelections","order","keep","present","f"],"mappings":"AAsDO,MAAMA,IAAc,CAACC,GAA6BC,MACjDD,MAAiB,OAAa,UAC3BC,EAAM,KAAA,EAAO,SAAS,IAAI,WAAW,WAGnCC,IAAe,CAACC,GAAwBF,MAA2B;AAC5E,QAAMG,IAASH,EAAM,KAAA,EAAO,YAAA;AAC5B,SAAOE,EAAK,MAAM,YAAA,EAAc,SAASC,CAAM,KAAKD,EAAK,MAAM,cAAc,SAASC,CAAM;AAChG,GAEMC,IAAiB,CAACC,GAAqCC,MAAA;AAVtD,MAAAC;AAWH,aAAI,MAAIA,IAAAF,EAAW,KAAK,CAACG,MAAcA,EAAU,WAAWF,CAAM,MAA1D,gBAAAC,EAA6D,UAAS,CAAA,CAAE;AAAA,GAE9EE,IAAS,CACXC,GACAL,MAEA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GK,CAAQ,EAAE,OAAO,CAACsB,MAAU,CAACa,EAAQ,IAAIb,CAAK,CAAC;AAAA,IAAA;AAAA,EAElE,CAAC;AACL,GAESc,IAAe,CACxB1C,GACAC,MACqB4B,EAAa7B,GAAY,CAAC,EAAE,QAAAC,GAAQ,OAAO,CAAA,GAAI,CAAC,GAE5D0C,IAAW,CAAC3C,MACrB6B;AAAA,EACI7B;AAAA,EACAA,EAAW,IAAI,CAACG,OAAe,EAAE,QAAQA,EAAU,QAAQ,OAAO,CAAA,IAAK;AAC3E,GAESyC,IAAa,CACtB5C,GACAC,GACA4C,MACqBhB,EAAa7B,GAAY,CAAC,EAAE,QAAAC,GAAQ,OAAO,CAAC4C,CAAI,EAAA,CAAG,CAAC,GAGhEC,IAAW,CAACC,GAAqBC,MACtCA,EAAW,WAAW,IAAUD,IAChCC,EAAW,WAAW,IAAU,GAAGD,CAAW,KAAKC,EAAW,CAAC,CAAC,KAC7D,GAAGD,CAAW,MAAMC,EAAW,KAAK,IAAI,CAAC,KAOvCC,IAAkB,CAC3BjD,GACAkD,GAEAC,IAAsB,SACX;AACX,QAAMC,IAAU,IAAI,IAAIpD,EAAW,IAAI,CAACG,MAAcA,EAAU,MAAM,CAAC,GACjE+B,IAAOgB,EAAM,OAAO,CAACjD,MAAWmD,EAAQ,IAAInD,CAAM,KAAKA,MAAWkD,CAAI;AAC5E,SAAO;AAAA,IACH,GAAGjB;AAAA,IACH,GAAGlC,EAAW,IAAI,CAACG,MAAcA,EAAU,MAAM,EAAE,OAAO,CAACkD,MAAM,CAACnB,EAAK,SAASmB,CAAC,CAAC;AAAA,EAAA;AAE1F;"}
|
|
1
|
+
{"version":3,"file":"filterSearchModel.js","sources":["../../src/components/filterSearchModel.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nexport interface FilterSearchItem {\n value: string;\n label: string;\n disabled?: boolean;\n /** Drawn before the label in the menu and in the applied chip: a logo, a status dot. Keep it 12px. */\n icon?: ReactNode;\n /** Drawn at the end of the value's row in the Filters panel: how many results it matches. */\n count?: number;\n}\n\nexport type FilterSearchControl = 'list' | 'toggle' | 'segmented';\n\nexport interface FilterSearchFilter {\n value: string;\n label: string;\n /** Shown beside the filter's name in the menu, and beside its values in a cross-filter search. */\n info?: string;\n /** Right-aligned hint on the filter's row, e.g. `e.g. Attio, Ashby`. */\n example?: string;\n /** `false` drops the filter's name from its chip, for a value that reads alone: `Configured only`. */\n chipLabel?: boolean;\n /** Filters panel control: `list` (default) ticks values, `toggle` switches its first item's value, `segmented` picks one or All. */\n control?: FilterSearchControl;\n items: FilterSearchItem[];\n}\n\nexport interface FilterSearchSelection {\n filter: string;\n items: string[];\n}\n\n/** One filter's new values. An empty `items` means the filter was removed. */\nexport interface FilterSearchChange {\n filter: string;\n items: string[];\n}\n\nexport interface FilterSearchUpdate {\n next: FilterSearchSelection[];\n changes: FilterSearchChange[];\n}\n\nexport type FilterSearchMode = 'filters' | 'items' | 'search';\n\nexport type FilterSearchToggle = 'select' | 'deselect';\n\nexport interface FilterSearchItemRow {\n item: FilterSearchItem;\n filter: FilterSearchFilter;\n selected: boolean;\n}\n\nexport interface FilterSearchRows {\n /** The Select All / Deselect All row, absent when no enabled value matches. */\n toggle: FilterSearchToggle | null;\n items: FilterSearchItemRow[];\n}\n\nexport const resolveMode = (activeFilter: string | null, query: string): FilterSearchMode => {\n if (activeFilter !== null) return 'items';\n return query.trim().length > 0 ? 'search' : 'filters';\n};\n\nexport const matchesQuery = (item: FilterSearchItem, query: string): boolean => {\n const needle = query.trim().toLowerCase();\n return item.label.toLowerCase().includes(needle) || item.value.toLowerCase().includes(needle);\n};\n\nconst selectedValues = (selections: FilterSearchSelection[], filter: string): Set<string> =>\n new Set(selections.find((selection) => selection.filter === filter)?.items ?? []);\n\nconst toRows = (\n filters: FilterSearchFilter[],\n selections: FilterSearchSelection[],\n): FilterSearchItemRow[] =>\n filters.flatMap((filter) => {\n const selected = selectedValues(selections, filter.value);\n return filter.items.map((item) => ({ item, filter, selected: selected.has(item.value) }));\n });\n\n/**\n * \"Deselect All\" replaces \"Select All\" once every enabled value is chosen, or once every value\n * the query matches is.\n */\nconst toggleFor = (all: FilterSearchItemRow[], query: string): FilterSearchToggle | null => {\n const matched = all.filter((row) => matchesQuery(row.item, query));\n if (!matched.some((row) => !row.item.disabled)) return null;\n\n const everyEnabledSelected = all.every((row) => row.item.disabled || row.selected);\n const everyMatchSelected =\n query.trim().length > 0 &&\n matched.filter((row) => !row.item.disabled).every((row) => row.selected);\n\n return everyEnabledSelected || everyMatchSelected ? 'deselect' : 'select';\n};\n\nconst rowsFor = (all: FilterSearchItemRow[], query: string): FilterSearchRows => ({\n toggle: toggleFor(all, query),\n items: all.filter((row) => matchesQuery(row.item, query)),\n});\n\n/**\n * The open filter as its menu lists it: `filters`' entry, with any picked value only\n * `searchFilters` holds added back, so a value picked through search can be unticked from its\n * own chip. A filter only `searchFilters` holds is listed from there.\n */\nexport const openFilterOf = (\n active: string | null,\n filters: FilterSearchFilter[],\n searchFilters: FilterSearchFilter[] | undefined,\n selections: FilterSearchSelection[],\n): FilterSearchFilter | undefined => {\n if (active === null) return undefined;\n const narrowed = filters.find((filter) => filter.value === active);\n const wide = searchFilters?.find((filter) => filter.value === active);\n if (!narrowed || !wide) return narrowed ?? wide;\n const picked = new Set(selections.find((selection) => selection.filter === active)?.items);\n const listed = new Set(narrowed.items.map((item) => item.value));\n const missing = wide.items.filter((item) => picked.has(item.value) && !listed.has(item.value));\n return missing.length ? { ...narrowed, items: [...narrowed.items, ...missing] } : narrowed;\n};\n\nexport const filterRows = (\n filter: FilterSearchFilter | undefined,\n selections: FilterSearchSelection[],\n query: string,\n): FilterSearchRows =>\n filter ? rowsFor(toRows([filter], selections), query) : { toggle: null, items: [] };\n\n/** The values of every filter that match a query typed before any filter was picked. */\nexport const searchRows = (\n filters: FilterSearchFilter[],\n selections: FilterSearchSelection[],\n query: string,\n): FilterSearchRows => rowsFor(toRows(filters, selections), query);\n\n// As sets: a Select All that adds nothing returns the values in item order, not the order chosen.\nconst sameItems = (a: string[], b: string[]) => {\n const set = new Set(b);\n return a.length === set.size && a.every((value) => set.has(value));\n};\n\n/** Applies per-filter changes, keeping each filter where it already was and dropping the emptied. */\nconst applyChanges = (\n selections: FilterSearchSelection[],\n proposed: FilterSearchChange[],\n): FilterSearchUpdate => {\n const changes = proposed.filter(\n (change) => !sameItems(change.items, [...selectedValues(selections, change.filter)]),\n );\n const byFilter = new Map(changes.map((change) => [change.filter, change.items]));\n const kept = selections\n .map((selection) => ({\n filter: selection.filter,\n items: byFilter.get(selection.filter) ?? selection.items,\n }))\n .filter((selection) => selection.items.length > 0);\n const added = changes.filter(\n (change) =>\n change.items.length > 0 &&\n !selections.some((selection) => selection.filter === change.filter),\n );\n\n return { next: [...kept, ...added], changes };\n};\n\nexport const toggleValue = (\n selections: FilterSearchSelection[],\n filter: string,\n value: string,\n): FilterSearchUpdate => {\n const current = [...selectedValues(selections, filter)];\n const items = current.includes(value)\n ? current.filter((item) => item !== value)\n : [...current, value];\n\n return applyChanges(selections, [{ filter, items }]);\n};\n\n/** Select All keeps what is already chosen and adds every enabled value the query matches. */\nexport const selectAll = (\n filters: FilterSearchFilter[],\n selections: FilterSearchSelection[],\n query: string,\n): FilterSearchUpdate =>\n applyChanges(\n selections,\n filters.map((filter) => {\n const selected = selectedValues(selections, filter.value);\n const added = filter.items\n .filter(\n (item) =>\n !selected.has(item.value) && !item.disabled && matchesQuery(item, query),\n )\n .map((item) => item.value);\n // Chosen values stay even when `items` no longer lists them (a stale or lazy list).\n return { filter: filter.value, items: [...selected, ...added] };\n }),\n );\n\n/** Deselect All drops every enabled value the query matches and keeps the rest. */\nexport const deselectAll = (\n filters: FilterSearchFilter[],\n selections: FilterSearchSelection[],\n query: string,\n): FilterSearchUpdate =>\n applyChanges(\n selections,\n filters.map((filter) => {\n const selected = selectedValues(selections, filter.value);\n const dropped = new Set(\n filter.items\n .filter((item) => !item.disabled && matchesQuery(item, query))\n .map((item) => item.value),\n );\n return {\n filter: filter.value,\n items: [...selected].filter((value) => !dropped.has(value)),\n };\n }),\n );\n\nexport const removeFilter = (\n selections: FilterSearchSelection[],\n filter: string,\n): FilterSearchUpdate => applyChanges(selections, [{ filter, items: [] }]);\n\n/** Removes every filter but `keep`, e.g. the typed text's pill. */\nexport const clearAll = (\n selections: FilterSearchSelection[],\n keep: string | null = null,\n): FilterSearchUpdate =>\n applyChanges(\n selections,\n selections\n .filter((selection) => selection.filter !== keep)\n .map((selection) => ({ filter: selection.filter, items: [] })),\n );\n\nexport const setValues = (\n selections: FilterSearchSelection[],\n filter: string,\n items: string[],\n): FilterSearchUpdate => applyChanges(selections, [{ filter, items }]);\n\nexport const commitText = (\n selections: FilterSearchSelection[],\n filter: string,\n text: string,\n): FilterSearchUpdate => applyChanges(selections, [{ filter, items: [text] }]);\n\n/** `Connector: Notion`, or `Connector: (Notion, Attio)` once there is more than one value. */\nexport const chipText = (filterLabel: string, itemLabels: string[]): string => {\n if (itemLabels.length === 0) return filterLabel;\n if (itemLabels.length === 1) return `${filterLabel}: ${itemLabels[0]}`;\n return `${filterLabel}: (${itemLabels.join(', ')})`;\n};\n\n/**\n * The order chips show filters in: when each was first added. A consumer reading its selection back\n * from the URL gets it in a fixed key order, which would reshuffle the chips on every change.\n */\nexport const orderSelections = (\n selections: FilterSearchSelection[],\n order: string[],\n /** A filter to hold its place in `order` while it has no values, e.g. the one being edited. */\n keep: string | null = null,\n): string[] => {\n const present = new Set(selections.map((selection) => selection.filter));\n const kept = order.filter((filter) => present.has(filter) || filter === keep);\n return [\n ...kept,\n ...selections.map((selection) => selection.filter).filter((f) => !kept.includes(f)),\n ];\n};\n"],"names":["resolveMode","activeFilter","query","matchesQuery","item","needle","selectedValues","selections","filter","_a","selection","toRows","filters","selected","toggleFor","all","matched","row","everyEnabledSelected","everyMatchSelected","rowsFor","openFilterOf","active","searchFilters","narrowed","wide","picked","listed","missing","filterRows","searchRows","sameItems","a","b","set","value","applyChanges","proposed","changes","change","byFilter","kept","added","toggleValue","current","items","selectAll","deselectAll","dropped","removeFilter","clearAll","keep","setValues","commitText","text","chipText","filterLabel","itemLabels","orderSelections","order","present","f"],"mappings":"AA4DO,MAAMA,IAAc,CAACC,GAA6BC,MACjDD,MAAiB,OAAa,UAC3BC,EAAM,KAAA,EAAO,SAAS,IAAI,WAAW,WAGnCC,IAAe,CAACC,GAAwBF,MAA2B;AAC5E,QAAMG,IAASH,EAAM,KAAA,EAAO,YAAA;AAC5B,SAAOE,EAAK,MAAM,YAAA,EAAc,SAASC,CAAM,KAAKD,EAAK,MAAM,cAAc,SAASC,CAAM;AAChG,GAEMC,IAAiB,CAACC,GAAqCC,MAAA;AAVtD,MAAAC;AAWH,aAAI,MAAIA,IAAAF,EAAW,KAAK,CAACG,MAAcA,EAAU,WAAWF,CAAM,MAA1D,gBAAAC,EAA6D,UAAS,CAAA,CAAE;AAAA,GAE9EE,IAAS,CACXC,GACAL,MAEAK,EAAQ,QAAQ,CAACJ,MAAW;AACxB,QAAMK,IAAWP,EAAeC,GAAYC,EAAO,KAAK;AACxD,SAAOA,EAAO,MAAM,IAAI,CAACJ,OAAU,EAAE,MAAAA,GAAM,QAAAI,GAAQ,UAAUK,EAAS,IAAIT,EAAK,KAAK,IAAI;AAC5F,CAAC,GAMCU,IAAY,CAACC,GAA4Bb,MAA6C;AACxF,QAAMc,IAAUD,EAAI,OAAO,CAACE,MAAQd,EAAac,EAAI,MAAMf,CAAK,CAAC;AACjE,MAAI,CAACc,EAAQ,KAAK,CAACC,MAAQ,CAACA,EAAI,KAAK,QAAQ,EAAG,QAAO;AAEvD,QAAMC,IAAuBH,EAAI,MAAM,CAACE,MAAQA,EAAI,KAAK,YAAYA,EAAI,QAAQ,GAC3EE,IACFjB,EAAM,KAAA,EAAO,SAAS,KACtBc,EAAQ,OAAO,CAACC,MAAQ,CAACA,EAAI,KAAK,QAAQ,EAAE,MAAM,CAACA,MAAQA,EAAI,QAAQ;AAE3E,SAAOC,KAAwBC,IAAqB,aAA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ACtCA,EAAW,WAAW,IAAUD,IAChCC,EAAW,WAAW,IAAU,GAAGD,CAAW,KAAKC,EAAW,CAAC,CAAC,KAC7D,GAAGD,CAAW,MAAMC,EAAW,KAAK,IAAI,CAAC,KAOvCC,IAAkB,CAC3BnD,GACAoD,GAEAR,IAAsB,SACX;AACX,QAAMS,IAAU,IAAI,IAAIrD,EAAW,IAAI,CAACG,MAAcA,EAAU,MAAM,CAAC,GACjE+B,IAAOkB,EAAM,OAAO,CAACnD,MAAWoD,EAAQ,IAAIpD,CAAM,KAAKA,MAAW2C,CAAI;AAC5E,SAAO;AAAA,IACH,GAAGV;AAAA,IACH,GAAGlC,EAAW,IAAI,CAACG,MAAcA,EAAU,MAAM,EAAE,OAAO,CAACmD,MAAM,CAACpB,EAAK,SAASoB,CAAC,CAAC;AAAA,EAAA;AAE1F;"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t = "outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-text-primary)]", s = "outline-none focus-visible:[outline:2px_solid_var(--malachite-text-primary)] focus-visible:[outline-offset:-2px]", i = "pointer-events-none absolute inset-0 hidden [outline:2px_solid_var(--malachite-text-primary)] [outline-offset:-2px]", n = `${i} z-[2] group-focus-visible:block`, l = "outline-none has-[[role=radio]:focus-visible]:outline-offset-2 has-[[role=radio]:focus-visible]:[outline:2px_solid_var(--malachite-text-primary)]", u = "outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-selection-bar-foreground)]", r = "outline-none focus-visible:[outline:2px_solid_var(--malachite-inline-confirm-foreground)] focus-visible:[outline-offset:-2px]", c = "outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-close-button-inverse-hover-foreground,rgb(255,255,255))]", _ = (o, e = !0) => {
|
|
2
|
+
try {
|
|
3
|
+
return o.matches(":focus-visible");
|
|
4
|
+
} catch {
|
|
5
|
+
return e;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
2
8
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
t as FOCUS_RING,
|
|
10
|
+
c as FOCUS_RING_CLOSE_BUTTON_INVERSE,
|
|
11
|
+
r as FOCUS_RING_INLINE_CONFIRM_INSET,
|
|
12
|
+
s as FOCUS_RING_INSET,
|
|
13
|
+
n as FOCUS_RING_INSET_OVERLAY,
|
|
14
|
+
i as FOCUS_RING_INSET_OVERLAY_HIDDEN,
|
|
15
|
+
u as FOCUS_RING_SELECTION_BAR,
|
|
16
|
+
l as FOCUS_RING_WITHIN_RADIO,
|
|
17
|
+
_ as isFocusVisible
|
|
11
18
|
};
|
|
12
19
|
//# sourceMappingURL=focusRing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusRing.js","sources":["../../src/components/focusRing.ts"],"sourcesContent":["// Shared keyboard focus indicator for interactive components.\n\n/** Standard focus ring — sits 2px outside the control. */\nexport const FOCUS_RING =\n 'outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-text-primary)]';\n\n/**\n * Inset focus ring — drawn 2px inside the element edge. Use for full-bleed elements\n * inside an `overflow-hidden` container (e.g. Surface.Row) where an outset outline\n * would be clipped.\n */\nexport const FOCUS_RING_INSET =\n 'outline-none focus-visible:[outline:2px_solid_var(--malachite-text-primary)] focus-visible:[outline-offset:-2px]';\n\nexport const FOCUS_RING_INSET_OVERLAY_HIDDEN =\n 'pointer-events-none absolute inset-0 hidden [outline:2px_solid_var(--malachite-text-primary)] [outline-offset:-2px]';\n\n/** `FOCUS_RING_INSET` drawn by an overlay while its `group` ancestor has keyboard focus. */\nexport const FOCUS_RING_INSET_OVERLAY = `${FOCUS_RING_INSET_OVERLAY_HIDDEN} z-[2] group-focus-visible:block`;\n\n/** Ring drawn on a wrapper when a control *inside* it takes focus. */\nexport const FOCUS_RING_WITHIN =\n 'outline-none has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:[outline:2px_solid_var(--malachite-text-primary)]';\n\n/**\n * As `FOCUS_RING_WITHIN`, for a card whose control is a `role=\"radio\"` beside its links:\n * `:has(:focus-visible)` would also match a focused link and draw a second ring.\n */\nexport const FOCUS_RING_WITHIN_RADIO =\n 'outline-none has-[[role=radio]:focus-visible]:outline-offset-2 has-[[role=radio]:focus-visible]:[outline:2px_solid_var(--malachite-text-primary)]';\n\n/** Ring for a control on the SelectionBar, where `FOCUS_RING` would be invisible. */\nexport const FOCUS_RING_SELECTION_BAR =\n 'outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-selection-bar-foreground)]';\n\n/** Inset ring for a control on the InlineConfirm chip. */\nexport const FOCUS_RING_INLINE_CONFIRM_INSET =\n 'outline-none focus-visible:[outline:2px_solid_var(--malachite-inline-confirm-foreground)] focus-visible:[outline-offset:-2px]';\n\n/** Ring for `CloseButton surface=\"inverse\"`, where `FOCUS_RING` would be invisible on the dark panel. */\nexport const FOCUS_RING_CLOSE_BUTTON_INVERSE =\n 'outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-close-button-inverse-hover-foreground,rgb(255,255,255))]';\n"],"names":["FOCUS_RING","FOCUS_RING_INSET","FOCUS_RING_INSET_OVERLAY_HIDDEN","FOCUS_RING_INSET_OVERLAY","FOCUS_RING_WITHIN_RADIO","FOCUS_RING_SELECTION_BAR","FOCUS_RING_INLINE_CONFIRM_INSET","FOCUS_RING_CLOSE_BUTTON_INVERSE"],"mappings":"AAGO,MAAMA,IACT,+GAOSC,IACT,oHAESC,IACT,uHAGSC,IAA2B,GAAGD,CAA+B,oCAU7DE,IACT,qJAGSC,IACT,2HAGSC,IACT,iIAGSC,IACT;"}
|
|
1
|
+
{"version":3,"file":"focusRing.js","sources":["../../src/components/focusRing.ts"],"sourcesContent":["// Shared keyboard focus indicator for interactive components.\n\n/** Standard focus ring — sits 2px outside the control. */\nexport const FOCUS_RING =\n 'outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-text-primary)]';\n\n/**\n * Inset focus ring — drawn 2px inside the element edge. Use for full-bleed elements\n * inside an `overflow-hidden` container (e.g. Surface.Row) where an outset outline\n * would be clipped.\n */\nexport const FOCUS_RING_INSET =\n 'outline-none focus-visible:[outline:2px_solid_var(--malachite-text-primary)] focus-visible:[outline-offset:-2px]';\n\nexport const FOCUS_RING_INSET_OVERLAY_HIDDEN =\n 'pointer-events-none absolute inset-0 hidden [outline:2px_solid_var(--malachite-text-primary)] [outline-offset:-2px]';\n\n/** `FOCUS_RING_INSET` drawn by an overlay while its `group` ancestor has keyboard focus. */\nexport const FOCUS_RING_INSET_OVERLAY = `${FOCUS_RING_INSET_OVERLAY_HIDDEN} z-[2] group-focus-visible:block`;\n\n/** Ring drawn on a wrapper when a control *inside* it takes focus. */\nexport const FOCUS_RING_WITHIN =\n 'outline-none has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:[outline:2px_solid_var(--malachite-text-primary)]';\n\n/**\n * As `FOCUS_RING_WITHIN`, for a card whose control is a `role=\"radio\"` beside its links:\n * `:has(:focus-visible)` would also match a focused link and draw a second ring.\n */\nexport const FOCUS_RING_WITHIN_RADIO =\n 'outline-none has-[[role=radio]:focus-visible]:outline-offset-2 has-[[role=radio]:focus-visible]:[outline:2px_solid_var(--malachite-text-primary)]';\n\n/** Ring for a control on the SelectionBar, where `FOCUS_RING` would be invisible. */\nexport const FOCUS_RING_SELECTION_BAR =\n 'outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-selection-bar-foreground)]';\n\n/** Inset ring for a control on the InlineConfirm chip. */\nexport const FOCUS_RING_INLINE_CONFIRM_INSET =\n 'outline-none focus-visible:[outline:2px_solid_var(--malachite-inline-confirm-foreground)] focus-visible:[outline-offset:-2px]';\n\n/** Ring for `CloseButton surface=\"inverse\"`, where `FOCUS_RING` would be invisible on the dark panel. */\nexport const FOCUS_RING_CLOSE_BUTTON_INVERSE =\n 'outline-none focus-visible:outline-offset-2 focus-visible:[outline:2px_solid_var(--malachite-close-button-inverse-hover-foreground,rgb(255,255,255))]';\n\n/** `fallback` is the answer where the browser can't match `:focus-visible`. */\nexport const isFocusVisible = (element: Element, fallback = true): boolean => {\n try {\n return element.matches(':focus-visible');\n } catch {\n return fallback;\n }\n};\n"],"names":["FOCUS_RING","FOCUS_RING_INSET","FOCUS_RING_INSET_OVERLAY_HIDDEN","FOCUS_RING_INSET_OVERLAY","FOCUS_RING_WITHIN_RADIO","FOCUS_RING_SELECTION_BAR","FOCUS_RING_INLINE_CONFIRM_INSET","FOCUS_RING_CLOSE_BUTTON_INVERSE","isFocusVisible","element","fallback"],"mappings":"AAGO,MAAMA,IACT,+GAOSC,IACT,oHAESC,IACT,uHAGSC,IAA2B,GAAGD,CAA+B,oCAU7DE,IACT,qJAGSC,IACT,2HAGSC,IACT,iIAGSC,IACT,yJAGSC,IAAiB,CAACC,GAAkBC,IAAW,OAAkB;AAC1E,MAAI;AACA,WAAOD,EAAQ,QAAQ,gBAAgB;AAAA,EAC3C,QAAQ;AACJ,WAAOC;AAAA,EACX;AACJ;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2034,6 +2034,8 @@ export declare interface FilterSearchChange {
|
|
|
2034
2034
|
items: string[];
|
|
2035
2035
|
}
|
|
2036
2036
|
|
|
2037
|
+
export declare type FilterSearchControl = 'list' | 'toggle' | 'segmented';
|
|
2038
|
+
|
|
2037
2039
|
export declare interface FilterSearchFilter {
|
|
2038
2040
|
value: string;
|
|
2039
2041
|
label: string;
|
|
@@ -2043,6 +2045,8 @@ export declare interface FilterSearchFilter {
|
|
|
2043
2045
|
example?: string;
|
|
2044
2046
|
/** `false` drops the filter's name from its chip, for a value that reads alone: `Configured only`. */
|
|
2045
2047
|
chipLabel?: boolean;
|
|
2048
|
+
/** Filters panel control: `list` (default) ticks values, `toggle` switches its first item's value, `segmented` picks one or All. */
|
|
2049
|
+
control?: FilterSearchControl;
|
|
2046
2050
|
items: FilterSearchItem[];
|
|
2047
2051
|
}
|
|
2048
2052
|
|
|
@@ -2052,6 +2056,8 @@ export declare interface FilterSearchItem {
|
|
|
2052
2056
|
disabled?: boolean;
|
|
2053
2057
|
/** Drawn before the label in the menu and in the applied chip: a logo, a status dot. Keep it 12px. */
|
|
2054
2058
|
icon?: ReactNode;
|
|
2059
|
+
/** Drawn at the end of the value's row in the Filters panel: how many results it matches. */
|
|
2060
|
+
count?: number;
|
|
2055
2061
|
}
|
|
2056
2062
|
|
|
2057
2063
|
export declare interface FilterSearchProps {
|
|
@@ -2068,9 +2074,9 @@ export declare interface FilterSearchProps {
|
|
|
2068
2074
|
onChange: (next: FilterSearchSelection[], changes: FilterSearchChange[]) => void;
|
|
2069
2075
|
/** Called when the clear control empties the bar, after `onChange`. */
|
|
2070
2076
|
onClear?: () => void;
|
|
2071
|
-
/** The filter whose values are open, or `null` on the filter list — for loading values lazily. */
|
|
2077
|
+
/** The filter whose values are open, or `null` on the filter list — for loading values lazily. Never called with `filtersButton`, whose panel draws every filter's `items` at once. */
|
|
2072
2078
|
onActiveFilterChange?: (filter: string | null) => void;
|
|
2073
|
-
/** The text in the field on every change: typed, put back by clicking the text pill, or reset to `''` when a value is picked or the menu closes. */
|
|
2079
|
+
/** The text in the field on every change: typed, put back by clicking the text pill, or reset to `''` when a value is picked or the menu closes (with `filtersButton`, only by Enter or Escape). */
|
|
2074
2080
|
onQueryChange?: (query: string) => void;
|
|
2075
2081
|
/** Lets typed text be committed as its own pill, under a `value` no filter uses. Its selection is `{ filter: textFilter.value, items: [text] }`. */
|
|
2076
2082
|
textFilter?: {
|
|
@@ -2086,8 +2092,8 @@ export declare interface FilterSearchProps {
|
|
|
2086
2092
|
/** Chips past this count collapse into `+N`. */
|
|
2087
2093
|
maxVisibleChips?: number;
|
|
2088
2094
|
/**
|
|
2089
|
-
* Puts a Filters button, with the applied filter count, at the bar's right end
|
|
2090
|
-
*
|
|
2095
|
+
* Puts a Filters button, with the applied filter count, at the bar's right end, and makes it the
|
|
2096
|
+
* only way to filters: the field becomes a plain search box whose Enter pins the text as a `textFilter` pill.
|
|
2091
2097
|
*/
|
|
2092
2098
|
filtersButton?: boolean;
|
|
2093
2099
|
className?: string;
|
|
@@ -3400,7 +3406,7 @@ export declare const LinkCard: default_2.FC<LinkCardProps>;
|
|
|
3400
3406
|
|
|
3401
3407
|
export declare interface LinkCardProps {
|
|
3402
3408
|
title: string;
|
|
3403
|
-
/** One line under the title;
|
|
3409
|
+
/** One line under the title; shown in full on hover, or when a clickable card takes keyboard focus. */
|
|
3404
3410
|
description?: string;
|
|
3405
3411
|
/** Colours the title. */
|
|
3406
3412
|
tone?: LinkCardTone;
|
|
@@ -4896,7 +4902,7 @@ export declare const SecurityIcon: React.FC<IconProps_99>;
|
|
|
4896
4902
|
* foreground-colour change as well as the thumb, so it does not rest on background
|
|
4897
4903
|
* colour alone.
|
|
4898
4904
|
*/
|
|
4899
|
-
export declare const SegmentedControl: <T extends string = string>({ options, value, onChange, size, fullWidth, disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className, }: SegmentedControlProps<T>) => JSX_2.Element;
|
|
4905
|
+
export declare const SegmentedControl: <T extends string = string>({ options, value, onChange, size, fullWidth, disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, className, }: SegmentedControlProps<T>) => JSX_2.Element;
|
|
4900
4906
|
|
|
4901
4907
|
export declare interface SegmentedControlOption<T extends string = string> {
|
|
4902
4908
|
value: T;
|
|
@@ -4922,6 +4928,7 @@ export declare interface SegmentedControlProps<T extends string = string> {
|
|
|
4922
4928
|
disabled?: boolean;
|
|
4923
4929
|
'aria-label'?: string;
|
|
4924
4930
|
'aria-labelledby'?: string;
|
|
4931
|
+
'aria-describedby'?: string;
|
|
4925
4932
|
className?: string;
|
|
4926
4933
|
}
|
|
4927
4934
|
|
|
@@ -6187,7 +6194,7 @@ export declare interface TimelineItemProps {
|
|
|
6187
6194
|
time?: default_2.ReactNode;
|
|
6188
6195
|
/**
|
|
6189
6196
|
* Paints the dot or the `icon`: `error` on a `stopped` step, else `neutral`, unless set. Colour
|
|
6190
|
-
* alone, so the title has to say what happened. Ignored when `marker` is set.
|
|
6197
|
+
* alone, so the title has to say what happened. Ignored when `skipped` or `marker` is set.
|
|
6191
6198
|
*/
|
|
6192
6199
|
tone?: TimelineTone;
|
|
6193
6200
|
/** Replaces the ringed dot with a 24px circle of its own, e.g. the caller's logo at size 24. Decorative: hidden from assistive tech. */
|
|
@@ -6200,12 +6207,14 @@ export declare interface TimelineItemProps {
|
|
|
6200
6207
|
* Precedence: `skipped`, then `marker`, then `icon`, then the dot.
|
|
6201
6208
|
*/
|
|
6202
6209
|
icon?: default_2.ReactNode;
|
|
6203
|
-
/** A step that never ran: a grey chevron replaces the dot, `tone`, `marker` and `icon`. */
|
|
6210
|
+
/** A step that never ran: a grey chevron replaces the dot, `tone`, `marker` and `icon`. Wins over `stopped`. */
|
|
6204
6211
|
skipped?: boolean;
|
|
6205
|
-
/** Marks the step the flow ended on, with a badge after the title. */
|
|
6212
|
+
/** Marks the step the flow ended on, with a badge after the title. Ignored when `skipped`. */
|
|
6206
6213
|
stopped?: boolean;
|
|
6207
6214
|
/** The badge's text when `stopped`. Empty falls back to "Stopped here". */
|
|
6208
6215
|
stoppedLabel?: string;
|
|
6216
|
+
/** Read to assistive tech after the title when `skipped`. Empty falls back to "skipped". */
|
|
6217
|
+
skippedLabel?: string;
|
|
6209
6218
|
/** Label and value pairs in a wrapping row under the title. */
|
|
6210
6219
|
meta?: readonly TimelineMetaEntry[];
|
|
6211
6220
|
/**
|