pict-section-picker 1.0.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.
@@ -0,0 +1,3 @@
1
+ export = PictProviderPicker;
2
+ import PictProviderPicker = require("./providers/Pict-Provider-Picker.js");
3
+ //# sourceMappingURL=Pict-Section-Picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pict-Section-Picker.d.ts","sourceRoot":"","sources":["../source/Pict-Section-Picker.js"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ export = PictProviderPicker;
2
+ /**
3
+ * The pict-section-picker provider — the primary API surface. Registers the widget CSS once and
4
+ * creates/manages picker view instances.
5
+ */
6
+ declare class PictProviderPicker extends libPictProvider {
7
+ constructor(pFable: any, pOptions: any, pServiceHash: any);
8
+ /**
9
+ * Create (or reconfigure + reuse) a picker widget instance.
10
+ *
11
+ * @param {string} pPickerHash - A unique hash/id for this picker; the widget renders its control
12
+ * into the DOM element `#<pPickerHash>` unless a DestinationAddress is given.
13
+ * @param {Record<string, any>} pConfig - Picker configuration:
14
+ * - DestinationAddress {string} - CSS selector to render into (default `#<pPickerHash>`).
15
+ * - ValueAddress {string} - AppData address the selection is read from / written to.
16
+ * - Mode {'single'} - selection mode (multi/categories/creatable land in later phases).
17
+ * - Placeholder {string} - text shown when nothing is selected.
18
+ * - Searchable {boolean} - show the search box (default true).
19
+ * - Options {Array<{Value:any, Text:string}>} - static option list.
20
+ * - OnChange {function} - optional callback invoked with the new value after a selection.
21
+ * @return {any} The picker view instance.
22
+ */
23
+ createPicker(pPickerHash: string, pConfig: Record<string, any>): any;
24
+ /**
25
+ * Build the Meadow FoxHound filter for a search term across one or more fields.
26
+ *
27
+ * Single field → a clean AND-connected `FBV~Field~LK~%term%`. Multiple fields → the LIKEs are
28
+ * OR'd together inside a paren group (`FOP…FCP`) so the OR can't bleed into a sibling AND base
29
+ * filter. The term is `encodeURIComponent`-wrapped exactly as pict-section-recordset does, so the
30
+ * structural `~` separators stay literal in the URL path while the value is escaped.
31
+ *
32
+ * @param {Array<string>} pSearchFields - The entity fields to LIKE-match.
33
+ * @param {string} pTerm - The (raw) search term.
34
+ * @return {string} The FoxHound filter stanza(s).
35
+ */
36
+ buildSearchFilter(pSearchFields: Array<string>, pTerm: string): string;
37
+ /**
38
+ * Build an async picker DataProvider backed by a Meadow entity (via `pict.EntityProvider`).
39
+ * Returns a `(searchTerm, page) => Promise<{ results:[{Value,Text,Record}], hasMore }>` function —
40
+ * the exact contract PictViewPicker consumes for server search + pagination.
41
+ *
42
+ * @param {Record<string, any>} pConfig - Entity source configuration:
43
+ * - Entity {string} (required) - the Meadow entity name (e.g. `Author`).
44
+ * - SearchFields {Array<string>} - fields to LIKE-search (default `['Name']`).
45
+ * - ValueField {string} - record field used as the option Value (default `ID<Entity>`).
46
+ * - TextField {string} - record field used as the option Text (default `Name`).
47
+ * - PageSize {number} - records per page (default 20).
48
+ * - Sort {string} - optional field to sort ascending (adds `FSF~<field>~ASC~0`).
49
+ * - BaseFilter {string} - optional always-applied FoxHound filter (AND), e.g. `FBV~IDCustomer~EQ~1`.
50
+ * - MapRecord {function} - optional `(record) => {Value, Text}` mapper (overrides Value/TextField).
51
+ * @return {(pSearchTerm: string, pPage: number) => Promise<{results: Array<any>, hasMore: boolean}>}
52
+ */
53
+ createEntityDataProvider(pConfig: Record<string, any>): (pSearchTerm: string, pPage: number) => Promise<{
54
+ results: Array<any>;
55
+ hasMore: boolean;
56
+ }>;
57
+ /**
58
+ * Build a `ResolveValue(value) => Promise<{Value,Text}>` for an entity-backed picker, so a
59
+ * pre-bound ID resolves to its display text on first render (fetched + cached by `getEntity`).
60
+ *
61
+ * @param {Record<string, any>} pConfig - Same shape as {@link createEntityDataProvider}.
62
+ * @return {(pValue: any) => Promise<any>}
63
+ */
64
+ createEntityResolveValue(pConfig: Record<string, any>): (pValue: any) => Promise<any>;
65
+ /**
66
+ * Create a picker backed by a Meadow entity — the high-level entry point for the real
67
+ * lims/config/bridge entity pickers. Wires a server DataProvider + ResolveValue from `pConfig`
68
+ * and delegates to {@link createPicker}. Any picker option (DestinationAddress, ValueAddress,
69
+ * Placeholder, OnChange, …) may also be supplied and is passed through.
70
+ *
71
+ * @param {string} pPickerHash - Unique hash/id for this picker.
72
+ * @param {Record<string, any>} pConfig - {@link createEntityDataProvider} config + picker options.
73
+ * @return {any} The picker view instance.
74
+ */
75
+ createEntityPicker(pPickerHash: string, pConfig: Record<string, any>): any;
76
+ }
77
+ declare namespace PictProviderPicker {
78
+ export { _DEFAULT_CONFIGURATION as default_configuration };
79
+ }
80
+ import libPictProvider = require("pict-provider");
81
+ /** @type {Record<string, any>} */
82
+ declare const _DEFAULT_CONFIGURATION: Record<string, any>;
83
+ //# sourceMappingURL=Pict-Provider-Picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pict-Provider-Picker.d.ts","sourceRoot":"","sources":["../../source/providers/Pict-Provider-Picker.js"],"names":[],"mappings":";AAyEA;;;GAGG;AACH;IAEC,2DASC;IAED;;;;;;;;;;;;;;OAcG;IACH,0BAZW,MAAM,WAEN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAQlB,GAAG,CAqBd;IAED;;;;;;;;;;;OAWG;IACH,iCAJW,KAAK,CAAC,MAAM,CAAC,SACb,MAAM,GACL,MAAM,CAWjB;IAED;;;;;;;;;;;;;;;OAeG;IACH,kCAXW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GASlB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAC,CAuCnG;IAED;;;;;;OAMG;IACH,kCAHW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAClB,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAsBxC;IAED;;;;;;;;;OASG;IACH,gCAJW,MAAM,WACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAClB,GAAG,CAQd;CACD;;;;;AA1LD,kCAAkC;AAClC,sCADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAO5B"}
@@ -0,0 +1,110 @@
1
+ export = PictViewPicker;
2
+ declare class PictViewPicker extends libPictView {
3
+ constructor(pFable: any, pOptions: any, pServiceHash: any);
4
+ _StateAddress: string;
5
+ _open: boolean;
6
+ _search: string;
7
+ _highlight: number;
8
+ _loadedResults: any[];
9
+ _page: number;
10
+ _hasMore: boolean;
11
+ _loading: boolean;
12
+ _loaded: boolean;
13
+ _searchTimer: NodeJS.Timeout;
14
+ _selectedText: any;
15
+ _values: any[];
16
+ _selectedRecords: {};
17
+ /** @return {boolean} True when a DataProvider function is configured (async/server mode). */
18
+ _isAsync(): boolean;
19
+ /** @return {boolean} True when the picker is in multi-select (chips) mode. */
20
+ _isMulti(): boolean;
21
+ /** @return {Record<string, any>} The AppData state slot for this picker. */
22
+ _state(): Record<string, any>;
23
+ /** Resolve display text for any pre-bound value(s) via the async ResolveValue hook, then repaint. */
24
+ _resolveInitialValues(): void;
25
+ /**
26
+ * @return {any} The current selection: a scalar in single mode, or an array of values in multi mode
27
+ * (normalizing a csv string or scalar at the bound address into an array).
28
+ */
29
+ getValue(): any;
30
+ /**
31
+ * Persist the selection to the bound address(es). Single mode writes the scalar; multi mode writes
32
+ * the array to ValueAddress and mirrors it to the optional csv / records addresses.
33
+ * @param {any} pValue - The new value (scalar in single mode, array in multi mode).
34
+ */
35
+ _setValue(pValue: any): void;
36
+ _value: any;
37
+ /** @return {Array<{Value:any, Text:string}>} The current option source rows (async results or static Options). */
38
+ _sourceRows(): Array<{
39
+ Value: any;
40
+ Text: string;
41
+ }>;
42
+ /**
43
+ * (Re)compute the picker's render state into AppData: the displayed value / chips + the
44
+ * (search-filtered) option list with selected/highlight flags.
45
+ */
46
+ _buildState(): Record<string, any>;
47
+ /**
48
+ * Find the {Value,Text} record for a value: the stored selection record (authoritative for chips /
49
+ * async), else a row in the current source (static Options or loaded results).
50
+ * @param {any} pValue
51
+ * @return {{Value:any, Text:string}|null}
52
+ */
53
+ _lookupRecord(pValue: any): {
54
+ Value: any;
55
+ Text: string;
56
+ } | null;
57
+ /**
58
+ * Load a page of results from the async DataProvider, accumulating (append) or replacing the list.
59
+ * @param {number} pPage - zero-based page index.
60
+ * @param {boolean} pAppend - true to append (Load more), false to replace (new search / first open).
61
+ */
62
+ _loadPage(pPage: number, pAppend: boolean): void;
63
+ /** Toggle the dropdown open/closed. */
64
+ toggle(pEvent: any): void;
65
+ /** Keyboard on the control: open the dropdown on Enter / Space / ArrowDown. */
66
+ onControlKey(pEvent: any): void;
67
+ /** Open the dropdown and focus the search box. */
68
+ open(): void;
69
+ /** Async mode: load + append the next page of results. */
70
+ loadMore(): void;
71
+ /** Close the dropdown. */
72
+ close(): void;
73
+ /** Reflect the open/closed state on the widget container. */
74
+ _paintOpen(): void;
75
+ /** Re-render only the option list (keeps the search input + its focus intact). */
76
+ _renderList(): void;
77
+ /** Re-render only the control's value area (the value span or the chips) — used in multi mode so
78
+ * toggling a selection updates the chips without tearing down the open dropdown + search box. */
79
+ _renderValue(): void;
80
+ /** @param {string} pValue - Filter the option list by this search term. */
81
+ search(pValue: string): void;
82
+ /** Keyboard navigation within the search box: arrows highlight, Enter selects, Escape closes. */
83
+ onSearchKey(pEvent: any): void;
84
+ /**
85
+ * Select an option. Single mode: set the value + close. Multi mode: toggle the value in/out of the
86
+ * selection, keep the dropdown open, and refocus the search box for rapid multi-pick.
87
+ * @param {string} pValueKey - String(Value) of the option.
88
+ */
89
+ select(pValueKey: string): void;
90
+ /** @return {Array<{Value:any, Text:string}>} The full record list for the current multi selection. */
91
+ getSelectedRecords(): Array<{
92
+ Value: any;
93
+ Text: string;
94
+ }>;
95
+ /**
96
+ * Creatable: build a new option from the current search term via OnCreate, then select it (single:
97
+ * set + close; multi: add a chip). The created record is inserted into the source list so it shows
98
+ * as a normal, checked option.
99
+ */
100
+ createFromSearch(): void;
101
+ /** Multi mode: remove a selected value (chip ×). Keeps the dropdown state as-is. */
102
+ removeChip(pValueKey: any): void;
103
+ }
104
+ declare namespace PictViewPicker {
105
+ export { _DEFAULT_CONFIGURATION as default_configuration };
106
+ }
107
+ import libPictView = require("pict-view");
108
+ /** @type {Record<string, any>} */
109
+ declare const _DEFAULT_CONFIGURATION: Record<string, any>;
110
+ //# sourceMappingURL=PictView-Picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PictView-Picker.d.ts","sourceRoot":"","sources":["../../source/views/PictView-Picker.js"],"names":[],"mappings":";AA6KA;IAEC,2DA0CC;IAlCA,sBAA2E;IAQ3E,eAAkB;IAClB,gBAAiB;IACjB,mBAAoB;IAEpB,sBAAwB;IACxB,cAAc;IACd,kBAAqB;IACrB,kBAAqB;IACrB,iBAAoB;IACpB,6BAAwB;IACxB,mBAAyB;IAGzB,eAAiB;IACjB,qBAA0B;IAc3B,6FAA6F;IAC7F,YADa,OAAO,CAInB;IAED,8EAA8E;IAC9E,YADa,OAAO,CAInB;IAED,4EAA4E;IAC5E,UADa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAM/B;IAED,qGAAqG;IACrG,8BA+BC;IAED;;;OAGG;IACH,YAHY,GAAG,CAgBd;IAED;;;;OAIG;IACH,kBAFW,GAAG,QA6Bb;IAvBC,YAAoB;IAyBtB,kHAAkH;IAClH,eADa,KAAK,CAAC;QAAC,KAAK,EAAC,GAAG,CAAC;QAAC,IAAI,EAAC,MAAM,CAAA;KAAC,CAAC,CAK3C;IAED;;;OAGG;IACH,mCAgGC;IAED;;;;;OAKG;IACH,sBAHW,GAAG,GACF;QAAC,KAAK,EAAC,GAAG,CAAC;QAAC,IAAI,EAAC,MAAM,CAAA;KAAC,GAAC,IAAI,CAQxC;IAED;;;;OAIG;IACH,iBAHW,MAAM,WACN,OAAO,QA4BjB;IAWD,uCAAuC;IACvC,0BAIC;IAED,+EAA+E;IAC/E,gCAWC;IAED,kDAAkD;IAClD,aAQC;IAED,0DAA0D;IAC1D,iBAMC;IAED,0BAA0B;IAC1B,cAKC;IAED,6DAA6D;IAC7D,mBAIC;IAED,kFAAkF;IAClF,oBAKC;IAED;sGACkG;IAClG,qBAKC;IAED,2EAA2E;IAC3E,eADY,MAAM,QAejB;IAED,iGAAiG;IACjG,+BAgCC;IAED;;;;OAIG;IACH,kBAFW,MAAM,QA4ChB;IAED,sGAAsG;IACtG,sBADa,KAAK,CAAC;QAAC,KAAK,EAAC,GAAG,CAAC;QAAC,IAAI,EAAC,MAAM,CAAA;KAAC,CAAC,CAI3C;IAED;;;;OAIG;IACH,yBA6CC;IAED,oFAAoF;IACpF,iCAWC;CAWD;;;;;AAxuBD,kCAAkC;AAClC,sCADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAyK5B"}