coles-solid-library 0.4.5 → 0.4.6

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.
@@ -6,6 +6,7 @@ interface MenuProps extends JSX.HTMLAttributes<HTMLDivElement> {
6
6
  show: [Accessor<boolean>, Setter<boolean>];
7
7
  areaExclusionRefs?: Accessor<HTMLElement | undefined>[];
8
8
  submenu?: boolean;
9
+ listClass?: string;
9
10
  }
10
11
  export declare const Menu: Component<MenuProps>;
11
12
  export {};
@@ -1,6 +1,7 @@
1
1
  import { Component, JSX } from "solid-js";
2
2
  interface MenuItemProps extends JSX.HTMLAttributes<HTMLLIElement> {
3
3
  children: JSX.Element;
4
+ dropListClass?: string;
4
5
  header?: () => JSX.Element;
5
6
  }
6
7
  export declare const MenuDropdown: Component<MenuItemProps>;
@@ -14,6 +14,12 @@ interface SelectProps<T = string, K = boolean> {
14
14
  dropdownClass?: string;
15
15
  children: JSX.Element;
16
16
  disabled?: boolean;
17
+ /** Controls mobile popup behavior.
18
+ * 'auto' (default): uses fullscreen popup on mobile devices, desktop dropdown otherwise.
19
+ * 'popup': always uses fullscreen popup regardless of device.
20
+ * 'desktop': always uses desktop dropdown regardless of device.
21
+ */
22
+ mobileMode?: 'auto' | 'popup' | 'desktop';
17
23
  }
18
24
  export declare function Select<T, K extends boolean = false>(props: SelectProps<(K extends true ? T[] : T), K>): JSX.Element;
19
25
  export {};
@@ -2,12 +2,14 @@ import { JSX } from "solid-js";
2
2
  export interface SelectContextValue<T> {
3
3
  isSelected: (val: T) => boolean;
4
4
  selectValue: (val: T) => void;
5
- registerOption?: (val: T, label: JSX.Element, labelText?: string) => void;
6
- unregisterOption?: (val: T) => void;
7
- isHighlighted?: (val: T) => boolean;
8
- selectRef?: (val: HTMLDivElement | undefined) => HTMLDivElement | undefined;
9
- selectStyle?: () => string;
10
- isDisabled?: () => boolean;
5
+ registerOption: (val: T, label: JSX.Element, labelText?: string) => void;
6
+ unregisterOption: (val: T) => void;
7
+ isHighlighted: (val: T) => boolean;
8
+ selectRef: (val: HTMLDivElement | undefined) => HTMLDivElement | undefined;
9
+ selectStyle: () => string;
10
+ isDisabled: () => boolean;
11
+ /** Close the dropdown/popup without changing the value */
12
+ closeDropdown: () => void;
11
13
  }
12
14
  export declare const useSelectContext: () => SelectContextValue<any>;
13
15
  export declare const SelectContextProvider: (props: {
@@ -0,0 +1,21 @@
1
+ import { Accessor } from "solid-js";
2
+ import { OptionEntry } from "./useSelectOptions";
3
+ export interface HighlightConfig<T> {
4
+ /** Accessor for the ordered option entries */
5
+ optionEntries: Accessor<OptionEntry<T>[]>;
6
+ /** Function to check if a value is currently selected */
7
+ isSelected: (val: T) => boolean;
8
+ /** Accessor for the dropdown DOM element (for scrollIntoView) */
9
+ dropdownRef: Accessor<HTMLElement | undefined>;
10
+ }
11
+ /**
12
+ * Manages highlighted-index state for keyboard navigation in a Select dropdown.
13
+ * Provides movement, scroll-into-view, and reset-to-selected helpers.
14
+ */
15
+ export declare function useHighlight<T>(config: HighlightConfig<T>): {
16
+ highlightedIndex: Accessor<number>;
17
+ setHighlightedIndex: import("solid-js").Setter<number>;
18
+ moveHighlight: (delta: number) => void;
19
+ setHighlightToSelectedOrFirst: () => void;
20
+ scrollHighlightedIntoView: (index?: number) => void;
21
+ };
@@ -0,0 +1,19 @@
1
+ import { JSX } from "solid-js";
2
+ export type OptionEntry<T> = {
3
+ value: string;
4
+ raw: T;
5
+ label: JSX.Element;
6
+ labelText: string;
7
+ };
8
+ /**
9
+ * Manages the registry of options for a Select component.
10
+ * Handles registration, unregistration, ordering, and label resolution.
11
+ */
12
+ export declare function useSelectOptions<T>(): {
13
+ options: Record<string, OptionEntry<T>>;
14
+ registerOption: (val: T, label: JSX.Element, labelText?: string) => void;
15
+ unregisterOption: (val: T) => void;
16
+ optionEntries: import("solid-js").Accessor<OptionEntry<T>[]>;
17
+ getOptionLabelText: (entry: OptionEntry<T>) => string;
18
+ getLabel: (val: T) => JSX.Element;
19
+ };
@@ -0,0 +1,20 @@
1
+ import { Accessor } from "solid-js";
2
+ import { OptionEntry } from "./useSelectOptions";
3
+ export interface TypeaheadConfig<T> {
4
+ /** Accessor for the ordered option entries */
5
+ optionEntries: Accessor<OptionEntry<T>[]>;
6
+ /** Accessor for the current highlighted index */
7
+ highlightedIndex: Accessor<number>;
8
+ /** Function to get a label string from an option entry */
9
+ getOptionLabelText: (entry: OptionEntry<T>) => string;
10
+ /** Called when a match is found — receives the matching index */
11
+ onMatch: (index: number) => void;
12
+ }
13
+ /**
14
+ * Typeahead search for Select. Buffers keystrokes and finds
15
+ * the first option whose label starts with the typed string.
16
+ */
17
+ export declare function useTypeahead<T>(config: TypeaheadConfig<T>): {
18
+ handleTypeahead: (key: string) => void;
19
+ resetTypeahead: () => void;
20
+ };
@@ -12,6 +12,7 @@ type Props = {
12
12
  styleType?: "primary" | "accent" | "tertiary";
13
13
  onClick?: (e: MouseEvent) => void;
14
14
  ref?: JSX.HTMLAttributes<HTMLDivElement>["ref"];
15
+ noHeader?: boolean;
15
16
  };
16
17
  export declare const Modal: Component<Props>;
17
18
  declare module "solid-js" {