@bicharts/chart-host 0.6.99 → 0.6.103

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.
@@ -0,0 +1,100 @@
1
+ /** The kind of value one exported column holds. Anything that is not a number, a date or a yes/no is text. */
2
+ export type ExportColumnType = "text" | "number" | "date" | "boolean";
3
+ /** One exported column, in the order the reader sees it. */
4
+ export interface ExportColumn {
5
+ /** The header, as the reader sees it. */
6
+ name: string;
7
+ type: ExportColumnType;
8
+ /** The d3-format specifier the chart prints this number with (a number column only). Wins over modelFormat. */
9
+ d3Format?: string | null;
10
+ /** The data model's own number format (an Excel / Power BI format string), used when there is no d3Format. */
11
+ modelFormat?: string | null;
12
+ }
13
+ /** One cell's value. A blank (null, undefined, "" or a value its column's type cannot read) is an empty cell. */
14
+ export type ExportCell = string | number | boolean | Date | null | undefined;
15
+ /** What a chart hands out: the visible columns in display order, and the rows in display order. */
16
+ export interface ExportTable {
17
+ /** Names the file and the worksheet. Absent: "table". */
18
+ title?: string | null;
19
+ columns: ExportColumn[];
20
+ rows: ExportCell[][];
21
+ }
22
+ export type ExportFormat = "csv" | "xlsx";
23
+ /** The formats a chart may offer, best first. */
24
+ export declare const EXPORT_FORMATS: readonly ExportFormat[];
25
+ /** A finished file, as a host's file service receives it. */
26
+ export interface ExportFile {
27
+ /** A file name with its extension, safe on every file system. */
28
+ name: string;
29
+ format: ExportFormat;
30
+ mime: string;
31
+ bytes: Uint8Array;
32
+ /** The same content as text, for a text format (the CSV); absent for a binary one. */
33
+ text?: string;
34
+ /**
35
+ * The table the file was written from, for a host that keeps it its own way (a spreadsheet add-in that must give
36
+ * the new sheet a name the open workbook does not already use, and so writes the workbook again under that name).
37
+ */
38
+ table: ExportTable;
39
+ }
40
+ export declare const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
41
+ export declare const CSV_MIME = "text/csv";
42
+ /**
43
+ * Excel's day number for a UTC time: days since 1899-12-30, the fraction being the time of day. Excel counts a
44
+ * 29 February 1900 that never was (day 60), so a day before 1 March 1900 is one lower to read back as itself.
45
+ */
46
+ export declare function excelSerial(t: number): number;
47
+ /**
48
+ * The Excel number format for an exported number column, or null for General. `values` are the column's numbers, so a
49
+ * format that shows "up to" some decimals shows as many as the data has.
50
+ */
51
+ export declare function excelNumberFormat(col: Pick<ExportColumn, "d3Format" | "modelFormat">, values?: readonly number[]): string | null;
52
+ /**
53
+ * The table as CSV text: a header row, then one line per row, CRLF between lines, RFC 4180 quoting. A number is its
54
+ * plain value (a point for the decimal, no grouping), a date its ISO day (and time, when the column has one), a yes/no
55
+ * TRUE or FALSE. The text starts with a byte-order mark so a spreadsheet reads it as UTF-8.
56
+ */
57
+ export declare function tableToCsv(table: ExportTable): string;
58
+ /** A1-style column letters for a 0-based column index. */
59
+ export declare function columnLetters(ci: number): string;
60
+ /** A worksheet name Excel accepts: at most 31 characters, none of []:*?/\, not blank, not starting or ending with '. */
61
+ export declare function sheetName(title: string | null | undefined): string;
62
+ /** A file name safe on every file system, from a title: no reserved characters, at most 80 characters. */
63
+ export declare function exportFileName(title: string | null | undefined, format: ExportFormat): string;
64
+ /**
65
+ * The table as an .xlsx workbook's bytes. One worksheet named after the title: a bold header row, frozen, with filter
66
+ * buttons; typed cells (numbers with their format where Excel can carry it, dates as dates, TRUE/FALSE); each column as
67
+ * wide as its widest value, within limits. Rows past Excel's limit are left out (a sheet holds 1,048,576 rows).
68
+ */
69
+ export declare function tableToXlsx(table: ExportTable): Uint8Array;
70
+ /**
71
+ * A ZIP archive of the given files, stored without compression (method 0) - every reader of a workbook accepts it. The
72
+ * entries carry a fixed timestamp, so the same table always gives the same bytes.
73
+ */
74
+ export declare function zipStored(files: Array<[string, string | Uint8Array]>): Uint8Array;
75
+ /** Builds the finished file for a table in one of the export formats. */
76
+ export declare function buildExportFile(table: ExportTable, format: ExportFormat): ExportFile;
77
+ /** Base64 of a file's bytes, for a host whose file service takes binary content as base64 text. */
78
+ export declare function bytesToBase64(bytes: Uint8Array): string;
79
+ /** A host's file service: saves a finished file the host's own way. False, a throw or a rejection means it did not. */
80
+ export type SaveFileService = (file: ExportFile) => boolean | void | Promise<boolean | void>;
81
+ /** The chart-facing export: what options.exportTable is. Resolves true when the host saved the file. */
82
+ export type ExportTableService = (table: ExportTable, format: ExportFormat) => Promise<boolean>;
83
+ /**
84
+ * The formats a host's file service takes, best first: the host's own list (when it names one) kept to the formats
85
+ * this module writes, in EXPORT_FORMATS order, without repeats. Absent or not a list: every format. An empty result
86
+ * means the host can save none of them, so it gets no export.
87
+ */
88
+ export declare function exportFormatsFor(hostFormats?: readonly unknown[] | null): ExportFormat[];
89
+ /**
90
+ * Builds the chart-facing exportTable from a host's file service. Never throws and never rejects: a table that cannot
91
+ * be written, a format the host does not take, or a host that refuses, resolves false, and the chart says the export
92
+ * did not happen.
93
+ */
94
+ export declare function exportTableService(save: SaveFileService, formats?: readonly ExportFormat[]): ExportTableService;
95
+ /**
96
+ * A file service for a page in a browser: the file downloads through a link the page never shows. For a React or
97
+ * Blazor page, a Fabric App, or any page whose browser allows downloads; a sandboxed frame without the
98
+ * "allow-downloads" permission silently drops it, so a host in one passes its own service (or none) instead.
99
+ */
100
+ export declare function browserSaveFile(doc?: Document): SaveFileService;
@@ -257,8 +257,9 @@ export interface ChartHostConfig {
257
257
  /**
258
258
  * NOTES ON MARKS. Each annotation names a key - a value in a column of this chart's data, such as a
259
259
  * country code - and the host draws a badge on that key's mark after every render, wherever a filter,
260
- * a re-query or a zoom has put it. Keyed by value, never by row position. Change them with
261
- * setAnnotations; none (the default) draws nothing.
260
+ * a re-query, a zoom or a scroll has put it. A chart that declares NOTE_STYLE_ATTR="dot" gets a small
261
+ * dot at a fixed spot instead, the label in its tooltip. Keyed by value, never by row position. Change
262
+ * them with setAnnotations; none (the default) draws nothing.
262
263
  */
263
264
  annotations?: MarkAnnotation[];
264
265
  /** A badge was clicked. The mark beneath is not selected. */
@@ -0,0 +1,11 @@
1
+ /** The clipboard half a host can supply: navigator.clipboard, or anything with the same writeText. */
2
+ export interface ClipboardLike {
3
+ writeText?: (text: string) => Promise<void>;
4
+ }
5
+ /** The two services, ready to spread into a host's render options: each is absent when the host supplied nothing for it. */
6
+ export interface HostLinkServices {
7
+ openUrl?: (url: string) => void;
8
+ copyText?: (text: string) => boolean | Promise<boolean>;
9
+ }
10
+ /** Builds openUrl and copyText from a host's own opener and clipboard. */
11
+ export declare function hostLinkServices(open: ((url: string) => void) | undefined | null, clipboard: ClipboardLike | undefined | null): HostLinkServices;
@@ -1,5 +1,7 @@
1
- export { HOST_CONTRACT_VERSION, GEO_POINT_PRECISIONS, MARK_CLASS, LEGEND_MARK_CLASS, AXIS_FILTER_CLASS, ROW_IDX_ATTR, LIFT_SELECTED_CLASS, CONTROL_CLASS, NO_ROW_MARKS_ATTR, SELECTION_RULE_ATTR, SELECTION_RULE_CLICKED_MARKS, MARK_KEY_ATTR, CONTAINER_SLOT_CLICKED_MARKS, SNAPSHOT_SVG_ATTR, XFILTER_REFRESH_EVENT, CONTAINER_SLOT_ANIM_STOP, CONTAINER_SLOT_XF_CLEAR, CONTAINER_SLOT_INITIAL_XF_MARK, CONTAINER_SLOT_UI_STATE, CONTAINER_SLOT_SCROLL, VIEW_ONLY_UI_STATE_KEYS, withoutViewOnlyKeys, HOST_CONTAINER_CLASS, SELECTION_ACTIVE_CLASS, MARK_SELECTED_CLASS, ACTIVE_TICK_CLASS, DIM_OPACITY_VAR, DIM_OPACITY_DEFAULT, DIM_OPACITY_MIN, chartOwnsTimeline, periodTickSuppressesFeedback, ANIM_PLAY_SPEED_DEFAULT, ANIM_PLAY_SPEED_MIN, ANIM_PLAY_SPEED_MAX, ANIM_LOOP_DELAY_DEFAULT, ANIM_LOOP_DELAY_MIN, ANIM_MAX_IDEAL_FRAMES_DEFAULT, ANIM_MAX_IDEAL_FRAMES_MIN, ANIM_MAX_IDEAL_FRAMES_MAX, ANIMATION_OPTION_KEYS, COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT, COLOR_SCALE_SELF_CLAMP_PCT_MIN, COLOR_SCALE_SELF_CLAMP_PCT_MAX, FLIP_MODE_DEFAULT, FLIP_INTERVAL_MIN_MS, FLIP_INTERVAL_MAX_MS, FLIP_DIRECTION_DEFAULT, APPROXIMATE_POSITIONS_DEFAULT, VALUE_AXIS_BASELINE_DEFAULT, SEASONAL_MARKERS_DEFAULT, MAX_MAP_POINTS_DEFAULT, type GeoPointPrecision, type GeoMapKind, type TimelineStyle, type FlipMode, type FlipDirection, type ApproximatePositions, type ValueAxisBaseline, type SeasonalMarkers, type ColorScaleScope, type RenderOptions, type ViewStateProvider, type ChartControlChange, type XfilterRefreshDetail, } from "./contract";
1
+ export { HOST_CONTRACT_VERSION, GEO_POINT_PRECISIONS, MARK_CLASS, LEGEND_MARK_CLASS, AXIS_FILTER_CLASS, ROW_IDX_ATTR, LIFT_SELECTED_CLASS, CONTROL_CLASS, NO_ROW_MARKS_ATTR, NOTE_STYLE_ATTR, SELECTION_RULE_ATTR, SELECTION_RULE_CLICKED_MARKS, MARK_KEY_ATTR, CONTAINER_SLOT_CLICKED_MARKS, SNAPSHOT_SVG_ATTR, XFILTER_REFRESH_EVENT, CONTAINER_SLOT_ANIM_STOP, CONTAINER_SLOT_XF_CLEAR, CONTAINER_SLOT_INITIAL_XF_MARK, CONTAINER_SLOT_UI_STATE, CONTAINER_SLOT_SCROLL, VIEW_ONLY_UI_STATE_KEYS, withoutViewOnlyKeys, HOST_CONTAINER_CLASS, SELECTION_ACTIVE_CLASS, MARK_SELECTED_CLASS, ACTIVE_TICK_CLASS, DIM_OPACITY_VAR, DIM_OPACITY_DEFAULT, DIM_OPACITY_MIN, chartOwnsTimeline, periodTickSuppressesFeedback, ANIM_PLAY_SPEED_DEFAULT, ANIM_PLAY_SPEED_MIN, ANIM_PLAY_SPEED_MAX, ANIM_LOOP_DELAY_DEFAULT, ANIM_LOOP_DELAY_MIN, ANIM_MAX_IDEAL_FRAMES_DEFAULT, ANIM_MAX_IDEAL_FRAMES_MIN, ANIM_MAX_IDEAL_FRAMES_MAX, ANIMATION_OPTION_KEYS, COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT, COLOR_SCALE_SELF_CLAMP_PCT_MIN, COLOR_SCALE_SELF_CLAMP_PCT_MAX, FLIP_MODE_DEFAULT, FLIP_INTERVAL_MIN_MS, FLIP_INTERVAL_MAX_MS, FLIP_DIRECTION_DEFAULT, APPROXIMATE_POSITIONS_DEFAULT, VALUE_AXIS_BASELINE_DEFAULT, SEASONAL_MARKERS_DEFAULT, MAX_MAP_POINTS_DEFAULT, type GeoPointPrecision, type GeoMapKind, type TimelineStyle, type FlipMode, type FlipDirection, type ApproximatePositions, type ValueAxisBaseline, type SeasonalMarkers, type ColorScaleScope, type RenderOptions, type ViewStateProvider, type ChartControlChange, type XfilterRefreshDetail, } from "./contract";
2
2
  export { resolveOptions, type ResolveOptionsInput } from "./defaults";
3
+ export { hostLinkServices, type HostLinkServices, type ClipboardLike } from "./hostLinks";
4
+ export { tableToCsv, tableToXlsx, buildExportFile, exportFileName, sheetName as exportSheetName, excelNumberFormat, excelSerial, bytesToBase64, exportFormatsFor, exportTableService, browserSaveFile, EXPORT_FORMATS, XLSX_MIME, CSV_MIME, type ExportTable, type ExportColumn, type ExportColumnType, type ExportCell, type ExportFormat, type ExportFile, type SaveFileService, type ExportTableService, } from "./exportTable";
3
5
  export { OPTIONS_VOCABULARY, LIVE_OPTION_KEYS, MAX_MAP_POINTS_MIN, MAX_MAP_POINTS_MAX, LIMIT_COUNT_MAX, wireLimitCount, codeReadsOption, type OptionVocabularyEntry, type OptionTiming, type OptionWire, type OptionKey, } from "./optionsVocabulary";
4
6
  export { loadGeo, geoFromCache, registerGeo, registerGeoAsset, geoAssetFor, clearGeoCache, type GeoAssetName, } from "./geoLazy";
5
7
  /** REPLACE the bundled city gazetteer with another packed table. Rarely needed — see the
@@ -21,6 +23,7 @@ export { captureSvgSnapshot, svgToDataUrl, svgNaturalSize, rasterizeSvgToPngData
21
23
  export { shouldReview, buildReviewWire, bareBase64, actionFor, type ReviewGate, type ReviewWire, type ReviewVerdict, type ReviewAction } from "./review";
22
24
  export { askApplyImprovements, type ReviewDialogOptions, type ReviewDialogText } from "./reviewDialog";
23
25
  export { mountProductFeedbackBox, normaliseProductFeedbackText, productFeedbackSendable, buildProductFeedbackPayload, PRODUCT_FEEDBACK_MAX_CHARS, PRODUCT_FEEDBACK_MIN_CHARS, type ProductFeedbackBox, type ProductFeedbackBoxOptions, type ProductFeedbackText, type ProductFeedbackSendResult, type ProductFeedbackPayload, type ProductFeedbackIdentity, type ProductFeedbackHost, } from "./productFeedback";
26
+ export { mountShareRateLine, shareRateLineModel, type ShareRateLine, type ShareRateLineOptions, type ShareRateText, type ShareRateModel, type ShareLink, type ShareAskWire, type ShareTargetWire, } from "./shareRate";
24
27
  export { qualifyGroupHeadingFor, newQualifyGroupState, type QualifyGroupRow, type QualifyGroupState, type QualifyGroupHeading, orderRefusalsForDisplay, refusalIsSelectable, hasRefusalsToShow, qualifyRefusalHeadingFor, newQualifyRefusalGroupState, qualifyRefusalReason, QUALIFY_REFUSAL_UNSPECIFIED, refusalIsTileBound, QUALIFY_TILE_REFUSAL_CODES, QUALIFY_TOO_SMALL_HEADING, type QualifyRefusalRow, type QualifyRefusalGroupState, type QualifyRefusalHeading, } from "./qualifyGroups";
25
28
  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";
26
29
  export { normalizeFilterTerm, filterQualifyRows, readQualifyChartRow, readQualifyRefusalRow, DEFAULT_FILTER_MATCH_STYLE, filterMatchStyleOf, type FilterMatchStyle, 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";
@@ -0,0 +1,90 @@
1
+ /** The block as the service sends it. Either casing is accepted, because the hosts' status calls serialise differently.
2
+ * shape-core types the same block on the status answer (GetLicenseStatusResult.shareAsk); it is restated here because
3
+ * this package's published declarations import nothing they do not ship, and a typecheck test holds the two equal. */
4
+ export interface ShareAskWire {
5
+ productUrl?: string;
6
+ ProductUrl?: string;
7
+ rateUrl?: string;
8
+ RateUrl?: string;
9
+ targets?: ShareTargetWire[];
10
+ Targets?: ShareTargetWire[];
11
+ }
12
+ export interface ShareTargetWire {
13
+ id?: string;
14
+ Id?: string;
15
+ label?: string;
16
+ Label?: string;
17
+ url?: string;
18
+ Url?: string;
19
+ }
20
+ export interface ShareLink {
21
+ /** Short network id ("li", "fb", "x"); a host's click counter names it. */
22
+ id: string;
23
+ label: string;
24
+ url: string;
25
+ }
26
+ export interface ShareRateModel {
27
+ share: ShareLink[];
28
+ /** The listing to rate; null when the block had none worth drawing. */
29
+ rateUrl: string | null;
30
+ }
31
+ /**
32
+ * The links to draw for a service block, or null to draw nothing. Absent block, nothing https, or nothing usable: null.
33
+ * A target whose URL is not https, whose id is malformed or repeated, or which has no label is dropped; the order the
34
+ * service sent is kept.
35
+ */
36
+ export declare function shareRateLineModel(ask: ShareAskWire | null | undefined): ShareRateModel | null;
37
+ /** The words a reader sees. Hosts localize; every field has an English default. Network names come from the service. */
38
+ export interface ShareRateText {
39
+ /** Before the network links: "Like it? Share it on". */
40
+ lead?: string;
41
+ /** Between the network links. */
42
+ separator?: string;
43
+ /** Between the share links and the rate link: ", or". */
44
+ or?: string;
45
+ /** The rate link after share links: "rate it on AppSource". */
46
+ rate?: string;
47
+ /** The rate link when there is nothing to share: "Like it? Rate it on AppSource". */
48
+ rateAlone?: string;
49
+ /** After the links: "Your ratings and feedback encourage us to do more." */
50
+ note?: string;
51
+ /** Menu layout, first: "Thanks for rating it." */
52
+ thanks?: string;
53
+ /** Menu layout, the rate link: "Rate it on AppSource too". */
54
+ rateToo?: string;
55
+ /** Menu layout, the toggle that reveals the networks: "Share it". */
56
+ shareMenu?: string;
57
+ }
58
+ export interface ShareRateLineOptions {
59
+ /** The service's block, as it arrived. Nothing is drawn when it yields no links. */
60
+ ask: ShareAskWire | null | undefined;
61
+ /** Opens a URL through the host's own door. The line never navigates by itself. */
62
+ open: (url: string) => void;
63
+ text?: ShareRateText;
64
+ /** Added to the wrapper so the host can skin it. */
65
+ className?: string;
66
+ /** "inline" (the landing line: the networks named in the sentence) or "menu" (after a vote: a short thank-you, the
67
+ * rate link, and a "Share it" toggle that reveals the networks). The links, their order and the click contract are
68
+ * the same either way. */
69
+ layout?: "inline" | "menu";
70
+ /** Menu layout: the "Share it" toggle opened the networks. */
71
+ onMenu?: () => void;
72
+ /** Called once, when the line is mounted - the host's "shown" counter. A host that folds the line away counts it
73
+ * itself instead and passes nothing here. */
74
+ onShown?: () => void;
75
+ /** A network link was clicked. */
76
+ onShare?: (id: string) => void;
77
+ /** The rate link was clicked. */
78
+ onRate?: () => void;
79
+ }
80
+ export interface ShareRateLine {
81
+ element: HTMLElement;
82
+ destroy(): void;
83
+ }
84
+ /**
85
+ * Draw the line inside `container`, or return null (and draw nothing) when the block yields no links. The wrapper carries
86
+ * `bic-share-rate`; network links `bic-share-rate-share` with `data-target`; the rate link `bic-share-rate-rate`; the
87
+ * note `bic-share-rate-note`. Every link carries its real href (so it reads as a link, and a reader can copy it), but a
88
+ * click is cancelled and handed to `open`.
89
+ */
90
+ export declare function mountShareRateLine(container: HTMLElement, opts: ShareRateLineOptions): ShareRateLine | null;
@@ -1,7 +1,7 @@
1
1
  /*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
2
  import {
3
3
  K
4
- } from "./chunk-W5L6OH25.mjs";
4
+ } from "./chunk-CNT3QA3R.mjs";
5
5
  import "./chunk-GHODWOAL.mjs";
6
6
 
7
7
  // src/zoomMemory/zoomMemory.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.6.99",
3
+ "version": "0.6.103",
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",