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

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, 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';
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, QueryChangeEvent, HighlightChangeEvent, LoadErrorEvent, PopupOpenChange, CreateEvent, ChoiceDetails, SingleChoiceDetails, AutocompleteDetails, TagDetails, 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 { AutocompleteDetails, 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, TagDetails, 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';
@@ -443,8 +443,8 @@ interface ChoiceHandle<V> extends InputHandle<V> {
443
443
  /** Forgets the source's cached pages and, if the list shows, asks again. */
444
444
  reload(): void;
445
445
  }
446
- /** The props every `Select` takes, whatever its value. */
447
- interface SelectCommonProps<K extends OptionKey, T, F = undefined> {
446
+ /** The props of every input with a list of options: where they come from, how they match and are drawn. */
447
+ interface OptionsProps<K extends OptionKey, T, F = undefined> {
448
448
  /**
449
449
  * The options, in the order they are listed; `group` draws them under
450
450
  * headers. With a `source`, options known without asking it.
@@ -454,20 +454,29 @@ interface SelectCommonProps<K extends OptionKey, T, F = undefined> {
454
454
  readonly source?: OptionSource<ChoiceOption<K, T>, F> | undefined;
455
455
  /** The source's dependent filters (a city list's country), compared by value. */
456
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
457
  /** The source's pages and labels, shared by every input on it. One per input by default. */
460
458
  readonly cache?: OptionCache<ChoiceOption<K, T>> | undefined;
461
459
  /** How the search text matches: a mode, or a matcher of your own. Default `"contains"`. */
462
460
  readonly match?: MatchMode | OptionMatcher<ChoiceOption<K, T>> | undefined;
463
461
  /** What the search text is matched against: `"label"`, `"description"`, `"keywords"`, column ids. Default label and keywords. */
464
462
  readonly matchFields?: readonly string[] | undefined;
465
- /** Draws an option's content your way; the tick stays the select's. */
463
+ /** Draws an option's content your way; the row and its tick stay the input's. */
466
464
  readonly renderOption?: ((option: ChoiceOption<K, T>, state: OptionState) => ReactNode) | undefined;
467
465
  /** Draws only the options in view. Default: above 100 rows, and always with a source. */
468
466
  readonly virtualize?: boolean | undefined;
469
467
  /** Whether the keys reach disabled options, announced as unavailable. Default `"skip"`. */
470
468
  readonly disabledOptions?: DisabledOptions | undefined;
469
+ /** The search text changed: typed, or dropped as the popup closed. */
470
+ readonly onQueryChange?: ((event: QueryChangeEvent<Event>) => void) | undefined;
471
+ /** The option the keys or the pointer are on changed. */
472
+ readonly onHighlightChange?: ((event: HighlightChangeEvent<ChoiceOption<K, T>, Event>) => void) | undefined;
473
+ /** A request to the source failed. */
474
+ readonly onLoadError?: ((event: LoadErrorEvent<F>) => void) | undefined;
475
+ }
476
+ /** The props every `Select` takes, whatever its value. */
477
+ interface SelectCommonProps<K extends OptionKey, T, F = undefined> extends OptionsProps<K, T, F> {
478
+ /** The options of the value, when the list does not hold them: their labels show at once. */
479
+ readonly valueOptions?: readonly ChoiceOption<K, T>[] | undefined;
471
480
  /** A text box that filters the list. Default: a button-like control. */
472
481
  readonly searchable?: boolean | undefined;
473
482
  /** Shown while nothing is chosen. Never a label. */
@@ -484,12 +493,6 @@ interface SelectCommonProps<K extends OptionKey, T, F = undefined> {
484
493
  readonly renderValue?: ((options: readonly ChoiceOption<K, T>[]) => ReactNode) | undefined;
485
494
  /** The popup opened or closed, with why. */
486
495
  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
496
  /**
494
497
  * Adds a "Create" row for search text no option's label matches. The
495
498
  * option it returns, at once or awaited, is chosen; `null` creates
@@ -524,6 +527,47 @@ interface MultipleSelectProps<K extends OptionKey, T = unknown, F = undefined> e
524
527
  }
525
528
  type SelectProps<K extends OptionKey, T = unknown, F = undefined> = SingleSelectProps<K, T, F> | MultipleSelectProps<K, T, F>;
526
529
 
530
+ /** The props of an `Autocomplete`, whose value is its text. */
531
+ interface AutocompleteProps<K extends OptionKey = string, T = unknown, F = undefined> extends OptionsProps<K, T, F>, Omit<InputBaseProps<string, HTMLInputElement, AutocompleteDetails<ChoiceOption<K, T>>>, "ref" | "handleRef">, Pick<FieldInputProps<string, HTMLInputElement, AutocompleteDetails<ChoiceOption<K, T>>>, "onBeforeInput"> {
532
+ /** Shown while the box is empty. Never a label. */
533
+ readonly placeholder?: string | undefined;
534
+ /** Inside the box, at the inline start. Read with the control. */
535
+ readonly prefix?: ReactNode;
536
+ /** Inside the box, at the inline end. Read with the control. */
537
+ readonly suffix?: ReactNode;
538
+ /** A button in the box that empties the field, shown while it has text. */
539
+ readonly clearable?: boolean | undefined;
540
+ /**
541
+ * Writes the rest of the first suggestion that starts with the typed
542
+ * text after it, selected, so typing on replaces it. Default `false`.
543
+ */
544
+ readonly inlineComplete?: boolean | undefined;
545
+ /** The on-screen keyboard to show. */
546
+ readonly inputMode?: HTMLAttributes<HTMLInputElement>["inputMode"];
547
+ /** The label of the on-screen keyboard's Enter key. */
548
+ readonly enterKeyHint?: HTMLAttributes<HTMLInputElement>["enterKeyHint"];
549
+ /** The popup opened or closed, with why. */
550
+ readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;
551
+ /** The `<input>`. */
552
+ readonly ref?: Ref<HTMLInputElement> | undefined;
553
+ readonly handleRef?: Ref<ChoiceHandle<string>> | undefined;
554
+ }
555
+ /**
556
+ * A text box that suggests options as it is typed in. Its value is the
557
+ * text, `null` when empty: a suggestion chosen writes its label, and any
558
+ * other text stays as typed, so it suits a field whose answer may be
559
+ * new. The suggestions come from `options` or a `source`, as a `Select`'s
560
+ * do, and `inlineComplete` writes the rest of the first one after the
561
+ * typed text. It follows the WAI-ARIA combobox, with focus kept in the
562
+ * box, and takes every shared input prop: display mode, `readOnly`,
563
+ * `disabled`, messages with their severity, density and the events of
564
+ * `@gridkitjs/forms`, whose details carry the option the text names.
565
+ *
566
+ * Inside a `Field` it takes the field's label, description and messages;
567
+ * outside one, `label` and `description` draw a `Field` around it.
568
+ */
569
+ declare function Autocomplete<K extends OptionKey = string, T = unknown, F = undefined>(props: AutocompleteProps<K, T, F>): react.JSX.Element;
570
+
527
571
  /**
528
572
  * A choice from a list of options: a button-like control that opens the
529
573
  * list, or with `searchable` a text box that filters it as it is typed in.
@@ -542,6 +586,65 @@ type SelectProps<K extends OptionKey, T = unknown, F = undefined> = SingleSelect
542
586
  */
543
587
  declare function Select<K extends OptionKey, T = unknown, F = undefined>(props: SelectProps<K, T, F>): react.JSX.Element;
544
588
 
589
+ /** What a tag input does with a tag `validateTag` refuses. */
590
+ type InvalidTags = "mark" | "refuse";
591
+
592
+ /** The props of a `TagInput`, whose value is a list of texts. */
593
+ interface TagInputProps<T = unknown, F = undefined> extends OptionsProps<string, T, F>, Omit<InputBaseProps<readonly string[], HTMLInputElement, TagDetails>, "ref" | "handleRef"> {
594
+ /** Shown while there is no tag and no text. Never a label. */
595
+ readonly placeholder?: string | undefined;
596
+ /** Inside the box, at the inline start. Read with the control. */
597
+ readonly prefix?: ReactNode;
598
+ /** Inside the box, at the inline end. Read with the control. */
599
+ readonly suffix?: ReactNode;
600
+ /** A button in the box that removes every tag, shown while there is one. */
601
+ readonly clearable?: boolean | undefined;
602
+ /** Texts that end a tag as they are typed, beside Enter; pasted text splits on line breaks too. Default `[","]`. */
603
+ readonly separators?: readonly string[] | undefined;
604
+ /** The same tag may be added twice. Default `false`: a repeat is refused. */
605
+ readonly allowDuplicates?: boolean | undefined;
606
+ /** Reads a piece of text as a tag; `null` refuses it. Default: trimmed, empty refused. */
607
+ readonly parseTag?: ((text: string) => string | null) | undefined;
608
+ /** Checks each tag as it is added, as a validator checks a text. */
609
+ readonly validateTag?: Validator<string> | readonly Validator<string>[] | undefined;
610
+ /**
611
+ * A tag `validateTag` refuses: kept and marked, the field holding an
612
+ * error naming it (`"mark"`), or left as text in the box with the
613
+ * message (`"refuse"`). Default `"mark"`.
614
+ */
615
+ readonly invalidTags?: InvalidTags | undefined;
616
+ /** The most tags; one past it is refused. */
617
+ readonly maxCount?: number | undefined;
618
+ /** Leaving the box turns its text into a tag, so it is not lost. Default `true`. */
619
+ readonly addOnBlur?: boolean | undefined;
620
+ /** At most this many chips while the field is not focused; as many as fit by default. */
621
+ readonly maxChips?: number | undefined;
622
+ /** The on-screen keyboard to show: `"email"` for addresses. */
623
+ readonly inputMode?: HTMLAttributes<HTMLInputElement>["inputMode"];
624
+ /** The popup of suggestions opened or closed, with why. */
625
+ readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;
626
+ /** The `<input>`. */
627
+ readonly ref?: Ref<HTMLInputElement> | undefined;
628
+ readonly handleRef?: Ref<ChoiceHandle<readonly string[]>> | undefined;
629
+ }
630
+
631
+ /**
632
+ * A text box that turns what is typed into tags, shown as chips: e-mail
633
+ * recipients, labels, keywords. Its value is the list of tags, `null`
634
+ * while there is none. Enter or a separator (a comma by default) ends a
635
+ * tag, a paste holding separators or line breaks becomes several, and
636
+ * leaving the box keeps its text as a tag. `validateTag` checks each tag
637
+ * as it is added; with `invalidTags` a refused one is kept and marked or
638
+ * left as text. `options` or a `source` suggest tags as they are typed. It
639
+ * takes every shared input prop: display mode, `readOnly`, `disabled`,
640
+ * messages with their severity, density and the events of
641
+ * `@gridkitjs/forms`, whose details carry the tags added and removed.
642
+ *
643
+ * Inside a `Field` it takes the field's label, description and messages;
644
+ * outside one, `label` and `description` draw a `Field` around it.
645
+ */
646
+ declare function TagInput<T = unknown, F = undefined>(props: TagInputProps<T, F>): react.JSX.Element;
647
+
545
648
  interface DateInputProps extends SegmentedInputProps<PlainDate, DateDetails>, DayLimits, CalendarSettings {
546
649
  /** The calendar button and its popup; on by default. */
547
650
  readonly calendar?: boolean | undefined;
@@ -1345,4 +1448,4 @@ interface SwitchProps extends Omit<ToggleBaseProps<boolean>, "value" | "defaultV
1345
1448
  */
1346
1449
  declare function Switch(props: SwitchProps): react.JSX.Element;
1347
1450
 
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 };
1451
+ export { Autocomplete, type AutocompleteProps, 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 InvalidTags, 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, type OptionsProps, 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, TagInput, type TagInputProps, TextInput, type TextInputBaseProps, type TextInputProps, TimeInput, type TimeInputProps, type TimeSettings, type ToggleBaseProps, type ToggleLabelPlacement, type UseFieldOptions, type UseFieldResult, useField, useFieldInput };