All files / src/constants drawer.ts

100% Statements 30/30
100% Branches 0/0
100% Functions 0/0
100% Lines 30/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 691x             1x   1x             1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                 1x           1x 1x 1x 1x 1x 1x 1x 1x 1x                 1x         1x 1x 1x 1x 1x  
/**
 * @group Constants
 * @groupDescription The column-drawer vocabulary — the widget kinds a column can
 * render as in the drawer accordion, where each one reads and writes in app state,
 * and the adornment sentinel. Split out of `constants/common.ts` because these are
 * consumed together, by the drawer and by the column definitions that configure it.
 * @source
 */
 
/**
 * Widget kinds a column's `meta.drawer` config can request. The value discriminates
 * the {@link ColumnDrawerConfig} union, so each one implies the runtime type of that
 * branch's `options` (e.g. {@link DRAWER_WIDGET.AUTOCOMPLETE_OBJECTS} needs
 * `{ code, label }[]`).
 * @category Constants
 * @source
 */
export const DRAWER_WIDGET = {
  /** Multi-select autocomplete over a list of plain strings. */
  AUTOCOMPLETE_STRINGS: 'autocompleteStrings',
  /** Multi-select autocomplete over `{ code, label }` options, e.g. countries. */
  AUTOCOMPLETE_OBJECTS: 'autocompleteObjects',
  /** A row of toggleable chips, one per option. */
  CHIPS: 'chips',
  /** Paired min/max numeric inputs. */
  NUMBER_RANGE: 'numberRange',
} as const;
 
/**
 * A {@link DRAWER_WIDGET} value.
 * @category Constants
 * @source
 */
export type DrawerWidget = (typeof DRAWER_WIDGET)[keyof typeof DRAWER_WIDGET];
 
/**
 * Where a drawer section's value reads and writes in app state. Discriminates the
 * {@link ColumnDrawerBinding} union, so `ColumnDrawerSection` can dispatch on it
 * without columns knowing how the context is structured.
 * @category Constants
 * @source
 */
export const DRAWER_BINDING = {
  /** A keyed slice of `searchFilters` (availability, country, shippingType). */
  SEARCH_FILTERS: 'searchFilters',
  /** The selected-suppliers list on the app context. */
  SELECTED_SUPPLIERS: 'selectedSuppliers',
  /** A min/max pair of `userSettings` keys, e.g. `priceMin`/`priceMax`. */
  USER_SETTINGS_RANGE: 'userSettingsRange',
} as const;
 
/**
 * A {@link DRAWER_BINDING} value.
 * @category Constants
 * @source
 */
export type DrawerBindingKind = (typeof DRAWER_BINDING)[keyof typeof DRAWER_BINDING];
 
/**
 * Sentinel values for a `numberRange` widget's `adornment`. Anything else is used
 * verbatim as the start-adornment text.
 * @category Constants
 * @source
 */
export const DRAWER_ADORNMENT = {
  /** Resolve the symbol at render time from `userSettings.currency` (USD → "$"). */
  CURRENCY: 'currency',
} as const;