coles-solid-library 0.4.4 → 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.
- package/USAGE.html +6 -5
- package/dist/components/Menu/menu.d.ts +1 -0
- package/dist/components/Menu/menuDropdown.d.ts +1 -0
- package/dist/components/Select/select.component.d.ts +8 -1
- package/dist/components/Select/selectContext.d.ts +8 -4
- package/dist/components/Select/useHighlight.d.ts +21 -0
- package/dist/components/Select/useSelectOptions.d.ts +19 -0
- package/dist/components/Select/useTypeahead.d.ts +20 -0
- package/dist/components/modal/popup.component.d.ts +1 -0
- package/dist/index.esm.js +755 -316
- package/package.json +1 -1
package/USAGE.html
CHANGED
|
@@ -175,7 +175,7 @@ addTheme('dark'); // or 'light'
|
|
|
175
175
|
disabled
|
|
176
176
|
onClick={(e) => {}}
|
|
177
177
|
>Click Me</Button></code></pre>
|
|
178
|
-
<p>Styling: theme tokens map to CSS variables like <code>--primary-color</code>. Prefer using <code>theme</code> rather than custom class names for consistent theming. Pass <code>class</code>/<code>style</code> for bespoke tweaks.</p>
|
|
178
|
+
<p>Styling: theme tokens map to CSS variables like <code>--primary-color</code>. Prefer using <code>theme</code> rather than custom class names for consistent theming. Pass <code>class</code>/<code>style</code> for bespoke tweaks. Disabled buttons now render with reduced opacity and a not-allowed cursor.</p>
|
|
179
179
|
|
|
180
180
|
<table class="api"><tr><th>Prop</th><th>Type</th><th>Description</th><th>Default</th></tr>
|
|
181
181
|
<tr><td>theme</td><td><code>ThemeVariables (excludes header/subheader)</code></td><td>Visual color role.</td><td><code>container</code></td></tr>
|
|
@@ -201,7 +201,7 @@ const [desc, setDesc] = createSignal("");
|
|
|
201
201
|
placeholder="Description"
|
|
202
202
|
/></code></pre>
|
|
203
203
|
<p><strong>Input:</strong> controlled via <code>value</code> (or form context) and <code>onChange</code>. <strong>TextArea:</strong> uses a signal pair <code>text</code>/<code>setText</code> instead of a <code>value</code> prop and auto-grows with content. Wrap in <code>FormField</code> for legend float + error sync.</p>
|
|
204
|
-
<p><small><strong>Notes:</strong> (1) <code>onChange</code> for <code>Input</code> is invoked after internal form sync (if inside a FormField) so reading form state inside the handler reflects the new value. (2) An <code>Input</code> with <code>type="checkbox"</code> is coerced to text internally for styling; prefer the dedicated <code>Checkbox</code> component for semantics. (3) Required indicator logic appends an asterisk to placeholders when the parent FormField marks the control as required.</small></p>
|
|
204
|
+
<p><small><strong>Notes:</strong> (1) <code>onChange</code> for <code>Input</code> is invoked after internal form sync (if inside a FormField) so reading form state inside the handler reflects the new value. (2) An <code>Input</code> with <code>type="checkbox"</code> is coerced to text internally for styling; prefer the dedicated <code>Checkbox</code> component for semantics. (3) Required indicator logic appends an asterisk to placeholders when the parent FormField marks the control as required. (4) When <code>disabled</code>, Input/TextArea suppress focus/blur handlers and input updates, and apply a disabled visual style.</small></p>
|
|
205
205
|
|
|
206
206
|
<table class="api"><tr><th>Component</th><th>Prop</th><th>Type</th><th>Description</th><th>Default</th></tr>
|
|
207
207
|
<tr><td>Input</td><td>value</td><td><code>string</code></td><td>Controlled value (overrides form context).</td><td>-</td></tr>
|
|
@@ -234,7 +234,7 @@ const [desc, setDesc] = createSignal("");
|
|
|
234
234
|
<Option value="a">Alpha</Option>
|
|
235
235
|
<Option value="b">Beta</Option>
|
|
236
236
|
</Select></code></pre>
|
|
237
|
-
<p><strong>Features:</strong> positioning logic clamps inside viewport; flips above if insufficient space. Multi-select toggles items; consumer tracks selected list via <code>onChange</code> or controlled value (depending on implementation).
|
|
237
|
+
<p><strong>Features:</strong> positioning logic clamps inside viewport; flips above if insufficient space. Multi-select toggles items; consumer tracks selected list via <code>onChange</code> or controlled value (depending on implementation). Keyboard navigation supports Arrow keys, Home/End, Enter, Escape, and type-to-search highlight. Disabled selects do not open or accept selection and expose <code>aria-disabled</code>.</p>
|
|
238
238
|
|
|
239
239
|
<table class="api"><tr><th>Component</th><th>Prop</th><th>Type</th><th>Description</th><th>Default</th></tr>
|
|
240
240
|
<tr><td>Select</td><td>multiple</td><td><code>boolean</code></td><td>Enable multi selection.</td><td>false</td></tr>
|
|
@@ -243,11 +243,12 @@ const [desc, setDesc] = createSignal("");
|
|
|
243
243
|
<tr><td>Select</td><td>onChange</td><td><code>(val) => void</code></td><td>Fires on selection state change (may fire on mount).</td><td>-</td></tr>
|
|
244
244
|
<tr><td>Select</td><td>onSelect</td><td><code>(val) => void</code></td><td>User interaction selection callback.</td><td>-</td></tr>
|
|
245
245
|
<tr><td>Select</td><td>placeholder</td><td><code>string</code></td><td>Trigger placeholder text.</td><td>"Select..."</td></tr>
|
|
246
|
-
<tr><td>Select</td><td>renderValue</td><td><code>(
|
|
246
|
+
<tr><td>Select</td><td>renderValue</td><td><code>(selectedValue) => JSX</code></td><td>Custom render of current value(s).</td><td>-</td></tr>
|
|
247
247
|
<tr><td>Select</td><td>dropdownClass</td><td><code>string</code></td><td>Class for dropdown portal element.</td><td>-</td></tr>
|
|
248
248
|
<tr><td>Select</td><td>transparent</td><td><code>boolean</code></td><td>Transparent trigger style.</td><td>false</td></tr>
|
|
249
249
|
<tr><td>Select</td><td>tooltip</td><td><code>string</code></td><td>Title attribute tooltip.</td><td>-</td></tr>
|
|
250
250
|
<tr><td>Select</td><td>id</td><td><code>string</code></td><td>DOM id (anchor / tests).</td><td>-</td></tr>
|
|
251
|
+
<tr><td>Select</td><td>disabled</td><td><code>boolean</code></td><td>Disable opening and selection; applies disabled styling.</td><td>false</td></tr>
|
|
251
252
|
<tr><td>Option</td><td>value</td><td><code>T</code></td><td>Option value token.</td><td>n/a</td></tr>
|
|
252
253
|
<tr><td>Option</td><td>children</td><td><code>JSX</code></td><td>Displayed label (fallback <code>String(value)</code>).</td><td>-</td></tr>
|
|
253
254
|
<tr><td>Option</td><td>class</td><td><code>string</code></td><td>Custom class.</td><td>-</td></tr>
|
|
@@ -558,7 +559,7 @@ const asyncOk = syncOk && await form.validateAsync();
|
|
|
558
559
|
if (asyncOk) doSubmit();</code></pre>
|
|
559
560
|
<h3 id="forms-patterns">Common Patterns</h3>
|
|
560
561
|
<ul>
|
|
561
|
-
<li>Blur-driven validation via <code>FormField</code>'s outside click detection.</li>
|
|
562
|
+
<li>Blur-driven validation via <code>FormField</code>'s outside click detection; it validates on blur when the field was focused or already dirty.</li>
|
|
562
563
|
<li>Programmatic: <code>form.validate('field')</code> returns boolean.</li>
|
|
563
564
|
<li>Dynamic rules: <code>form.addValidator('name', Validators.maxLength(20))</code>.</li>
|
|
564
565
|
<li>Reset: <code>form.reset()</code> clears errors + meta + restores initial values.</li>
|
|
@@ -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 {};
|
|
@@ -9,10 +9,17 @@ interface SelectProps<T = string, K = boolean> {
|
|
|
9
9
|
onSelect?: (value: T) => void;
|
|
10
10
|
placeholder?: string;
|
|
11
11
|
tooltip?: string;
|
|
12
|
-
renderValue?: (
|
|
12
|
+
renderValue?: (selectedValue: T) => JSX.Element;
|
|
13
13
|
class?: string;
|
|
14
14
|
dropdownClass?: string;
|
|
15
15
|
children: JSX.Element;
|
|
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';
|
|
16
23
|
}
|
|
17
24
|
export declare function Select<T, K extends boolean = false>(props: SelectProps<(K extends true ? T[] : T), K>): JSX.Element;
|
|
18
25
|
export {};
|
|
@@ -2,10 +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
|
|
6
|
-
unregisterOption
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
9
13
|
}
|
|
10
14
|
export declare const useSelectContext: () => SelectContextValue<any>;
|
|
11
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" {
|