@bicharts/chart-host 0.5.60 → 0.5.61

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
@@ -705,6 +705,57 @@ function qualifyFilterGate(i) {
705
705
  if (!listNeedsFilter(i.scrollHeight, i.clientHeight)) return { show: false, why: "no-overflow" };
706
706
  return { show: true, why: "shown" };
707
707
  }
708
+ function computeQualifyFilterView(groups, term) {
709
+ const g = Array.isArray(groups) ? groups : [];
710
+ const read = (r) => ({ name: r.name, description: r.description });
711
+ const collect = (section) => {
712
+ const out = [];
713
+ for (const grp of g) if (grp.section === section) for (const r of grp.rows) out.push(r);
714
+ return out;
715
+ };
716
+ const fitRows = collect("fits");
717
+ const fit = filterQualifyRows(fitRows, term, read);
718
+ const ref = filterQualifyRows(collect("refused"), term, read);
719
+ const visible = /* @__PURE__ */ new Set();
720
+ for (const r of fit.rows) visible.add(r.el);
721
+ for (const r of ref.rows) visible.add(r.el);
722
+ const show = [], hide = [], showHeadings = [], hideHeadings = [];
723
+ for (const grp of g) {
724
+ let any = false;
725
+ for (const r of grp.rows) {
726
+ if (visible.has(r.el)) {
727
+ show.push(r.el);
728
+ any = true;
729
+ } else {
730
+ hide.push(r.el);
731
+ }
732
+ }
733
+ if (grp.heading !== null) (any ? showHeadings : hideHeadings).push(grp.heading);
734
+ }
735
+ const filtering = fit.tier !== "all";
736
+ const openRefusals = filtering && fit.rows.length === 0 && ref.rows.length > 0;
737
+ let note = "none";
738
+ if (filtering) {
739
+ if (fit.tier === "desc") note = "descFallback";
740
+ else if (fit.tier === "none") note = openRefusals ? "onlyRefusals" : "noMatch";
741
+ }
742
+ return {
743
+ show,
744
+ hide,
745
+ showHeadings,
746
+ hideHeadings,
747
+ tier: fit.tier,
748
+ matched: fit.rows.length,
749
+ total: fitRows.length,
750
+ refusalMatched: ref.rows.length,
751
+ openRefusals,
752
+ note,
753
+ term: fit.term
754
+ };
755
+ }
756
+ function qualifyFilterCountText(view) {
757
+ return view.tier === "all" ? String(view.total) : `${view.matched} of ${view.total}`;
758
+ }
708
759
  function inlineFilterGate(rowCount) {
709
760
  return rowCount >= INLINE_FILTER_MIN_ROWS ? { show: true, why: "shown" } : { show: false, why: "no-overflow" };
710
761
  }
