@abpjs/ui 0.2.0-next.12 → 0.2.0-next.13

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0-next.13
4
+
5
+ A prerelease under npm's `next` tag: pickers and names by language, for the `guard` area and the hosts.
6
+
7
+ - `SearchPicker`: one item picked from a searchable list (an ARIA combobox): a search as the person types, items
8
+ already known, an empty choice, making one from the text typed, every match bold (`Highlight`). `PersonPicker` (name
9
+ and @username, a `badge` for an agent's account) and `GroupPicker` take their `search` from the area or the host.
10
+ Their words are the labels' new `picker` group.
11
+ - `TranslatedInput`: a name in every language the host offers (`AbpHost.languages`, which gains `englishName`), the
12
+ reader's inline and the others behind a button counting them, each typed in its direction. Where the host has
13
+ `suggestNames(text, signal)` (`NameSuggestion`), names already translated are offered while typing. Its words are the
14
+ labels' new `translations` group.
15
+ - `@abpjs/ui/rules`: `toNamesValue(name, names, written)` and `fromNamesValue(value, written)` between a written name
16
+ with its other languages and the one map `TranslatedInput` edits.
17
+
3
18
  ## 0.2.0-next.12
4
19
 
5
20
  A prerelease under npm's `next` tag: lists served a page at a time.
package/dist/index.d.ts CHANGED
@@ -90,7 +90,43 @@ interface AbpLabels {
90
90
  /** Above a form with wrong fields, `{count}` of them (ICU plural). */
91
91
  formFix: string;
92
92
  queryList: QueryListLabels;
93
+ translations: TranslationsLabels;
94
+ picker: PickerLabels;
95
+ }
96
+ /** Strings of SearchPicker, PersonPicker and GroupPicker. `{count}` is filled in (ICU plural). */
97
+ interface PickerLabels {
98
+ placeholder: string;
99
+ searching: string;
100
+ noMatches: string;
101
+ /** Nothing to offer when nothing can be searched. */
102
+ noKnown: string;
103
+ /** Above the options: how many match what's typed. */
104
+ matches: string;
105
+ /** Above the options when there are more than shown. */
106
+ firstMatches: string;
107
+ searchPeople: string;
108
+ /** A person picker with no search: the people on the page. */
109
+ choosePerson: string;
110
+ noPeople: string;
111
+ noKnownPeople: string;
112
+ searchGroups: string;
113
+ noGroups: string;
114
+ }
115
+ declare const defaultPickerLabels: PickerLabels;
116
+ /** Strings of TranslatedInput. {name}, {filled}, {total}, {shown} are filled in by the component. */
117
+ interface TranslationsLabels {
118
+ /** Above the other languages' fields. */
119
+ title: string;
120
+ /** The button that opens them, for a screen reader. */
121
+ open: string;
122
+ /** The button's tooltip. */
123
+ count: string;
124
+ /** Under a language left empty: which name shows instead. */
125
+ missing: string;
126
+ /** The list of names already translated. */
127
+ suggestions: string;
93
128
  }
129
+ declare const defaultTranslationsLabels: TranslationsLabels;
94
130
  /** Strings of QueryableList. {name} placeholders are filled in by the component. */
95
131
  interface QueryListLabels {
96
132
  savedView: string;
@@ -323,9 +359,18 @@ interface HostScope {
323
359
  /** One of the site's languages, for names by language. */
324
360
  interface HostLanguage {
325
361
  code: string;
362
+ /** Its name in itself ("العربية"). */
326
363
  name: string;
364
+ /** Its name in English, shown beside `name` where they differ. */
365
+ englishName?: string;
327
366
  direction?: 'ltr' | 'rtl';
328
367
  }
368
+ /** A name someone already translated (a text of the host's, a setting's name): every language at once. */
369
+ interface NameSuggestion {
370
+ names: Record<string, string>;
371
+ /** Where it comes from, as the host words it ("Status · FIN"). */
372
+ source?: string;
373
+ }
329
374
  /**
330
375
  * What a host gives the screens (ADR 0109 amendment): how to call its server, where each package's API is, how to
331
376
  * move, what the person may do, its scopes and people, its languages, its words for any text, and the slots it fills.
@@ -354,6 +399,8 @@ interface AbpHost {
354
399
  names?: (accountIds: string[]) => Promise<Record<string, string>>;
355
400
  /** The site's languages, the first the default. */
356
401
  languages?: HostLanguage[];
402
+ /** Names already translated that start with what's typed, so a name is translated the same way everywhere. */
403
+ suggestNames?: (text: string, signal: AbortSignal) => Promise<NameSuggestion[]>;
357
404
  /** The host's words for any area's text, by area then language then key: `{ ai: { en: { 'models.title': 'AI models' } } }`. */
358
405
  texts?: Record<string, Record<string, Record<string, string>>>;
359
406
  /**
@@ -484,6 +531,102 @@ declare function ColorModeToggle({ size }: {
484
531
  size?: 'xs' | 'sm' | 'md';
485
532
  }): react.JSX.Element;
486
533
 
534
+ type NamesValue = Record<string, string>;
535
+ interface TranslatedInputProps {
536
+ /** Names by language code. */
537
+ value: NamesValue;
538
+ onChange: (value: NamesValue) => void;
539
+ /** Shown when nothing is given in a language, and the last resort for what shows (usually the object's key). */
540
+ fallback?: string;
541
+ 'aria-label'?: string;
542
+ placeholder?: string;
543
+ size?: 'xs' | 'sm' | 'md';
544
+ disabled?: boolean;
545
+ autoFocus?: boolean;
546
+ onBlur?: () => void;
547
+ /** Offer names already translated while typing (the host's `suggestNames`; default on where the host has it). */
548
+ suggest?: boolean;
549
+ }
550
+ /**
551
+ * A name in every language the site offers (the host's `languages`): the reader's language inline, the others behind a
552
+ * button that shows how many are filled in. Each language is typed in its own direction, and one left empty says which
553
+ * name shows instead. Where the host offers names already translated (`suggestNames`), typing lists them, and picking
554
+ * one fills in every language at once, so a name is translated the same way everywhere. A host with no languages gets
555
+ * one field.
556
+ */
557
+ declare function TranslatedInput({ value, onChange, fallback, 'aria-label': ariaLabel, placeholder, size, disabled, autoFocus, onBlur, suggest, }: TranslatedInputProps): react.JSX.Element;
558
+
559
+ /**
560
+ * A text with the part matching what was typed in bold, every match, ignoring case; as it was when nothing is typed or
561
+ * nothing matches.
562
+ */
563
+ declare function Highlight({ text, query }: {
564
+ text: string;
565
+ query: string;
566
+ }): react.JSX.Element;
567
+ interface SearchPickerMessages {
568
+ placeholder: string;
569
+ searching: string;
570
+ noMatches: string;
571
+ noKnown: string;
572
+ /** Under the list when nothing can be searched and only `known` is offered. */
573
+ limitedHint?: string;
574
+ }
575
+ interface SearchPickerProps<T> {
576
+ value: T | null;
577
+ onChange: (item: T | null) => void;
578
+ /** Searches as the person types; null when there's nothing to search, and only `known` is offered. */
579
+ search: ((text: string) => Promise<T[]>) | null;
580
+ /** Items to offer without searching (people on the page…), filtered by the text typed. */
581
+ known?: T[];
582
+ getId: (item: T) => string;
583
+ /** The text the input shows for the chosen item, and what typing filters `known` by. */
584
+ label: (item: T) => string;
585
+ /** How an option reads in the list (with what's typed, to bold its match: `Highlight`); the label, its match bold, by default. */
586
+ renderOption?: (item: T, query: string) => ReactNode;
587
+ /**
588
+ * Making a new item from the text typed, offered last when no option is called just that ("Add “Acme” as a new
589
+ * vendor"); it resolves with the item made, which is then picked, or null when it wasn't.
590
+ */
591
+ create?: {
592
+ label: (text: string) => string;
593
+ onCreate: (text: string) => Promise<T | null>;
594
+ };
595
+ /** Offer an empty choice ("Unassigned"). */
596
+ clearLabel?: string;
597
+ /** With nothing picked, the closed input shows the placeholder rather than the empty choice's words. */
598
+ emptyShowsPlaceholder?: boolean;
599
+ /** The picker's words; the labels' `picker` defaults where not given. */
600
+ messages?: Partial<SearchPickerMessages>;
601
+ disabled?: boolean;
602
+ size?: 'sm' | 'md';
603
+ 'aria-label'?: string;
604
+ id?: string;
605
+ }
606
+ /** One item picked from a searchable list: an ARIA combobox with keyboard support. */
607
+ declare function SearchPicker<T>({ value, onChange, search, known, getId, label, renderOption, create, clearLabel, emptyShowsPlaceholder, messages: own, disabled, size, id, 'aria-label': ariaLabel, }: SearchPickerProps<T>): react.JSX.Element;
608
+ /** A person to pick: an account's id, username and name, and whether it's an agent's. */
609
+ interface PickerPerson {
610
+ id: string;
611
+ username: string;
612
+ displayName?: string | null;
613
+ }
614
+ /** A group (a team) to pick. */
615
+ interface PickerGroup {
616
+ id: string;
617
+ name: string;
618
+ }
619
+ declare const personLabel: (p: PickerPerson | null | undefined) => string;
620
+ /**
621
+ * Picks one person: their name and @username, searched by `search` (the area's call, or the host's); without one, the
622
+ * people already `known` on the page. `badge` marks a person where the host has something to say (an agent's account).
623
+ */
624
+ declare function PersonPicker<P extends PickerPerson>({ badge, messages, ...rest }: Omit<SearchPickerProps<P>, 'getId' | 'label' | 'renderOption'> & {
625
+ badge?: (person: P) => ReactNode;
626
+ }): react.JSX.Element;
627
+ /** Picks one group, searched by `search` (the area's call, or the host's). */
628
+ declare function GroupPicker<G extends PickerGroup>({ messages, ...rest }: Omit<SearchPickerProps<G>, 'getId' | 'label'>): react.JSX.Element;
629
+
487
630
  type Direction = 'ltr' | 'rtl';
488
631
  /** Text direction for a BCP 47 locale ("ar", "ar-SA" -> rtl). */
489
632
  declare function directionOf(locale: string): Direction;
@@ -2904,4 +3047,4 @@ interface TooltipProps extends Omit<Tooltip$1.RootProps, 'children'> {
2904
3047
  */
2905
3048
  declare const Tooltip: react.ForwardRefExoticComponent<TooltipProps & react.RefAttributes<HTMLDivElement>>;
2906
3049
 
2907
- export { ABP_UI_VERSION, AbpApiError, type AbpBrand, type AbpHost, type AbpLabels, type AbpListOptions, AbpProvider, type AbpProviderProps, type AbpSystemOptions, type ApiQuery, AppLink, type AppLinkProps, AppShell, type AppShellBrand, type AppShellNavItem, type AppShellNavSection, type AppShellPlace, type AppShellProps, type AppShellSidebar, type AreaTexts, type Arrival, ArriveOnChange, type ArriveOnChangeProps, AttentionChip, type AttentionChipProps, type AvatarPerson, AvatarStack, type AvatarStackProps, Bone, type BoneProps, type BreadcrumbItem, Breadcrumbs, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CalendarGrid, type CalendarGridProps, type CalendarItem, type CardDates, CategoryProgress, type CategoryProgressProps, type CelebrateTarget, Chart, type ChartProps, type ChartSeries, CheckboxField, type CheckboxFieldProps, Collapse, type CollapseProps, type ColorMode, ColorModeProvider, ColorModeToggle, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, ConfirmDialog, type ConfirmDialogProps, type ConfirmOptions, ConfirmProvider, CountBadge, type CountBadgeProps, Counter, type CounterProps, DEFAULT_PAGE_SIZE, DashboardGrid, type DashboardGridProps, DataTable, type DataTableColumn, type DataTableProps, type DataTableSelection, type DataTableSort, type Direction, DirectionalIcon, DropHint, type DropHintProps, type DropZoneOptions, type DropZoneState, type DroppedFile, EMPTY_VALUE, EmptyState, type EmptyStateProps, FadeIn, type FadeInProps, Field, type FieldProps, FileDropArea, type FileDropAreaProps, FormDialog, type FormDialogProps, FormField, type GridItem, HighlightText, type HostEventHandler, type HostEvents, type HostFile, type HostLanguage, HostProvider, type HostRequest, type HostRequestInit, type HostRequestOptions, type HostScope, HostSlot, IconButton, type IconButtonProps, IconTile, type IconTileProps, Indicator, type IndicatorProps, InlineAlert, type InlineAlertProps, KanbanBoard, type KanbanBoardProps, type KanbanColumn, type KanbanItem, type KanbanLane, type KanbanMove, type LinkComponent, type ListPage, type ListQuery, type ListSource, type ListState, Loading, type LoadingProps, LoadingState, MotionProvider, type MotionSetting, type MotionState, Nudge, type NudgeProps, PageHeader, type PageHeaderProps, PageTitleProvider, Pagination, type PaginationProps, Panel, type PanelProps, PanelTone, type Particle, PathChips, type PathChipsProps, PersonChip, type PersonChipProps, type PlacedCard, PluginTextsProvider, type Pose, Presence, PresenceItem, type PresenceItemProps, PresenceList, type PresenceListProps, type PresenceProps, Pressable, type PressableProps, PriorityMark, type PriorityMarkProps, type PropertyItem, PropertyList, type PropertyListProps, type QueryConditionJson, type QueryExportFormat, type QueryField, type QueryGroup, type QueryJson, type QueryListLabels, type QueryNodeJson, type QueryRow, type QuerySuggestion, type QuerySuggestions, type QueryValueEditor, QueryableList, type QueryableListError, type QueryableListExport, type QueryableListProps, type QueryableListState, type QueryableListView, type QueueProgress, RecordKey, type RecordKeyProps, type RegisterSlotSave, Reveal, RevealItem, type RevealItemProps, type RevealProps, SHOWN, STEP_UP_REQUIRED, STRONG_FACTOR_REQUIRED, type Scale, SearchInput, type SearchInputProps, type SectionMove, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SelectField, type SelectFieldProps, type SelectOption, type SettingsArea, SettingsLayout, type SettingsLayoutProps, type SettingsPage, type SettingsSection, SlideItem, type SlideItemProps, SlideList, type SlideListProps, type SlotSave, type SortDirection, type SortableSection, SortableSections, type SortableSectionsProps, type StatusCategory, StatusPill, type StatusPillProps, type StatusTone, StepUpDialog, type StepUpHandler, type StepUpNeed, Swap, type SwapProps, SwitchField, type SwitchFieldProps, TITLE_SEPARATOR, TextBone, type TextBoneProps, TextSlot, type TextSlotProps, type TimelineCardItem, TimelineCards, type TimelineCardsProps, TimelineChart, type TimelineChartProps, type TimelineItem, type TimelineRow, type TimelineScale, type TitleParts, Toaster, Tooltip, type TooltipProps, UPLOADS_AT_ONCE, type UploadJob, UploadList, type UploadListProps, type UploadRow, type UploadState, abpConfig, abpListParams, abpListSource, arriveCss, asMotionSetting, avatarPalette, basicConditions, boneWidth, burst, compactLayout, compareOrdinal, composeTitle, covers, createAbpSystem, createAreaTexts, createHostEvents, createHostRequest, createPasskey, curves, defaultBrand, defaultLabels, defaultQueryListLabels, directionOf, droppedFiles, emptyQuery, errorText, fileNameOf, findSettingsPage, folderOf, foldersFor, formatDateTime, formatMessage, formatNumber, getPasskey, ghostCss, groupKey, heavierFirst, hiddenPose, inSections, isStepUp, looksLikeCode, durations as motionDurations, needsStepUp, notify, pageCount, pageList, partsOf, passkeysSupported, pastedName, placeCards, placeItem, priorityLevel, progressOf, readAbpError, readEvents, refusal, requestStepUp, setStepUpHandler, settingsArea, shineCss, springs, staggerDelay, stepUpNeedOf, targetOf, toStart, toaster, useAbpLabels, useAbpLocale, useAbpTimeZone, useApiAction, useApiDownload, useApiQuery, useAreaEvents, useAreaListSource, useAreaRequest, useArriving, useCan, useCelebrate, useColorMode, useConfirm, useDropZone, useFilesOverPage, useFormatters, useHost, useHostLanguages, useLinkComponent, useListState, useLoading, useMe, useMotionSetting, useNames, useNavigate, useOptionalHost, usePageDrop, usePageTitle, usePageTitleParts, usePageTitleSite, usePastedFiles, usePluginTexts, useProductName, useSlotSaves, useTokenVar };
3050
+ export { ABP_UI_VERSION, AbpApiError, type AbpBrand, type AbpHost, type AbpLabels, type AbpListOptions, AbpProvider, type AbpProviderProps, type AbpSystemOptions, type ApiQuery, AppLink, type AppLinkProps, AppShell, type AppShellBrand, type AppShellNavItem, type AppShellNavSection, type AppShellPlace, type AppShellProps, type AppShellSidebar, type AreaTexts, type Arrival, ArriveOnChange, type ArriveOnChangeProps, AttentionChip, type AttentionChipProps, type AvatarPerson, AvatarStack, type AvatarStackProps, Bone, type BoneProps, type BreadcrumbItem, Breadcrumbs, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CalendarGrid, type CalendarGridProps, type CalendarItem, type CardDates, CategoryProgress, type CategoryProgressProps, type CelebrateTarget, Chart, type ChartProps, type ChartSeries, CheckboxField, type CheckboxFieldProps, Collapse, type CollapseProps, type ColorMode, ColorModeProvider, ColorModeToggle, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, ConfirmDialog, type ConfirmDialogProps, type ConfirmOptions, ConfirmProvider, CountBadge, type CountBadgeProps, Counter, type CounterProps, DEFAULT_PAGE_SIZE, DashboardGrid, type DashboardGridProps, DataTable, type DataTableColumn, type DataTableProps, type DataTableSelection, type DataTableSort, type Direction, DirectionalIcon, DropHint, type DropHintProps, type DropZoneOptions, type DropZoneState, type DroppedFile, EMPTY_VALUE, EmptyState, type EmptyStateProps, FadeIn, type FadeInProps, Field, type FieldProps, FileDropArea, type FileDropAreaProps, FormDialog, type FormDialogProps, FormField, type GridItem, GroupPicker, Highlight, HighlightText, type HostEventHandler, type HostEvents, type HostFile, type HostLanguage, HostProvider, type HostRequest, type HostRequestInit, type HostRequestOptions, type HostScope, HostSlot, IconButton, type IconButtonProps, IconTile, type IconTileProps, Indicator, type IndicatorProps, InlineAlert, type InlineAlertProps, KanbanBoard, type KanbanBoardProps, type KanbanColumn, type KanbanItem, type KanbanLane, type KanbanMove, type LinkComponent, type ListPage, type ListQuery, type ListSource, type ListState, Loading, type LoadingProps, LoadingState, MotionProvider, type MotionSetting, type MotionState, type NameSuggestion, type NamesValue, Nudge, type NudgeProps, PageHeader, type PageHeaderProps, PageTitleProvider, Pagination, type PaginationProps, Panel, type PanelProps, PanelTone, type Particle, PathChips, type PathChipsProps, PersonChip, type PersonChipProps, PersonPicker, type PickerGroup, type PickerLabels, type PickerPerson, type PlacedCard, PluginTextsProvider, type Pose, Presence, PresenceItem, type PresenceItemProps, PresenceList, type PresenceListProps, type PresenceProps, Pressable, type PressableProps, PriorityMark, type PriorityMarkProps, type PropertyItem, PropertyList, type PropertyListProps, type QueryConditionJson, type QueryExportFormat, type QueryField, type QueryGroup, type QueryJson, type QueryListLabels, type QueryNodeJson, type QueryRow, type QuerySuggestion, type QuerySuggestions, type QueryValueEditor, QueryableList, type QueryableListError, type QueryableListExport, type QueryableListProps, type QueryableListState, type QueryableListView, type QueueProgress, RecordKey, type RecordKeyProps, type RegisterSlotSave, Reveal, RevealItem, type RevealItemProps, type RevealProps, SHOWN, STEP_UP_REQUIRED, STRONG_FACTOR_REQUIRED, type Scale, SearchInput, type SearchInputProps, SearchPicker, type SearchPickerMessages, type SearchPickerProps, type SectionMove, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SelectField, type SelectFieldProps, type SelectOption, type SettingsArea, SettingsLayout, type SettingsLayoutProps, type SettingsPage, type SettingsSection, SlideItem, type SlideItemProps, SlideList, type SlideListProps, type SlotSave, type SortDirection, type SortableSection, SortableSections, type SortableSectionsProps, type StatusCategory, StatusPill, type StatusPillProps, type StatusTone, StepUpDialog, type StepUpHandler, type StepUpNeed, Swap, type SwapProps, SwitchField, type SwitchFieldProps, TITLE_SEPARATOR, TextBone, type TextBoneProps, TextSlot, type TextSlotProps, type TimelineCardItem, TimelineCards, type TimelineCardsProps, TimelineChart, type TimelineChartProps, type TimelineItem, type TimelineRow, type TimelineScale, type TitleParts, Toaster, Tooltip, type TooltipProps, TranslatedInput, type TranslatedInputProps, type TranslationsLabels, UPLOADS_AT_ONCE, type UploadJob, UploadList, type UploadListProps, type UploadRow, type UploadState, abpConfig, abpListParams, abpListSource, arriveCss, asMotionSetting, avatarPalette, basicConditions, boneWidth, burst, compactLayout, compareOrdinal, composeTitle, covers, createAbpSystem, createAreaTexts, createHostEvents, createHostRequest, createPasskey, curves, defaultBrand, defaultLabels, defaultPickerLabels, defaultQueryListLabels, defaultTranslationsLabels, directionOf, droppedFiles, emptyQuery, errorText, fileNameOf, findSettingsPage, folderOf, foldersFor, formatDateTime, formatMessage, formatNumber, getPasskey, ghostCss, groupKey, heavierFirst, hiddenPose, inSections, isStepUp, looksLikeCode, durations as motionDurations, needsStepUp, notify, pageCount, pageList, partsOf, passkeysSupported, pastedName, personLabel, placeCards, placeItem, priorityLevel, progressOf, readAbpError, readEvents, refusal, requestStepUp, setStepUpHandler, settingsArea, shineCss, springs, staggerDelay, stepUpNeedOf, targetOf, toStart, toaster, useAbpLabels, useAbpLocale, useAbpTimeZone, useApiAction, useApiDownload, useApiQuery, useAreaEvents, useAreaListSource, useAreaRequest, useArriving, useCan, useCelebrate, useColorMode, useConfirm, useDropZone, useFilesOverPage, useFormatters, useHost, useHostLanguages, useLinkComponent, useListState, useLoading, useMe, useMotionSetting, useNames, useNavigate, useOptionalHost, usePageDrop, usePageTitle, usePageTitleParts, usePageTitleSite, usePastedFiles, usePluginTexts, useProductName, useSlotSaves, useTokenVar };