@gridkitjs/forms-core 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
@@ -588,6 +588,8 @@ interface FormsMessages {
588
588
  cardNumberInvalid: string;
589
589
  /** An IPv4 address has a part above 255, or one with a leading zero. */
590
590
  ipv4Invalid: string;
591
+ /** Text that is not one plain e-mail address. */
592
+ invalidEmail: string;
591
593
  /** The visible character counter. */
592
594
  counter: (count: number, max: number) => string;
593
595
  /** The counter's description, read with the control. */
@@ -656,6 +658,14 @@ interface FormsMessages {
656
658
  tooFewChoices: (min: number) => string;
657
659
  /** Shown and announced once `maxCount` options are chosen. */
658
660
  maxChoicesReached: (max: number) => string;
661
+ /** The name of a tag input's list of entries. */
662
+ tagEntries: string;
663
+ /** Announced and shown as a tag input refuses an entry it already holds. */
664
+ duplicateTag: (tag: string) => string;
665
+ /** A tag input holding entries its check refuses; `tags` lists them. */
666
+ invalidTags: (count: number, tags: string) => string;
667
+ /** Read after an entry its check refuses. */
668
+ notValid: string;
659
669
  /** Read before a message, naming its severity. */
660
670
  severityLabel: (severity: Severity) => string;
661
671
  /** How many messages of one severity a summary holds. */
@@ -1272,6 +1282,16 @@ interface SingleChoiceDetails<O extends ChoiceOption> extends ChoiceDetails<O> {
1272
1282
  readonly option: O | null;
1273
1283
  readonly previousOption: O | null;
1274
1284
  }
1285
+ /**
1286
+ * What an autocomplete, whose value is its text, adds to every event it
1287
+ * fires.
1288
+ */
1289
+ interface AutocompleteDetails<O extends ChoiceOption = ChoiceOption> {
1290
+ /** The suggestion whose label the text is, `null` when it is no suggestion's. */
1291
+ readonly option: O | null;
1292
+ /** The text typed, without an inline completion after it. */
1293
+ readonly query: string;
1294
+ }
1275
1295
  /** The search text changed (`onQueryChange`). */
1276
1296
  interface QueryChangeEvent<N = unknown> {
1277
1297
  readonly query: string;
@@ -1589,6 +1609,97 @@ interface OptionSourceController<O extends ChoiceOption, F, S> {
1589
1609
  */
1590
1610
  declare function createOptionSourceController<O extends ChoiceOption, F, S>(initial: OptionSourceOptions<O, F, S>): OptionSourceController<O, F, S>;
1591
1611
 
1612
+ /** What a validator knows beside the value. */
1613
+ interface ValidatorContext {
1614
+ /** The text the field shows. */
1615
+ readonly text: string;
1616
+ readonly locale: Intl.LocalesArgument;
1617
+ readonly messages: FormsMessages;
1618
+ }
1619
+ /** What a validator returns: one message or several, `null` or nothing when the value is fine. */
1620
+ type ValidationResult = FieldMessageInput | readonly FieldMessageInput[] | null | undefined;
1621
+ /**
1622
+ * Checks a value. Called with every value, `null` included, after each
1623
+ * change, so it must be synchronous and cheap: anything slow or remote
1624
+ * belongs in `onBeforeCommit`. A string it returns is an error; a message
1625
+ * with another severity is shown and never blocks.
1626
+ */
1627
+ type Validator<V> = (value: V | null, context: ValidatorContext) => ValidationResult;
1628
+ /** `null`, or a string of only whitespace, is `messages.required`. */
1629
+ declare function requiredRule<V>(): Validator<V>;
1630
+ /**
1631
+ * `null` is `messages.requiredChoice`: a choice input with nothing
1632
+ * chosen. Its value holds keys, so an empty string is a key like any other.
1633
+ */
1634
+ declare function requiredChoiceRule<V>(): Validator<V>;
1635
+ /**
1636
+ * More than `max` keys is `messages.tooManyChoices`: a choice input with
1637
+ * several values, given one over its limit. `null` passes.
1638
+ */
1639
+ declare function maxCountRule<K>(max: number): Validator<readonly K[]>;
1640
+ /**
1641
+ * Fewer than `min` keys is `messages.tooFewChoices`. `null` passes, as an
1642
+ * empty text passes `minLengthRule`: `required` asks for a first choice.
1643
+ */
1644
+ declare function minCountRule<K>(min: number): Validator<readonly K[]>;
1645
+ /** Fewer than `min` code points is `messages.tooShort`. `null` passes. */
1646
+ declare function minLengthRule(min: number): Validator<string>;
1647
+ /** More than `max` code points is `messages.tooLong`. `null` passes. */
1648
+ declare function maxLengthRule(max: number): Validator<string>;
1649
+ /**
1650
+ * The whole value must match `pattern`, as the HTML `pattern` attribute
1651
+ * reads it; `message` replaces `messages.patternMismatch`. `null` passes.
1652
+ */
1653
+ declare function patternRule(pattern: RegExp, message?: string): Validator<string>;
1654
+ /**
1655
+ * Text that is not one plain e-mail address (`name@example.com`) is
1656
+ * `messages.invalidEmail`. It checks the shape only: no display names
1657
+ * (`Ada <ada@example.com>`), groups or quoted parts. `null` passes.
1658
+ */
1659
+ declare function emailRule(): Validator<string>;
1660
+ /**
1661
+ * Anything but `true` is the message `message` picks from the catalogue:
1662
+ * a required checkbox (`requiredChecked`) or switch (`requiredOn`).
1663
+ */
1664
+ declare function checkedRule(message: (messages: FormsMessages) => string): Validator<boolean>;
1665
+
1666
+ /** What a tag input adds to every event it fires. */
1667
+ interface TagDetails {
1668
+ /** Tags in the value now and not before, in the value's order. */
1669
+ readonly added: readonly string[];
1670
+ /** Tags in the value before and not now, in the previous value's order. */
1671
+ readonly removed: readonly string[];
1672
+ /** Tags of the value that the tag check refuses, still in it. */
1673
+ readonly invalid: readonly string[];
1674
+ /** The text left in the box, not yet a tag. */
1675
+ readonly pending: string;
1676
+ }
1677
+ /**
1678
+ * `text` cut at every one of `separators` and at line breaks, in order,
1679
+ * each piece as written (`parseTag` trims it): `"a@x.com, b@y.com"` with
1680
+ * `[","]` is `["a@x.com", " b@y.com"]`. Text holding no separator is one
1681
+ * piece.
1682
+ */
1683
+ declare function splitTags(text: string, separators: readonly string[]): string[];
1684
+ /** Whether `text` holds a separator or a line break: a paste of several tags. */
1685
+ declare function hasTagSeparator(text: string, separators: readonly string[]): boolean;
1686
+ /**
1687
+ * A tag input's details. A tag held twice counts twice, so adding a
1688
+ * second copy of one is an `added` of that tag.
1689
+ */
1690
+ declare function tagDetails(value: readonly string[] | null, previous: readonly string[] | null, isInvalid: (tag: string) => boolean, pending: string): TagDetails;
1691
+ /** Every message `validators` return for one tag, checked as text of its own. */
1692
+ declare function tagMessages(tag: string, validators: readonly Validator<string>[], context: Omit<ValidatorContext, "text">): FieldMessage[];
1693
+ /** Whether `validators` refuse `tag`: one of them returns an error. */
1694
+ declare function isInvalidTag(tag: string, validators: readonly Validator<string>[], context: Omit<ValidatorContext, "text">): boolean;
1695
+ /**
1696
+ * Tags `validators` refuse, each checked as text of its own, make the
1697
+ * whole value `messages.invalidTags` (code `"invalidTags"`), which names
1698
+ * them: "1 entry is not valid: x@". A warning a validator returns for a tag
1699
+ * refuses nothing. `null` passes.
1700
+ */
1701
+ declare function tagsRule(validators: readonly Validator<string>[]): Validator<readonly string[]>;
1702
+
1592
1703
  /**
1593
1704
  * What a tree's value holds with several values: every ticked node
1594
1705
  * (`"all"`), ticked nodes with no children (`"leaves"`), or each ticked
@@ -2461,54 +2572,6 @@ declare function instantZoneMessage(text: string, options: InstantFieldOptions &
2461
2572
  readonly messages: FormsMessages;
2462
2573
  }): string | null;
2463
2574
 
2464
- /** What a validator knows beside the value. */
2465
- interface ValidatorContext {
2466
- /** The text the field shows. */
2467
- readonly text: string;
2468
- readonly locale: Intl.LocalesArgument;
2469
- readonly messages: FormsMessages;
2470
- }
2471
- /** What a validator returns: one message or several, `null` or nothing when the value is fine. */
2472
- type ValidationResult = FieldMessageInput | readonly FieldMessageInput[] | null | undefined;
2473
- /**
2474
- * Checks a value. Called with every value, `null` included, after each
2475
- * change, so it must be synchronous and cheap: anything slow or remote
2476
- * belongs in `onBeforeCommit`. A string it returns is an error; a message
2477
- * with another severity is shown and never blocks.
2478
- */
2479
- type Validator<V> = (value: V | null, context: ValidatorContext) => ValidationResult;
2480
- /** `null`, or a string of only whitespace, is `messages.required`. */
2481
- declare function requiredRule<V>(): Validator<V>;
2482
- /**
2483
- * `null` is `messages.requiredChoice`: a choice input with nothing
2484
- * chosen. Its value holds keys, so an empty string is a key like any other.
2485
- */
2486
- declare function requiredChoiceRule<V>(): Validator<V>;
2487
- /**
2488
- * More than `max` keys is `messages.tooManyChoices`: a choice input with
2489
- * several values, given one over its limit. `null` passes.
2490
- */
2491
- declare function maxCountRule<K>(max: number): Validator<readonly K[]>;
2492
- /**
2493
- * Fewer than `min` keys is `messages.tooFewChoices`. `null` passes, as an
2494
- * empty text passes `minLengthRule`: `required` asks for a first choice.
2495
- */
2496
- declare function minCountRule<K>(min: number): Validator<readonly K[]>;
2497
- /** Fewer than `min` code points is `messages.tooShort`. `null` passes. */
2498
- declare function minLengthRule(min: number): Validator<string>;
2499
- /** More than `max` code points is `messages.tooLong`. `null` passes. */
2500
- declare function maxLengthRule(max: number): Validator<string>;
2501
- /**
2502
- * The whole value must match `pattern`, as the HTML `pattern` attribute
2503
- * reads it; `message` replaces `messages.patternMismatch`. `null` passes.
2504
- */
2505
- declare function patternRule(pattern: RegExp, message?: string): Validator<string>;
2506
- /**
2507
- * Anything but `true` is the message `message` picks from the catalogue:
2508
- * a required checkbox (`requiredChecked`) or switch (`requiredOn`).
2509
- */
2510
- declare function checkedRule(message: (messages: FormsMessages) => string): Validator<boolean>;
2511
-
2512
2575
  /** Writes a span for a message: "10", "14 days". */
2513
2576
  type SpanFormatter<S> = (span: S, context: ValidatorContext) => string;
2514
2577
  /**
@@ -4371,4 +4434,4 @@ interface VisibleRange {
4371
4434
  */
4372
4435
  declare function visibleRange(heights: RowHeights, estimatedHeight: number, scrollTop: number, viewportHeight: number, overscan: number): VisibleRange;
4373
4436
 
4374
- export { ALL_DAY, type AbortFactory, type ActiveMove, type AssembleContext, type BeforeInputDecision, type BooleanWords, CALENDAR_FISCAL_YEAR, CHECKBOX_WORDS, CHILDREN_UNLOADED, type CalendarAction, type CalendarContext, type CalendarDay, type CalendarLimits, type CalendarMonth, type CalendarMove, type CalendarState, type CalendarUnit, type CalendarView, type CalendarWeek, type ChangeCause, type ChangeSource, type ChildrenLoad, type ChildrenLoadAction, type ChoiceDetails, type ChoiceOption, type CleanedNumber, type CommitOutcome, type CommitTrigger, type CompiledMask, type CompositeController, type CompositeDetailsContext, type CompositeFieldOptions, type CompositeState, type CreateEvent, DEFAULT_MATCH_FIELDS, DEFAULT_SOURCE_DEBOUNCE, DEFAULT_SOURCE_PAGE_SIZE, type DateDetails, type DateFieldOptions, type DateLayout, type DateLayoutFields, type DateLayoutOptions, type DateLayoutPart, type DateParts, type DatePreset, type DateRange, type DateReadOptions, type DateReadingInfo, type DateRuleContext, type DateSegment, type DateSegmentType, type DateTextReading, type DateTimeDetails, type DateTimeFieldOptions, type DateUnreadableReason, type DecimalString, type DefaultTimes, type DisabledOptions, type DurationDetails, type DurationLike, type DurationNotation, type DurationOptions, type DurationReading, type DurationUnit, type FieldAction, type FieldBeforeChangeEvent, type FieldBeforeCommitEvent, type FieldBeforeInputEvent, type FieldChangeEvent, type FieldCommitEvent, type FieldController, type FieldDraft, type FieldEventBase, type FieldFocusEvent, type FieldHandlers, type FieldInputEvent, type FieldMessage, type FieldMessageInput, type FieldOptions, type FieldPhase, type FieldRegistry, type FieldState, type FieldValidateEvent, type FiscalMonthPeriod, type FiscalQuarterPeriod, type FiscalYear, type FiscalYearPeriod, type FoldedText, type FormatContext, type FormatPurpose, type Formatter, type FormsMessages, type FractionDigits, type HighlightChangeEvent, type InputFilter, type InputFilterDecision, type Instant, type InstantFieldOptions, type KeyChanges, type KeyList, type KeyLookup, type KeyOf, type LoadErrorEvent, type LoadedOptions, type MaskCompileResult, type MaskDetails, type MaskEdit, type MaskInputHints, type MaskLetterCase, type MaskOptions, type MaskPreset, type MaskPresets, type MaskResult, type MaskSlot, type MaskSource, type MaskTokenDefinition, type MaskTokens, type MaskValueFormat, type MaskedText, type MatchContext, type MatchMode, type MessageSummary, type MonthGrid, type MonthGridOptions, type MonthPeriod, NO_TIME, type NavigableRow, type NegativeStyle, type NoDetails, type NoFlags, type NumberAffixes, type NumberDetails, type NumberEntry, type NumberEntryOptions, type NumberFieldOptions, type NumberLike, type NumberOptions, type NumberReading, type NumberReadingInfo, type NumberStep, type NumberStyle, type NumberSymbolOverrides, type NumberSymbols, type NumberTextForm, type NumberUnreadableReason, type NumberValue, type NumberValueType, type OptionAction, type OptionCache, type OptionCacheOptions, type OptionCursor, type OptionHit, type OptionIndex, type OptionKey, type OptionMatch, type OptionMatcher, type OptionPage, type OptionQuery, type OptionRow, type OptionRowActions, type OptionSearch, type OptionSource, type OptionSourceController, type OptionSourceOptions, type OvernightFlags, POPUP_CLOSED, type PageKey, type ParseContext, type ParseResult, type Parser, type PartChange, type PartController, type PartOptions, type PartTexts, type PartValues, type PercentScale, type Period, type PeriodDetails, type PeriodFieldOptions, type PeriodGranularity, type PeriodLayoutOptions, type PeriodParts, type PeriodValues, type PickedDays, type PivotOptions, type PlainDate, type PlainDateTime, type PlainTime, type PopupAction, type PopupCloseReason, type PopupOpenChange, type PopupOpenReason, type PopupState, type PopupStep, type QuarterPeriod, type QueryChangeEvent, type Range, type RangeBounds, type RangeDetails, type RangeEnd, type RangeEnds, type RangeKind, type RangeOptions, type RangeOrientation, type RangePick, type RangePickAction, type RangePickStep, type RangeReading, type RangeTextOptions, type RangeValue, type RegisteredField, type RelativeDateRule, type RelativeRange, type ResolveRequest, type RoundingMode, type RowHeights, SOURCE_IDLE, SWITCH_WORDS, type Schedule, type ScopeState, type SegmentAction, type SegmentAria, type SegmentContext, type SegmentEntry, type SegmentRun, type SegmentState, type SegmentStep, type SegmentType, type Severity, type SeverityCount, type SingleChoiceDetails, type SourceAction, type SourceState, type SpanFormatter, type StepDirection, type StepRequest, type StepSize, type SummaryItem, type TextEdit, type TextInputDetails, type TextParseOptions, type TextRange, type TextReading, type TickState, type TimeColumn, type TimeColumnOption, type TimeColumnType, type TimeColumnsOptions, type TimeDetails, type TimeFieldOptions, type TimeLimits, type TimeParts, type TimeRange, type TimeRangeContext, type TimeZoneDisambiguation, type TreeIndex, type TreeOption, type TreeRow, type TreeSearch, type TreeSource, type TreeValueMode, type TypeaheadRow, type ValidationResult, type Validator, type ValidatorContext, type VisibleRange, type WeekInfo, type WeekNumbering, type WeekOfYear, type Weekday, type WritingDirection, type YearPeriod, type ZonedRangeContext, type ZonedReading, addDays, addDecimals, addKeys, addMonths, addPeriods, addYears, appendPage, applyMaskEdit, availableDateRule, booleanFormatter, booleanParser, calendarMonth, calendarMonthParts, calendarReducer, calendarStart, calendarYears, canAddKey, canSelectAll, checkedRule, childrenLoadReducer, choiceDetails, clampCalendarDate, clampCalendarMonth, clampTime, cleanPastedNumber, clearKeys, commonDatePresets, compareCalendarMonths, compareDateTimes, compareDates, compareDecimals, compareInstants, comparePeriods, compareTimes, compileMask, convertDuration, countCharacters, counterAnnouncement, createCompositeController, createDefaultFormsMessages, createFieldController, createFieldRegistry, createOptionCache, createOptionIndex, createOptionSourceController, createTreeIndex, dateDetails, dateFormatter, dateFromInstant, dateFromPlainDate, dateFromPlainDateTime, dateLayout, dateParser, dateParts, datePresetLabel, dateRangeKind, dateTimeDetails, dateTimeFormatter, dateTimeParser, dateTimeRangeKind, dayOfWeek, dayTimeLimits, daysBetween, daysInMonth, daysToDateTimeRange, daysToInstantRange, decimalRangeKind, decimalToNumber, defaultFormsMessages, defaultWeekNumbering, durationDetails, durationFormatter, durationParser, endOfMonth, endsRule, exactInstantOf, fieldMessages, fieldReducer, fieldText, filterMaskEdit, filterNumberEdit, filtersKey, findDuplicateKeys, fixedFractionDigits, flattenOptions, flattenTree, foldText, formatCalendarMonth, formatCalendarYear, formatDate, formatDateRange, formatDateSegments, formatDateTime, formatDateTimeSegments, formatDayOfMonth, formatDaySpan, formatDuration, formatInstant, formatMasked, formatMonthName, formatNumber, formatNumberRange, formatPeriod, formatPeriodPage, formatPeriodPlace, formatPeriodSegments, formatText, formatTime, formatTimeRange, formatTimeSegments, formatTimeSpan, formatWeekday, hasError, hasKey, ibanRule, idleSegments, inlineStep, instantDetails, instantFormatter, instantFromDate, instantOf, instantParser, instantRangeKind, instantZoneMessage, ipv4Rule, isCalendarDayDisabled, isCalendarMonth, isCalendarMonthDisabled, isDecimalString, isInstant, isLandingRow, isLeapYear, isPeriod, isPlainDate, isPlainDateTime, isPlainTime, isRelativeDateRule, isRelativeRange, isTimeZone, isValidMaskStart, joinSegments, keyChanges, keyText, luhnRule, maskDetails, maskFormatter, maskInputHints, maskParser, maskPresets, matchOption, matchText, maxCountRule, maxDateRule, maxDateTimeRule, maxDurationRule, maxInstantRule, maxLengthRule, maxPeriodRule, maxRule, maxSpanRule, maxTimeRule, minCountRule, minDateRule, minDateTimeRule, minDurationRule, minInstantRule, minLengthRule, minPeriodRule, minRule, minSpanRule, minTimeRule, minutesOfDay, monthGrid, monthOfDate, mostSevere, moveActive, moveCalendarDate, nextCheckedValue, normalizeDecimal, nowIn, numberAffixes, numberCaret, numberDetails, numberFormatter, numberFractionDigits, numberParser, numberRangeKind, numberRangeKindOf, numberSymbols, numberToDecimal, offsetOf, orderRange, parseDuration, parseNumber, parsed, patternRule, periodDetails, periodFormatter, periodGranularity, periodLayout, periodOf, periodPage, periodPageYears, periodParser, periodParts, periodRange, pickedDays, pivotYear, plainDate, plainDateFromDate, plainDateTime, plainTime, popupReducer, rangeDetails, rangeEnds, rangeFlags, rangeIncludes, rangeKeys, rangePickPreview, rangePickReducer, rangeSpan, readDateShortcut, readDateText, readRangeEnds, readTimeText, relativePreset, removeKeys, requiredChoiceRule, requiredRule, resolveDateRange, resolveDateRule, resolveFormsMessages, resolveRange, roundDecimal, runtimeTimeZone, sameDayIn, sameFilters, sameKey, sameKeys, sameRange, sameRule, scopeState, searchTree, segmentAria, segmentReducer, segmentRuns, segmentSpans, segmentValue, segmentsTime, selectAll, setTimeColumn, shiftDecimal, shownEnd, shownMessages, singleChoiceDetails, snapTime, sortFieldMessages, sourceReducer, spanOf, splitDateTime, splitSegments, standInOption, startOfDayIn, startOfMonth, startOfWeek, stepNumber, stepNumberValue, stepRule, subtractDecimals, summarizeMessages, textParser, tickNode, tickState, tickedFromValue, timeColumns, timeDetails, timeFormatter, timeParser, timeParts, timeRangeKind, toFieldMessages, toInstant, toKeyList, toOptionPage, toPeriod, toPlainDate, toPlainDateTime, toPlainTime, todayIn, toggleKey, treeValue, typeaheadIndex, typeaheadRow, unreadable, valueKeys, visibleRange, wallClockOf, weekInfo, weekOf, writeSegment };
4437
+ export { ALL_DAY, type AbortFactory, type ActiveMove, type AssembleContext, type AutocompleteDetails, type BeforeInputDecision, type BooleanWords, CALENDAR_FISCAL_YEAR, CHECKBOX_WORDS, CHILDREN_UNLOADED, type CalendarAction, type CalendarContext, type CalendarDay, type CalendarLimits, type CalendarMonth, type CalendarMove, type CalendarState, type CalendarUnit, type CalendarView, type CalendarWeek, type ChangeCause, type ChangeSource, type ChildrenLoad, type ChildrenLoadAction, type ChoiceDetails, type ChoiceOption, type CleanedNumber, type CommitOutcome, type CommitTrigger, type CompiledMask, type CompositeController, type CompositeDetailsContext, type CompositeFieldOptions, type CompositeState, type CreateEvent, DEFAULT_MATCH_FIELDS, DEFAULT_SOURCE_DEBOUNCE, DEFAULT_SOURCE_PAGE_SIZE, type DateDetails, type DateFieldOptions, type DateLayout, type DateLayoutFields, type DateLayoutOptions, type DateLayoutPart, type DateParts, type DatePreset, type DateRange, type DateReadOptions, type DateReadingInfo, type DateRuleContext, type DateSegment, type DateSegmentType, type DateTextReading, type DateTimeDetails, type DateTimeFieldOptions, type DateUnreadableReason, type DecimalString, type DefaultTimes, type DisabledOptions, type DurationDetails, type DurationLike, type DurationNotation, type DurationOptions, type DurationReading, type DurationUnit, type FieldAction, type FieldBeforeChangeEvent, type FieldBeforeCommitEvent, type FieldBeforeInputEvent, type FieldChangeEvent, type FieldCommitEvent, type FieldController, type FieldDraft, type FieldEventBase, type FieldFocusEvent, type FieldHandlers, type FieldInputEvent, type FieldMessage, type FieldMessageInput, type FieldOptions, type FieldPhase, type FieldRegistry, type FieldState, type FieldValidateEvent, type FiscalMonthPeriod, type FiscalQuarterPeriod, type FiscalYear, type FiscalYearPeriod, type FoldedText, type FormatContext, type FormatPurpose, type Formatter, type FormsMessages, type FractionDigits, type HighlightChangeEvent, type InputFilter, type InputFilterDecision, type Instant, type InstantFieldOptions, type KeyChanges, type KeyList, type KeyLookup, type KeyOf, type LoadErrorEvent, type LoadedOptions, type MaskCompileResult, type MaskDetails, type MaskEdit, type MaskInputHints, type MaskLetterCase, type MaskOptions, type MaskPreset, type MaskPresets, type MaskResult, type MaskSlot, type MaskSource, type MaskTokenDefinition, type MaskTokens, type MaskValueFormat, type MaskedText, type MatchContext, type MatchMode, type MessageSummary, type MonthGrid, type MonthGridOptions, type MonthPeriod, NO_TIME, type NavigableRow, type NegativeStyle, type NoDetails, type NoFlags, type NumberAffixes, type NumberDetails, type NumberEntry, type NumberEntryOptions, type NumberFieldOptions, type NumberLike, type NumberOptions, type NumberReading, type NumberReadingInfo, type NumberStep, type NumberStyle, type NumberSymbolOverrides, type NumberSymbols, type NumberTextForm, type NumberUnreadableReason, type NumberValue, type NumberValueType, type OptionAction, type OptionCache, type OptionCacheOptions, type OptionCursor, type OptionHit, type OptionIndex, type OptionKey, type OptionMatch, type OptionMatcher, type OptionPage, type OptionQuery, type OptionRow, type OptionRowActions, type OptionSearch, type OptionSource, type OptionSourceController, type OptionSourceOptions, type OvernightFlags, POPUP_CLOSED, type PageKey, type ParseContext, type ParseResult, type Parser, type PartChange, type PartController, type PartOptions, type PartTexts, type PartValues, type PercentScale, type Period, type PeriodDetails, type PeriodFieldOptions, type PeriodGranularity, type PeriodLayoutOptions, type PeriodParts, type PeriodValues, type PickedDays, type PivotOptions, type PlainDate, type PlainDateTime, type PlainTime, type PopupAction, type PopupCloseReason, type PopupOpenChange, type PopupOpenReason, type PopupState, type PopupStep, type QuarterPeriod, type QueryChangeEvent, type Range, type RangeBounds, type RangeDetails, type RangeEnd, type RangeEnds, type RangeKind, type RangeOptions, type RangeOrientation, type RangePick, type RangePickAction, type RangePickStep, type RangeReading, type RangeTextOptions, type RangeValue, type RegisteredField, type RelativeDateRule, type RelativeRange, type ResolveRequest, type RoundingMode, type RowHeights, SOURCE_IDLE, SWITCH_WORDS, type Schedule, type ScopeState, type SegmentAction, type SegmentAria, type SegmentContext, type SegmentEntry, type SegmentRun, type SegmentState, type SegmentStep, type SegmentType, type Severity, type SeverityCount, type SingleChoiceDetails, type SourceAction, type SourceState, type SpanFormatter, type StepDirection, type StepRequest, type StepSize, type SummaryItem, type TagDetails, type TextEdit, type TextInputDetails, type TextParseOptions, type TextRange, type TextReading, type TickState, type TimeColumn, type TimeColumnOption, type TimeColumnType, type TimeColumnsOptions, type TimeDetails, type TimeFieldOptions, type TimeLimits, type TimeParts, type TimeRange, type TimeRangeContext, type TimeZoneDisambiguation, type TreeIndex, type TreeOption, type TreeRow, type TreeSearch, type TreeSource, type TreeValueMode, type TypeaheadRow, type ValidationResult, type Validator, type ValidatorContext, type VisibleRange, type WeekInfo, type WeekNumbering, type WeekOfYear, type Weekday, type WritingDirection, type YearPeriod, type ZonedRangeContext, type ZonedReading, addDays, addDecimals, addKeys, addMonths, addPeriods, addYears, appendPage, applyMaskEdit, availableDateRule, booleanFormatter, booleanParser, calendarMonth, calendarMonthParts, calendarReducer, calendarStart, calendarYears, canAddKey, canSelectAll, checkedRule, childrenLoadReducer, choiceDetails, clampCalendarDate, clampCalendarMonth, clampTime, cleanPastedNumber, clearKeys, commonDatePresets, compareCalendarMonths, compareDateTimes, compareDates, compareDecimals, compareInstants, comparePeriods, compareTimes, compileMask, convertDuration, countCharacters, counterAnnouncement, createCompositeController, createDefaultFormsMessages, createFieldController, createFieldRegistry, createOptionCache, createOptionIndex, createOptionSourceController, createTreeIndex, dateDetails, dateFormatter, dateFromInstant, dateFromPlainDate, dateFromPlainDateTime, dateLayout, dateParser, dateParts, datePresetLabel, dateRangeKind, dateTimeDetails, dateTimeFormatter, dateTimeParser, dateTimeRangeKind, dayOfWeek, dayTimeLimits, daysBetween, daysInMonth, daysToDateTimeRange, daysToInstantRange, decimalRangeKind, decimalToNumber, defaultFormsMessages, defaultWeekNumbering, durationDetails, durationFormatter, durationParser, emailRule, endOfMonth, endsRule, exactInstantOf, fieldMessages, fieldReducer, fieldText, filterMaskEdit, filterNumberEdit, filtersKey, findDuplicateKeys, fixedFractionDigits, flattenOptions, flattenTree, foldText, formatCalendarMonth, formatCalendarYear, formatDate, formatDateRange, formatDateSegments, formatDateTime, formatDateTimeSegments, formatDayOfMonth, formatDaySpan, formatDuration, formatInstant, formatMasked, formatMonthName, formatNumber, formatNumberRange, formatPeriod, formatPeriodPage, formatPeriodPlace, formatPeriodSegments, formatText, formatTime, formatTimeRange, formatTimeSegments, formatTimeSpan, formatWeekday, hasError, hasKey, hasTagSeparator, ibanRule, idleSegments, inlineStep, instantDetails, instantFormatter, instantFromDate, instantOf, instantParser, instantRangeKind, instantZoneMessage, ipv4Rule, isCalendarDayDisabled, isCalendarMonth, isCalendarMonthDisabled, isDecimalString, isInstant, isInvalidTag, isLandingRow, isLeapYear, isPeriod, isPlainDate, isPlainDateTime, isPlainTime, isRelativeDateRule, isRelativeRange, isTimeZone, isValidMaskStart, joinSegments, keyChanges, keyText, luhnRule, maskDetails, maskFormatter, maskInputHints, maskParser, maskPresets, matchOption, matchText, maxCountRule, maxDateRule, maxDateTimeRule, maxDurationRule, maxInstantRule, maxLengthRule, maxPeriodRule, maxRule, maxSpanRule, maxTimeRule, minCountRule, minDateRule, minDateTimeRule, minDurationRule, minInstantRule, minLengthRule, minPeriodRule, minRule, minSpanRule, minTimeRule, minutesOfDay, monthGrid, monthOfDate, mostSevere, moveActive, moveCalendarDate, nextCheckedValue, normalizeDecimal, nowIn, numberAffixes, numberCaret, numberDetails, numberFormatter, numberFractionDigits, numberParser, numberRangeKind, numberRangeKindOf, numberSymbols, numberToDecimal, offsetOf, orderRange, parseDuration, parseNumber, parsed, patternRule, periodDetails, periodFormatter, periodGranularity, periodLayout, periodOf, periodPage, periodPageYears, periodParser, periodParts, periodRange, pickedDays, pivotYear, plainDate, plainDateFromDate, plainDateTime, plainTime, popupReducer, rangeDetails, rangeEnds, rangeFlags, rangeIncludes, rangeKeys, rangePickPreview, rangePickReducer, rangeSpan, readDateShortcut, readDateText, readRangeEnds, readTimeText, relativePreset, removeKeys, requiredChoiceRule, requiredRule, resolveDateRange, resolveDateRule, resolveFormsMessages, resolveRange, roundDecimal, runtimeTimeZone, sameDayIn, sameFilters, sameKey, sameKeys, sameRange, sameRule, scopeState, searchTree, segmentAria, segmentReducer, segmentRuns, segmentSpans, segmentValue, segmentsTime, selectAll, setTimeColumn, shiftDecimal, shownEnd, shownMessages, singleChoiceDetails, snapTime, sortFieldMessages, sourceReducer, spanOf, splitDateTime, splitSegments, splitTags, standInOption, startOfDayIn, startOfMonth, startOfWeek, stepNumber, stepNumberValue, stepRule, subtractDecimals, summarizeMessages, tagDetails, tagMessages, tagsRule, textParser, tickNode, tickState, tickedFromValue, timeColumns, timeDetails, timeFormatter, timeParser, timeParts, timeRangeKind, toFieldMessages, toInstant, toKeyList, toOptionPage, toPeriod, toPlainDate, toPlainDateTime, toPlainTime, todayIn, toggleKey, treeValue, typeaheadIndex, typeaheadRow, unreadable, valueKeys, visibleRange, wallClockOf, weekInfo, weekOf, writeSegment };
package/dist/index.js CHANGED
@@ -1038,6 +1038,187 @@ function createOptionSourceController(initial) {
1038
1038
  };
1039
1039
  }
1040
1040
 
1041
+ // src/messages/severity.ts
1042
+ var BY_SERIOUSNESS = [
1043
+ "error",
1044
+ "warning",
1045
+ "info",
1046
+ "success"
1047
+ ];
1048
+ function severityRank(severity) {
1049
+ return BY_SERIOUSNESS.indexOf(severity);
1050
+ }
1051
+ function mostSevere(severities) {
1052
+ const present = new Set(severities);
1053
+ return BY_SERIOUSNESS.find((severity) => present.has(severity)) ?? null;
1054
+ }
1055
+
1056
+ // src/messages/fieldMessage.ts
1057
+ var SOURCE_ORDER = [
1058
+ "parse",
1059
+ "commit",
1060
+ "validate",
1061
+ "app"
1062
+ ];
1063
+ function toFieldMessage(input, source, code = null) {
1064
+ return typeof input === "string" ? { severity: "error", text: input, code, source } : {
1065
+ severity: input.severity ?? "error",
1066
+ text: input.text,
1067
+ code: input.code ?? code,
1068
+ source
1069
+ };
1070
+ }
1071
+ function toFieldMessages(input, source) {
1072
+ if (input === null || input === void 0) {
1073
+ return [];
1074
+ }
1075
+ return isList(input) ? input.map((entry2) => toFieldMessage(entry2, source)) : [toFieldMessage(input, source)];
1076
+ }
1077
+ function isList(input) {
1078
+ return Array.isArray(input);
1079
+ }
1080
+ function sortFieldMessages(messages) {
1081
+ return messages.toSorted(
1082
+ (a, b) => severityRank(a.severity) - severityRank(b.severity) || SOURCE_ORDER.indexOf(a.source) - SOURCE_ORDER.indexOf(b.source)
1083
+ );
1084
+ }
1085
+ function hasError(messages) {
1086
+ return messages.some((message) => message.severity === "error");
1087
+ }
1088
+
1089
+ // src/text.ts
1090
+ function textParser(options = {}) {
1091
+ const { trim = false, uppercase = false } = options;
1092
+ return (text, { locale }) => {
1093
+ const trimmed = trim ? text.trim() : text;
1094
+ const value = uppercase ? trimmed.toLocaleUpperCase(locale) : trimmed;
1095
+ return parsed(value === "" ? null : value);
1096
+ };
1097
+ }
1098
+ function formatText(value) {
1099
+ return value ?? "";
1100
+ }
1101
+ function countCharacters(text) {
1102
+ return Array.from(text).length;
1103
+ }
1104
+ function counterAnnouncement(count, max, messages) {
1105
+ const left = max - count;
1106
+ if (left < 0) {
1107
+ return messages.charactersOver(-left);
1108
+ }
1109
+ return left <= max / 10 ? messages.charactersLeft(left) : null;
1110
+ }
1111
+
1112
+ // src/validation/validators.ts
1113
+ function requiredRule() {
1114
+ return (value, { messages }) => value === null || typeof value === "string" && value.trim() === "" ? { text: messages.required, code: "required" } : null;
1115
+ }
1116
+ function requiredChoiceRule() {
1117
+ return (value, { messages }) => value === null ? { text: messages.requiredChoice, code: "required" } : null;
1118
+ }
1119
+ function maxCountRule(max) {
1120
+ return (value, { messages }) => value !== null && value.length > max ? { text: messages.tooManyChoices(max), code: "tooManyChoices" } : null;
1121
+ }
1122
+ function minCountRule(min) {
1123
+ return (value, { messages }) => value !== null && value.length < min ? { text: messages.tooFewChoices(min), code: "tooFewChoices" } : null;
1124
+ }
1125
+ function minLengthRule(min) {
1126
+ return (value, { messages }) => value !== null && countCharacters(value) < min ? { text: messages.tooShort(min), code: "tooShort" } : null;
1127
+ }
1128
+ function maxLengthRule(max) {
1129
+ return (value, { messages }) => value !== null && countCharacters(value) > max ? { text: messages.tooLong(max), code: "tooLong" } : null;
1130
+ }
1131
+ function patternRule(pattern, message) {
1132
+ const whole = new RegExp(
1133
+ `^(?:${pattern.source})$`,
1134
+ pattern.flags.replace(/[gy]/g, "")
1135
+ );
1136
+ return (value, { messages }) => value !== null && !whole.test(value) ? { text: message ?? messages.patternMismatch, code: "pattern" } : null;
1137
+ }
1138
+ var EMAIL_ADDRESS = /^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/u;
1139
+ function emailRule() {
1140
+ return (value, { messages }) => value !== null && !EMAIL_ADDRESS.test(value) ? { text: messages.invalidEmail, code: "email" } : null;
1141
+ }
1142
+ function checkedRule(message) {
1143
+ return (value, context) => value === true ? null : { text: message(context.messages), code: "required" };
1144
+ }
1145
+ function runValidators(validators, value, context) {
1146
+ return validators.flatMap(
1147
+ (validator) => toFieldMessages(validator(value, context), "validate")
1148
+ );
1149
+ }
1150
+
1151
+ // src/choice/tags.ts
1152
+ var LINE_BREAK = /\r\n|\r|\n/u;
1153
+ function splitTags(text, separators) {
1154
+ let pieces = text.split(LINE_BREAK);
1155
+ for (const separator of separators) {
1156
+ if (separator !== "") {
1157
+ pieces = pieces.flatMap((piece) => piece.split(separator));
1158
+ }
1159
+ }
1160
+ return pieces;
1161
+ }
1162
+ function hasTagSeparator(text, separators) {
1163
+ return splitTags(text, separators).length > 1;
1164
+ }
1165
+ function missingTags(from, to) {
1166
+ const left = /* @__PURE__ */ new Map();
1167
+ for (const tag of to) {
1168
+ left.set(tag, (left.get(tag) ?? 0) + 1);
1169
+ }
1170
+ return from.filter((tag) => {
1171
+ const count = left.get(tag) ?? 0;
1172
+ if (count === 0) {
1173
+ return true;
1174
+ }
1175
+ left.set(tag, count - 1);
1176
+ return false;
1177
+ });
1178
+ }
1179
+ function tagDetails(value, previous, isInvalid, pending) {
1180
+ const now = value ?? [];
1181
+ const before = previous ?? [];
1182
+ return {
1183
+ added: missingTags(now, before),
1184
+ removed: missingTags(before, now),
1185
+ invalid: now.filter(isInvalid),
1186
+ pending
1187
+ };
1188
+ }
1189
+ function tagMessages(tag, validators, context) {
1190
+ return runValidators(validators, tag, { ...context, text: tag });
1191
+ }
1192
+ function isInvalidTag(tag, validators, context) {
1193
+ return tagMessages(tag, validators, context).some(
1194
+ (message) => message.severity === "error"
1195
+ );
1196
+ }
1197
+ var tagLists = /* @__PURE__ */ new Map();
1198
+ function tagList(locale) {
1199
+ const key = locale === void 0 ? "" : String(locale);
1200
+ let format = tagLists.get(key);
1201
+ if (format === void 0) {
1202
+ format = new Intl.ListFormat(locale, { type: "unit", style: "short" });
1203
+ tagLists.set(key, format);
1204
+ }
1205
+ return format;
1206
+ }
1207
+ function tagsRule(validators) {
1208
+ return (value, { locale, messages }) => {
1209
+ const invalid = (value ?? []).filter(
1210
+ (tag) => isInvalidTag(tag, validators, { locale, messages })
1211
+ );
1212
+ return invalid.length === 0 ? null : {
1213
+ text: messages.invalidTags(
1214
+ invalid.length,
1215
+ tagList(locale).format(invalid)
1216
+ ),
1217
+ code: "invalidTags"
1218
+ };
1219
+ };
1220
+ }
1221
+
1041
1222
  // src/choice/tree.ts
1042
1223
  function createTreeIndex(nodes) {
1043
1224
  const byKey = /* @__PURE__ */ new Map();
@@ -5193,112 +5374,6 @@ function inlineStep(key, direction = "ltr") {
5193
5374
  return null;
5194
5375
  }
5195
5376
 
5196
- // src/messages/severity.ts
5197
- var BY_SERIOUSNESS = [
5198
- "error",
5199
- "warning",
5200
- "info",
5201
- "success"
5202
- ];
5203
- function severityRank(severity) {
5204
- return BY_SERIOUSNESS.indexOf(severity);
5205
- }
5206
- function mostSevere(severities) {
5207
- const present = new Set(severities);
5208
- return BY_SERIOUSNESS.find((severity) => present.has(severity)) ?? null;
5209
- }
5210
-
5211
- // src/messages/fieldMessage.ts
5212
- var SOURCE_ORDER = [
5213
- "parse",
5214
- "commit",
5215
- "validate",
5216
- "app"
5217
- ];
5218
- function toFieldMessage(input, source, code = null) {
5219
- return typeof input === "string" ? { severity: "error", text: input, code, source } : {
5220
- severity: input.severity ?? "error",
5221
- text: input.text,
5222
- code: input.code ?? code,
5223
- source
5224
- };
5225
- }
5226
- function toFieldMessages(input, source) {
5227
- if (input === null || input === void 0) {
5228
- return [];
5229
- }
5230
- return isList(input) ? input.map((entry2) => toFieldMessage(entry2, source)) : [toFieldMessage(input, source)];
5231
- }
5232
- function isList(input) {
5233
- return Array.isArray(input);
5234
- }
5235
- function sortFieldMessages(messages) {
5236
- return messages.toSorted(
5237
- (a, b) => severityRank(a.severity) - severityRank(b.severity) || SOURCE_ORDER.indexOf(a.source) - SOURCE_ORDER.indexOf(b.source)
5238
- );
5239
- }
5240
- function hasError(messages) {
5241
- return messages.some((message) => message.severity === "error");
5242
- }
5243
-
5244
- // src/text.ts
5245
- function textParser(options = {}) {
5246
- const { trim = false, uppercase = false } = options;
5247
- return (text, { locale }) => {
5248
- const trimmed = trim ? text.trim() : text;
5249
- const value = uppercase ? trimmed.toLocaleUpperCase(locale) : trimmed;
5250
- return parsed(value === "" ? null : value);
5251
- };
5252
- }
5253
- function formatText(value) {
5254
- return value ?? "";
5255
- }
5256
- function countCharacters(text) {
5257
- return Array.from(text).length;
5258
- }
5259
- function counterAnnouncement(count, max, messages) {
5260
- const left = max - count;
5261
- if (left < 0) {
5262
- return messages.charactersOver(-left);
5263
- }
5264
- return left <= max / 10 ? messages.charactersLeft(left) : null;
5265
- }
5266
-
5267
- // src/validation/validators.ts
5268
- function requiredRule() {
5269
- return (value, { messages }) => value === null || typeof value === "string" && value.trim() === "" ? { text: messages.required, code: "required" } : null;
5270
- }
5271
- function requiredChoiceRule() {
5272
- return (value, { messages }) => value === null ? { text: messages.requiredChoice, code: "required" } : null;
5273
- }
5274
- function maxCountRule(max) {
5275
- return (value, { messages }) => value !== null && value.length > max ? { text: messages.tooManyChoices(max), code: "tooManyChoices" } : null;
5276
- }
5277
- function minCountRule(min) {
5278
- return (value, { messages }) => value !== null && value.length < min ? { text: messages.tooFewChoices(min), code: "tooFewChoices" } : null;
5279
- }
5280
- function minLengthRule(min) {
5281
- return (value, { messages }) => value !== null && countCharacters(value) < min ? { text: messages.tooShort(min), code: "tooShort" } : null;
5282
- }
5283
- function maxLengthRule(max) {
5284
- return (value, { messages }) => value !== null && countCharacters(value) > max ? { text: messages.tooLong(max), code: "tooLong" } : null;
5285
- }
5286
- function patternRule(pattern, message) {
5287
- const whole = new RegExp(
5288
- `^(?:${pattern.source})$`,
5289
- pattern.flags.replace(/[gy]/g, "")
5290
- );
5291
- return (value, { messages }) => value !== null && !whole.test(value) ? { text: message ?? messages.patternMismatch, code: "pattern" } : null;
5292
- }
5293
- function checkedRule(message) {
5294
- return (value, context) => value === true ? null : { text: message(context.messages), code: "required" };
5295
- }
5296
- function runValidators(validators, value, context) {
5297
- return validators.flatMap(
5298
- (validator) => toFieldMessages(validator(value, context), "validate")
5299
- );
5300
- }
5301
-
5302
5377
  // src/field/state.ts
5303
5378
  var CURRENT_DRAFT = { kind: "current" };
5304
5379
  var IDLE_PHASE = { kind: "idle" };
@@ -7642,6 +7717,7 @@ function createDefaultFormsMessages(locale) {
7642
7717
  ibanInvalid: "Enter a valid IBAN",
7643
7718
  cardNumberInvalid: "Enter a valid card number",
7644
7719
  ipv4Invalid: "Enter a valid IPv4 address",
7720
+ invalidEmail: "Enter a valid email address",
7645
7721
  counter: (count, max) => `${n(count)}/${n(max)}`,
7646
7722
  counterLabel: (max) => `Up to ${counted(n, max, characters)}`,
7647
7723
  charactersLeft: (left) => `${counted(n, left, characters)} left`,
@@ -7676,6 +7752,10 @@ function createDefaultFormsMessages(locale) {
7676
7752
  tooManyChoices: (max) => `Choose no more than ${n(max)}`,
7677
7753
  tooFewChoices: (min) => `Choose at least ${n(min)}`,
7678
7754
  maxChoicesReached: (max) => max === 1 ? "Up to 1 choice" : `Up to ${n(max)} choices`,
7755
+ tagEntries: "Entries",
7756
+ duplicateTag: (tag) => `\u201C${tag}\u201D is already added`,
7757
+ invalidTags: (count, tags) => count === 1 ? `1 entry is not valid: ${tags}` : `${n(count)} entries are not valid: ${tags}`,
7758
+ notValid: "not valid",
7679
7759
  severityLabel: (severity) => SEVERITY_LABELS[severity],
7680
7760
  severityCount: (severity, count) => counted(n, count, SEVERITY_NOUNS[severity]),
7681
7761
  messageSummaryTitle: (count) => count === 1 ? "There is 1 problem with this form" : `There are ${n(count)} problems with this form`
@@ -9400,6 +9480,7 @@ export {
9400
9480
  durationDetails,
9401
9481
  durationFormatter,
9402
9482
  durationParser,
9483
+ emailRule,
9403
9484
  endOfMonth,
9404
9485
  endsRule,
9405
9486
  exactInstantOf,
@@ -9441,6 +9522,7 @@ export {
9441
9522
  formatWeekday,
9442
9523
  hasError,
9443
9524
  hasKey,
9525
+ hasTagSeparator,
9444
9526
  ibanRule,
9445
9527
  idleSegments,
9446
9528
  inlineStep,
@@ -9457,6 +9539,7 @@ export {
9457
9539
  isCalendarMonthDisabled,
9458
9540
  isDecimalString,
9459
9541
  isInstant,
9542
+ isInvalidTag,
9460
9543
  isLandingRow,
9461
9544
  isLeapYear,
9462
9545
  isPeriod,
@@ -9588,6 +9671,7 @@ export {
9588
9671
  spanOf,
9589
9672
  splitDateTime,
9590
9673
  splitSegments,
9674
+ splitTags,
9591
9675
  standInOption,
9592
9676
  startOfDayIn,
9593
9677
  startOfMonth,
@@ -9597,6 +9681,9 @@ export {
9597
9681
  stepRule,
9598
9682
  subtractDecimals,
9599
9683
  summarizeMessages,
9684
+ tagDetails,
9685
+ tagMessages,
9686
+ tagsRule,
9600
9687
  textParser,
9601
9688
  tickNode,
9602
9689
  tickState,