@@ -985,6 +1036,7 @@ export {
985
1036
  clearGeoCache,
986
1037
  compileRenderFn,
987
1038
  compileTrivialSource,
1039
+ computeQualifyFilterView,
988
1040
  computeSelectionCard,
989
1041
  confirmLaunch,
990
1042
  createChartHost,
@@ -1014,6 +1066,7 @@ export {
1014
1066
  qualifyAuto,
1015
1067
  qualifyCancel,
1016
1068
  qualifyFailureFallsOpen,
1069
+ qualifyFilterCountText,
1017
1070
  qualifyFilterGate,
1018
1071
  qualifyGroupHeadingFor,
1019
1072
  qualifyPick,
@@ -13,7 +13,7 @@ export { shouldReview, buildReviewWire, bareBase64, actionFor, type ReviewGate,
13
13
  export { askApplyImprovements, type ReviewDialogOptions, type ReviewDialogText } from "./reviewDialog";
14
14
  export { qualifyGroupHeadingFor, newQualifyGroupState, type QualifyGroupRow, type QualifyGroupState, type QualifyGroupHeading, orderRefusalsForDisplay, refusalIsSelectable, hasRefusalsToShow, qualifyRefusalHeadingFor, newQualifyRefusalGroupState, type QualifyRefusalRow, type QualifyRefusalGroupState, type QualifyRefusalHeading, } from "./qualifyGroups";
15
15
  export { qualifyPick, qualifyAuto, qualifyCancel, launchGenerates, launchFavorStyle, chooserFitsViewport, shouldOpenChooserOnGenerate, shouldOpenInlineChooserOnGenerate, canConfirmLaunch, confirmLaunch, qualifyFailureFallsOpen, CHOOSER_MIN_WIDTH_PX, CHOOSER_MIN_HEIGHT_PX, type QualifyLaunchOutcome, type ChooserGateInput, } from "./qualifyLaunch";
16
- export { normalizeFilterTerm, filterQualifyRows, readQualifyChartRow, readQualifyRefusalRow, filterFitsChooser, listNeedsFilter, qualifyFilterGate, inlineFilterGate, FILTER_MIN_TERM_CHARS, FILTER_ROW_PX, FILTER_MIN_WIDTH_PX, FILTER_MIN_HEIGHT_PX, INLINE_FILTER_MIN_ROWS, type QualifyFilterTier, type QualifyFilterResult, type QualifyFilterRead, type QualifyFilterGateReason, type QualifyFilterGateInput, } from "./qualifyFilter";
16
+ export { normalizeFilterTerm, filterQualifyRows, readQualifyChartRow, readQualifyRefusalRow, filterFitsChooser, listNeedsFilter, qualifyFilterGate, inlineFilterGate, FILTER_MIN_TERM_CHARS, FILTER_ROW_PX, FILTER_MIN_WIDTH_PX, FILTER_MIN_HEIGHT_PX, INLINE_FILTER_MIN_ROWS, computeQualifyFilterView, qualifyFilterCountText, type QualifyFilterTier, type QualifyFilterResult, type QualifyFilterRead, type QualifyFilterGateReason, type QualifyFilterGateInput, type QualifyFilterRow, type QualifyFilterGroup, type QualifyFilterView, type QualifyFilterNoteKind, } from "./qualifyFilter";
17
17
  export { computeSelectionCard, normaliseAggregation, type SelectionCardModel, type SelectionCardLine, type SelectionCardOptions, } from "./selectionCard";
18
18
  export { ensureCrossfilterHitTargets, type HitTargetReport } from "./hitTargets";
19
19
  export { censusMarks, isBlankRender, blankRenderFlag, type MarkCensus, type BlankVerdictInput } from "./blankRender";
@@ -165,6 +165,83 @@ export declare function qualifyFilterGate(i: QualifyFilterGateInput): {
165
165
  show: boolean;
166
166
  why: QualifyFilterGateReason;
167
167
  };
168
+ /** One row, as the hosts record it while BUILDING the list - the element handle plus the text it
169
+ * is matched on, carried beside the element rather than scraped back out of it later. */
170
+ export interface QualifyFilterRow<E> {
171
+ el: E;
172
+ name: string;
173
+ description: string;
174
+ }
175
+ /** A heading and the rows it introduces, in render order. `section` separates the fitting list
176
+ * from the refusal block behind "Show all chart types" - two independently visible surfaces
177
+ * answering two different questions, and only one of them can be auto-opened. */
178
+ export interface QualifyFilterGroup<E> {
179
+ heading: E | null;
180
+ section: "fits" | "refused";
181
+ rows: QualifyFilterRow<E>[];
182
+ }
183
+ /** WHICH SENTENCE THE HOST HAS TO SHOW. The host owns the words (it localizes); this owns the
184
+ * decision, which is the half that can differ between two hosts without anyone noticing.
185
+ *
186
+ * "none" - a name tier answered, or nothing is being filtered. Say nothing: the reader's
187
+ * own word was found where they expected it and needs no explanation.
188
+ * "descFallback" - no name matched; these matched on description. MUST be said - a silent
189
+ * fall-through is indistinguishable from bad matching.
190
+ * "onlyRefusals" - nothing that FITS matches, but something in the refusal block does. Say where
191
+ * it went; that block is now open.
192
+ * "noMatch" - nothing anywhere. NEVER phrase this like "nothing fits your data": one is a
193
+ * statement about a typed string and is fixed with backspace, the other is a
194
+ * statement about the data and is not.
195
+ */
196
+ export type QualifyFilterNoteKind = "none" | "descFallback" | "onlyRefusals" | "noMatch";
197
+ export interface QualifyFilterView<E> {
198
+ /** Rows to show, and rows to hide. Two lists rather than one predicate so a host can write
199
+ * them in one pass without asking a Set per element. */
200
+ show: E[];
201
+ hide: E[];
202
+ /** Headings to show, and headings that now introduce nothing. A heading with nothing under it
203
+ * is a label for an empty category, and the rule it draws reads as a divider between two
204
+ * things that are not there. */
205
+ showHeadings: E[];
206
+ hideHeadings: E[];
207
+ tier: QualifyFilterTier;
208
+ /** Matches and totals for the FITTING list - what the "12 of 137" counter is made of. */
209
+ matched: number;
210
+ total: number;
211
+ refusalMatched: number;
212
+ /**
213
+ * Does the refusal block need to be OPEN for this term?
214
+ *
215
+ * True only when the term matches nothing that fits and something that does not. "Why isn't
216
+ * my chart here" is the only question that section is open to ask, and the reader has just
217
+ * asked it by name - the server's own sentence about why it cannot be drawn is already
218
+ * rendered, one collapsed checkbox away.
219
+ *
220
+ * THE HOST MUST TREAT THIS AS AN OVERRIDE, NOT A SETTING: remember what the reader's own
221
+ * checkbox said before the first override, and put it back the moment this goes false. An
222
+ * auto-expansion that sticks leaves the reader with a section they never opened.
223
+ */
224
+ openRefusals: boolean;
225
+ note: QualifyFilterNoteKind;
226
+ /** The normalized term, for the host to interpolate into whichever sentence it shows. */
227
+ term: string;
228
+ }
229
+ /**
230
+ * The filtered view of a whole dialog: fitting rows, refusal rows, headings and the note.
231
+ *
232
+ * ORDER IS UNTOUCHED, as everywhere else here - `show` and `hide` come out in the order the
233
+ * groups were built, so a host writing them in sequence cannot reorder anything by accident.
234
+ */
235
+ export declare function computeQualifyFilterView<E>(groups: readonly QualifyFilterGroup<E>[], term: string | null | undefined): QualifyFilterView<E>;
236
+ /** The counter beside the box: "12 of 137" while filtering, the plain total otherwise.
237
+ *
238
+ * Digits only, assembled here so both hosts show the same shape of number - the words around it
239
+ * (there are none today) would be the host's business, the arithmetic is not. */
240
+ export declare function qualifyFilterCountText(view: {
241
+ tier: QualifyFilterTier;
242
+ matched: number;
243
+ total: number;
244
+ }): string;
168
245
  /**
169
246
  * The same question for a host whose chooser is an INLINE, SCROLLING PANEL - and it has no size
170
247
  * clause, for the reason `shouldOpenInlineChooserOnGenerate` already sets out at length.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.5.60",
3
+ "version": "0.5.61",
4
4
  "description": "Run a BIC-generated D3 chart in any web host: compiles the generated render() function, applies the shared option defaults, resolves mark clicks (through tooltip overlays), owns the selection affordance, and translates row indices between cross-filtered charts. The same contract the BIC Power BI visual implements, minus Power BI. React bindings at @bicharts/chart-host/react.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",