@gridkitjs/forms 0.0.0-dev-20261206115313 → 0.0.0-dev-20261206150419

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as core from '@gridkitjs/forms-core';
2
- import { NoDetails, Parser, Formatter, Validator, FieldMessageInput, FormsMessages, FieldState, FieldMessage, Severity, ChangeCause, ParseContext, ParseResult, FormatContext, InputFilter, PlainDate, Weekday, WeekNumbering, DateDetails, CalendarMonth, DateRange, RangeDetails, NoFlags, RelativeDateRule, RangeBounds, PopupOpenChange, Instant, PlainDateTime, DateTimeDetails, PlainTime, TimeZoneDisambiguation, TimeDetails, StepDirection, StepSize, NumberValueType, NumberValue, NumberDetails, RoundingMode, NegativeStyle, NumberOptions, DecimalString, DurationDetails, DurationUnit, DurationNotation, MaskDetails, MaskOptions, MaskSource, MaskPreset, MaskValueFormat, Range, PercentScale, PeriodGranularity, Period, PeriodDetails } from '@gridkitjs/forms-core';
3
- export { CalendarMonth, ChangeSource, CommitTrigger, DateDetails, DateRange, DateReadingInfo, DateSegmentType, DateTimeDetails, DecimalString, DurationDetails, DurationNotation, DurationUnit, FieldDraft, FieldMessage, FieldMessageInput, FieldPhase, FieldState, FiscalYear, FormatContext, Formatter, FormsMessages, Instant, MaskDetails, MaskOptions, MaskPreset, MaskPresets, MaskSource, MaskTokenDefinition, MaskTokens, MaskValueFormat, NegativeStyle, NoDetails, NoFlags, NumberDetails, NumberReadingInfo, NumberValue, NumberValueType, ParseContext, ParseResult, Parser, PercentScale, Period, PeriodDetails, PeriodGranularity, PlainDate, PlainDateTime, PlainTime, PopupCloseReason, PopupOpenChange, PopupOpenReason, Range, RangeBounds, RangeDetails, RangeEnd, RoundingMode, Severity, StepDirection, StepSize, TextInputDetails, TextParseOptions, TextReading, TimeDetails, TimeZoneDisambiguation, ValidationResult, Validator, ValidatorContext, WeekNumbering, Weekday, formatText, maskPresets, parsed, textParser, unreadable } from '@gridkitjs/forms-core';
2
+ import { NoDetails, Parser, Formatter, Validator, FieldMessageInput, FormsMessages, FieldState, FieldMessage, Severity, ChangeCause, ParseContext, ParseResult, FormatContext, InputFilter, PlainDate, Weekday, WeekNumbering, DateDetails, CalendarMonth, DateRange, RangeDetails, NoFlags, RelativeDateRule, RangeBounds, OptionMatch, ChoiceOption, OptionSource as OptionSource$1, OptionKey, OptionCache, MatchMode, OptionMatcher, DisabledOptions, PopupOpenChange, QueryChangeEvent, HighlightChangeEvent, LoadErrorEvent, CreateEvent, ChoiceDetails, SingleChoiceDetails, Instant, PlainDateTime, DateTimeDetails, PlainTime, TimeZoneDisambiguation, TimeDetails, StepDirection, StepSize, NumberValueType, NumberValue, NumberDetails, RoundingMode, NegativeStyle, NumberOptions, DecimalString, DurationDetails, DurationUnit, DurationNotation, MaskDetails, MaskOptions, MaskSource, MaskPreset, MaskValueFormat, Range, PercentScale, PeriodGranularity, Period, PeriodDetails } from '@gridkitjs/forms-core';
3
+ export { CalendarMonth, ChangeSource, ChoiceDetails, ChoiceOption, CommitTrigger, CreateEvent, DateDetails, DateRange, DateReadingInfo, DateSegmentType, DateTimeDetails, DecimalString, DisabledOptions, DurationDetails, DurationNotation, DurationUnit, FieldDraft, FieldMessage, FieldMessageInput, FieldPhase, FieldState, FiscalYear, FormatContext, Formatter, FormsMessages, HighlightChangeEvent, Instant, LoadErrorEvent, LoadedOptions, MaskDetails, MaskOptions, MaskPreset, MaskPresets, MaskSource, MaskTokenDefinition, MaskTokens, MaskValueFormat, MatchContext, MatchMode, NegativeStyle, NoDetails, NoFlags, NumberDetails, NumberReadingInfo, NumberValue, NumberValueType, OptionCache, OptionKey, OptionMatch, OptionMatcher, OptionPage, OptionQuery, OptionSearch, ParseContext, ParseResult, Parser, PercentScale, Period, PeriodDetails, PeriodGranularity, PlainDate, PlainDateTime, PlainTime, PopupCloseReason, PopupOpenChange, PopupOpenReason, QueryChangeEvent, Range, RangeBounds, RangeDetails, RangeEnd, RoundingMode, Severity, SingleChoiceDetails, StepDirection, StepSize, TextInputDetails, TextParseOptions, TextRange, TextReading, TimeDetails, TimeZoneDisambiguation, ValidationResult, Validator, ValidatorContext, WeekNumbering, Weekday, createOptionCache, formatText, keyText, maskPresets, parsed, textParser, unreadable } from '@gridkitjs/forms-core';
4
4
  import * as react from 'react';
5
5
  import { Ref, RefCallback, ReactElement, ReactNode, CSSProperties, HTMLAttributes, InputHTMLAttributes, SubmitEvent } from 'react';
6
6
  import { TextControl, TextInputOptions, ToggleOptions } from '@gridkitjs/forms-dom';
@@ -405,6 +405,143 @@ interface RangeCalendarProps extends CalendarBaseProps<DateRange, RangeCalendarD
405
405
  */
406
406
  declare function RangeCalendar({ min, max, isDateDisabled, timeZone, firstDayOfWeek, weekNumbers, weekNumbering, visibleMonths, bounds, required, validate, className, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }: RangeCalendarProps): react.JSX.Element;
407
407
 
408
+ /** A column of a multi-column option list. */
409
+ interface OptionColumn {
410
+ /** `"label"`, `"description"`, or a key of the options' `columns`. */
411
+ readonly id: string;
412
+ /** Drawn above the column; screen readers read each option's cells instead. */
413
+ readonly header: string;
414
+ /** A CSS grid track: `"6rem"`, `"2fr"`; `minmax(0, 1fr)` by default. */
415
+ readonly width?: string | undefined;
416
+ readonly align?: "start" | "end" | undefined;
417
+ }
418
+ /** What `renderOption` is told about the option it draws. */
419
+ interface OptionState {
420
+ /** The keys or the pointer are on it. */
421
+ readonly active: boolean;
422
+ /** It is in the value. */
423
+ readonly selected: boolean;
424
+ readonly disabled: boolean;
425
+ /** Where the search text matched it; `null` with no search text. */
426
+ readonly match: OptionMatch | null;
427
+ /** The search text; `""` without one. */
428
+ readonly query: string;
429
+ }
430
+
431
+ /**
432
+ * Where a choice input's options come from when they are not a local
433
+ * list: forms-core's `OptionSource` with the browser's `AbortSignal`, so
434
+ * `search` passes its `signal` straight to `fetch`.
435
+ */
436
+ type OptionSource<O extends ChoiceOption, F = undefined> = OptionSource$1<O, F, AbortSignal>;
437
+
438
+ /** What a choice input does from code, besides what every input does. */
439
+ interface ChoiceHandle<V> extends InputHandle<V> {
440
+ /** Opens the popup, focusing the control first. */
441
+ open(): void;
442
+ close(): void;
443
+ /** Forgets the source's cached pages and, if the list shows, asks again. */
444
+ reload(): void;
445
+ }
446
+ /** The props every `Select` takes, whatever its value. */
447
+ interface SelectCommonProps<K extends OptionKey, T, F = undefined> {
448
+ /**
449
+ * The options, in the order they are listed; `group` draws them under
450
+ * headers. With a `source`, options known without asking it.
451
+ */
452
+ readonly options?: readonly ChoiceOption<K, T>[] | undefined;
453
+ /** Where the options come from when they are not a local list: a server, usually. */
454
+ readonly source?: OptionSource<ChoiceOption<K, T>, F> | undefined;
455
+ /** The source's dependent filters (a city list's country), compared by value. */
456
+ readonly filters?: F | undefined;
457
+ /** The options of the value, when the list does not hold them: their labels show at once. */
458
+ readonly valueOptions?: readonly ChoiceOption<K, T>[] | undefined;
459
+ /** The source's pages and labels, shared by every input on it. One per input by default. */
460
+ readonly cache?: OptionCache<ChoiceOption<K, T>> | undefined;
461
+ /** How the search text matches: a mode, or a matcher of your own. Default `"contains"`. */
462
+ readonly match?: MatchMode | OptionMatcher<ChoiceOption<K, T>> | undefined;
463
+ /** What the search text is matched against: `"label"`, `"description"`, `"keywords"`, column ids. Default label and keywords. */
464
+ readonly matchFields?: readonly string[] | undefined;
465
+ /** Draws an option's content your way; the tick stays the select's. */
466
+ readonly renderOption?: ((option: ChoiceOption<K, T>, state: OptionState) => ReactNode) | undefined;
467
+ /** Draws only the options in view. Default: above 100 rows, and always with a source. */
468
+ readonly virtualize?: boolean | undefined;
469
+ /** Whether the keys reach disabled options, announced as unavailable. Default `"skip"`. */
470
+ readonly disabledOptions?: DisabledOptions | undefined;
471
+ /** A text box that filters the list. Default: a button-like control. */
472
+ readonly searchable?: boolean | undefined;
473
+ /** Shown while nothing is chosen. Never a label. */
474
+ readonly placeholder?: string | undefined;
475
+ /** Inside the box, at the inline start. Read with the control. */
476
+ readonly prefix?: ReactNode;
477
+ /** Inside the box, at the inline end. Read with the control. */
478
+ readonly suffix?: ReactNode;
479
+ /** A button in the box that empties the field, shown while something is chosen. */
480
+ readonly clearable?: boolean | undefined;
481
+ /** Lays each option out as a row of these columns, under a header row. */
482
+ readonly columns?: readonly OptionColumn[] | undefined;
483
+ /** A select-only control's content: the chosen options drawn your way, in place of chips. */
484
+ readonly renderValue?: ((options: readonly ChoiceOption<K, T>[]) => ReactNode) | undefined;
485
+ /** The popup opened or closed, with why. */
486
+ readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;
487
+ /** The search text changed: typed, or dropped as the popup closed. */
488
+ readonly onQueryChange?: ((event: QueryChangeEvent<Event>) => void) | undefined;
489
+ /** The option the keys or the pointer are on changed. */
490
+ readonly onHighlightChange?: ((event: HighlightChangeEvent<ChoiceOption<K, T>, Event>) => void) | undefined;
491
+ /** A request to the source failed. */
492
+ readonly onLoadError?: ((event: LoadErrorEvent<F>) => void) | undefined;
493
+ /**
494
+ * Adds a "Create" row for search text no option's label matches. The
495
+ * option it returns, at once or awaited, is chosen; `null` creates
496
+ * nothing.
497
+ */
498
+ readonly onCreate?: ((event: CreateEvent<Event>) => ChoiceOption<K, T> | null | Promise<ChoiceOption<K, T> | null>) | undefined;
499
+ /** The focusable control: the `<button>`, or the `<input>` when searchable. */
500
+ readonly ref?: Ref<HTMLElement> | undefined;
501
+ }
502
+ /** A `Select` holding one key, `null` when nothing is chosen. */
503
+ interface SingleSelectProps<K extends OptionKey, T = unknown, F = undefined> extends SelectCommonProps<K, T, F>, Omit<InputBaseProps<K, HTMLInputElement, SingleChoiceDetails<ChoiceOption<K, T>>>, "ref" | "handleRef">, Pick<FieldInputProps<K, HTMLInputElement, SingleChoiceDetails<ChoiceOption<K, T>>>, "onBeforeInput"> {
504
+ readonly multiple?: false | undefined;
505
+ /**
506
+ * A searchable select with string keys: text no option's label matches
507
+ * commits as the key itself.
508
+ */
509
+ readonly allowCustomValue?: boolean | undefined;
510
+ readonly handleRef?: Ref<ChoiceHandle<K>> | undefined;
511
+ }
512
+ /** A `Select` holding several keys in the order chosen, `null` when none is. */
513
+ interface MultipleSelectProps<K extends OptionKey, T = unknown, F = undefined> extends SelectCommonProps<K, T, F>, Omit<InputBaseProps<readonly K[], HTMLInputElement, ChoiceDetails<ChoiceOption<K, T>>>, "ref" | "handleRef"> {
514
+ readonly multiple: true;
515
+ /** The most options that can be chosen; a longer value from the app is an error. */
516
+ readonly maxCount?: number | undefined;
517
+ /** The fewest options a value may hold, once it holds one. */
518
+ readonly minCount?: number | undefined;
519
+ /** A "Select all" row at the top of the list. */
520
+ readonly selectAll?: boolean | undefined;
521
+ /** At most this many chips while the field is not focused; as many as fit by default. */
522
+ readonly maxChips?: number | undefined;
523
+ readonly handleRef?: Ref<ChoiceHandle<readonly K[]>> | undefined;
524
+ }
525
+ type SelectProps<K extends OptionKey, T = unknown, F = undefined> = SingleSelectProps<K, T, F> | MultipleSelectProps<K, T, F>;
526
+
527
+ /**
528
+ * A choice from a list of options: a button-like control that opens the
529
+ * list, or with `searchable` a text box that filters it as it is typed in.
530
+ * Its value is the chosen option's key (`option.value`), `null` when
531
+ * nothing is chosen; with `multiple`, the chosen keys in the order chosen,
532
+ * shown as chips. Options can sit in groups, show a description or extra
533
+ * columns, or be drawn by `renderOption`; long lists draw only the options
534
+ * in view, and a `source` loads them page by page from a server. It
535
+ * follows the WAI-ARIA combobox, with focus kept in the control, and takes
536
+ * every shared input prop: display mode, `readOnly`, `disabled`, messages
537
+ * with their severity, density and the events of `@gridkitjs/forms`,
538
+ * whose details carry the chosen options.
539
+ *
540
+ * Inside a `Field` it takes the field's label, description and messages;
541
+ * outside one, `label` and `description` draw a `Field` around it.
542
+ */
543
+ declare function Select<K extends OptionKey, T = unknown, F = undefined>(props: SelectProps<K, T, F>): react.JSX.Element;
544
+
408
545
  interface DateInputProps extends SegmentedInputProps<PlainDate, DateDetails>, DayLimits, CalendarSettings {
409
546
  /** The calendar button and its popup; on by default. */
410
547
  readonly calendar?: boolean | undefined;
@@ -1208,4 +1345,4 @@ interface SwitchProps extends Omit<ToggleBaseProps<boolean>, "value" | "defaultV
1208
1345
  */
1209
1346
  declare function Switch(props: SwitchProps): react.JSX.Element;
1210
1347
 
1211
- export { Calendar, type CalendarLimitProps, type CalendarProps, type CalendarSettings, Checkbox, type CheckboxProps, DateInput, type DateInputProps, DateTimeInput, type DateTimeInputProps, type DateTimeValue, type DateTimeValueType, type DateTimeZoneProps, type DayLimits, type Density, DurationInput, type DurationInputProps, Field, type FieldBeforeChangeEvent, type FieldBeforeCommitEvent, type FieldBeforeInputEvent, type FieldChangeEvent, type FieldClearEvent, type FieldCommitEvent, type FieldControlBinding, type FieldControlProps, type FieldControlState, type FieldEventBase, type FieldFocusEvent, FieldGroup, type FieldGroupProps, type FieldHandlers, type FieldInput, type FieldInputEvent, type FieldInputKind, type FieldInputOptions, type FieldInputProps, type FieldMode, type FieldProps, type FieldSpan, type FieldValidateEvent, Fieldset, type FieldsetProps, Form, FormLayout, type FormLayoutProps, type FormProps, FormSection, type FormSectionProps, FormsProvider, type FormsProviderProps, type InputBaseProps, type InputHandle, type LabelPosition, type ManagedControlProps, MaskedInput, type MaskedInputProps, MessageSummary, type MessageSummaryProps, type NecessityIndicator, NumberInput, type NumberInputProps, type NumberLimit, type NumberRange, type NumberRangeDetails, NumberRangeInput, type NumberRangeInputProps, type NumberStepEvent, PercentInput, type PercentInputProps, PeriodInput, type PeriodInputProps, RangeCalendar, type RangeCalendarDetails, type RangeCalendarProps, SearchInput, type SearchInputProps, type SegmentedInputProps, Switch, type SwitchProps, TextInput, type TextInputBaseProps, type TextInputProps, TimeInput, type TimeInputProps, type TimeSettings, type ToggleBaseProps, type ToggleLabelPlacement, type UseFieldOptions, type UseFieldResult, useField, useFieldInput };
1348
+ export { Calendar, type CalendarLimitProps, type CalendarProps, type CalendarSettings, Checkbox, type CheckboxProps, type ChoiceHandle, DateInput, type DateInputProps, DateTimeInput, type DateTimeInputProps, type DateTimeValue, type DateTimeValueType, type DateTimeZoneProps, type DayLimits, type Density, DurationInput, type DurationInputProps, Field, type FieldBeforeChangeEvent, type FieldBeforeCommitEvent, type FieldBeforeInputEvent, type FieldChangeEvent, type FieldClearEvent, type FieldCommitEvent, type FieldControlBinding, type FieldControlProps, type FieldControlState, type FieldEventBase, type FieldFocusEvent, FieldGroup, type FieldGroupProps, type FieldHandlers, type FieldInput, type FieldInputEvent, type FieldInputKind, type FieldInputOptions, type FieldInputProps, type FieldMode, type FieldProps, type FieldSpan, type FieldValidateEvent, Fieldset, type FieldsetProps, Form, FormLayout, type FormLayoutProps, type FormProps, FormSection, type FormSectionProps, FormsProvider, type FormsProviderProps, type InputBaseProps, type InputHandle, type LabelPosition, type ManagedControlProps, MaskedInput, type MaskedInputProps, MessageSummary, type MessageSummaryProps, type MultipleSelectProps, type NecessityIndicator, NumberInput, type NumberInputProps, type NumberLimit, type NumberRange, type NumberRangeDetails, NumberRangeInput, type NumberRangeInputProps, type NumberStepEvent, type OptionColumn, type OptionSource, type OptionState, PercentInput, type PercentInputProps, PeriodInput, type PeriodInputProps, RangeCalendar, type RangeCalendarDetails, type RangeCalendarProps, SearchInput, type SearchInputProps, type SegmentedInputProps, Select, type SelectCommonProps, type SelectProps, type SingleSelectProps, Switch, type SwitchProps, TextInput, type TextInputBaseProps, type TextInputProps, TimeInput, type TimeInputProps, type TimeSettings, type ToggleBaseProps, type ToggleLabelPlacement, type UseFieldOptions, type UseFieldResult, useField, useFieldInput };