@jobber/components 8.4.0 → 8.6.0
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/Autocomplete/Autocomplete.d.ts +6 -4
- package/dist/Autocomplete/Autocomplete.types.d.ts +3 -137
- package/dist/Autocomplete/components/FloatingMenu.d.ts +6 -6
- package/dist/Autocomplete/components/MenuList.d.ts +4 -4
- package/dist/Autocomplete/components/PersistentRegion.d.ts +3 -3
- package/dist/Autocomplete/index.cjs +25 -1658
- package/dist/Autocomplete/index.d.ts +3 -30
- package/dist/Autocomplete/index.mjs +25 -1647
- package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +15 -15
- package/dist/Autocomplete/useAutocomplete.d.ts +2 -2
- package/dist/Autocomplete-cjs.js +1306 -0
- package/dist/Autocomplete-es.js +1304 -0
- package/dist/FormField/FormFieldTypes.d.ts +0 -7
- package/dist/InputDate/InputDate.types.d.ts +1 -1
- package/dist/InputEmail/InputEmail.types.d.ts +1 -1
- package/dist/InputNumber/InputNumber.types.d.ts +1 -1
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +1 -1
- package/dist/InputText/InputText.types.d.ts +1 -5
- package/dist/InputTime/InputTime.types.d.ts +1 -1
- package/dist/Menu-es.js +1 -1
- package/dist/MenuSubmenuTrigger-es.js +1 -1
- package/dist/Select/OptionGroup.d.ts +2 -2
- package/dist/Select/Select.types.d.ts +1 -1
- package/dist/docs/Autocomplete/{AutocompleteV2.md → Autocomplete.md} +13 -107
- package/dist/docs/Banner/Banner.md +3 -3
- package/dist/docs/Box/Box.md +2 -2
- package/dist/docs/Chips/Chips.md +1 -1
- package/dist/docs/DataList/DataList.md +1 -1
- package/dist/docs/FormField/FormField.md +0 -1
- package/dist/docs/Icon/Icon.md +1 -1
- package/dist/docs/InputGroup/InputGroup.md +1 -1
- package/dist/docs/InputPassword/InputPassword.md +0 -1
- package/dist/docs/Menu/Menu.md +1 -1
- package/dist/docs/Modal/Modal.md +3 -3
- package/dist/docs/MultiSelect/MultiSelect.md +1 -1
- package/dist/docs/index.md +1 -2
- package/dist/docs/usage-guidelines/usage-guidelines.md +13 -44
- package/dist/floating-ui.react-dom-es.js +1 -1
- package/dist/floating-ui.react-es.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.esm-es.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/sharedHelpers/types.d.ts +0 -4
- package/dist/styles.css +29 -153
- package/package.json +2 -2
- package/dist/Autocomplete/Autocomplete.rebuilt.d.ts +0 -8
- package/dist/Autocomplete/Autocomplete.utils.d.ts +0 -8
- package/dist/Autocomplete/Menu/DefaultMenu.d.ts +0 -16
- package/dist/Autocomplete/Menu/Menu.d.ts +0 -3
- package/dist/Autocomplete/Menu/MenuWrapper.d.ts +0 -23
- package/dist/Autocomplete/Option.d.ts +0 -78
- package/dist/Autocomplete/V1.docgen.d.ts +0 -4
- package/dist/Autocomplete/V2.docgen.d.ts +0 -6
- package/dist/Autocomplete/useKeyboardNavigation.d.ts +0 -35
- package/dist/Autocomplete/useRepositionMenu.d.ts +0 -10
- package/dist/docs/Autocomplete/AutocompleteV1.md +0 -1328
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { Ref
|
|
1
|
+
import type { Ref } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import
|
|
4
|
-
declare
|
|
5
|
-
|
|
3
|
+
import type { AutocompleteProps, OptionLike } from "./Autocomplete.types";
|
|
4
|
+
export declare const Autocomplete: <Value extends OptionLike = OptionLike, Multiple extends boolean = false>(props: AutocompleteProps<Value, Multiple> & {
|
|
5
|
+
ref?: Ref<HTMLInputElement | HTMLTextAreaElement>;
|
|
6
|
+
}) => ReturnType<typeof AutocompleteInternal>;
|
|
7
|
+
declare function AutocompleteInternal<Value extends OptionLike, Multiple extends boolean = false>(props: AutocompleteProps<Value, Multiple>, forwardedRef: Ref<HTMLInputElement | HTMLTextAreaElement>): React.JSX.Element;
|
|
6
8
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { CSSProperties, Key, Ref
|
|
1
|
+
import type { CSSProperties, Key, Ref } from "react";
|
|
2
2
|
import type { UseAutocompleteListNavReturn } from "./hooks/useAutocompleteListNav";
|
|
3
3
|
import type { createInteractionPointerDownHandler } from "./utils/interactionUtils";
|
|
4
4
|
import type { AriaInputProps, FocusEvents, HTMLInputBaseProps, RebuiltInputCommonProps } from "../sharedHelpers/types";
|
|
5
|
-
import type { FormFieldProps } from "../FormField";
|
|
6
5
|
import type { InputTextProps } from "../InputText";
|
|
7
6
|
/**
|
|
8
7
|
* ARIA attributes for Autocomplete with managed/orchestrated behavior.
|
|
@@ -12,139 +11,6 @@ import type { InputTextProps } from "../InputText";
|
|
|
12
11
|
interface AriaInputPropsManaged extends Omit<AriaInputProps, "aria-controls" | "aria-expanded" | "aria-activedescendant" | "aria-autocomplete"> {
|
|
13
12
|
}
|
|
14
13
|
export type ExtraProps = Record<string, unknown>;
|
|
15
|
-
type OptionValue = string | number;
|
|
16
|
-
export interface BaseOption {
|
|
17
|
-
label: string;
|
|
18
|
-
}
|
|
19
|
-
export interface Option extends BaseOption {
|
|
20
|
-
value?: OptionValue;
|
|
21
|
-
description?: string;
|
|
22
|
-
details?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface GroupOption extends BaseOption {
|
|
25
|
-
options: Option[];
|
|
26
|
-
}
|
|
27
|
-
export type OptionCollection = AnyOption[];
|
|
28
|
-
export type AnyOption<GenericOption extends Option | GroupOption = Option | GroupOption> = GenericOption;
|
|
29
|
-
export type OptionInGroup<T extends AnyOption> = T extends GroupOption ? T["options"][number] : T;
|
|
30
|
-
export interface AutocompleteBaseProps<GenericOption extends AnyOption = AnyOption, GenericOptionValue extends Option = Option, GenericGetOptionsValue extends AnyOption = AnyOption> extends Pick<FormFieldProps, "clearable" | "description" | "invalid" | "name" | "onBlur" | "onFocus" | "prefix" | "size" | "suffix"> {
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated
|
|
33
|
-
* Use `ref` instead.
|
|
34
|
-
*/
|
|
35
|
-
readonly inputRef?: FormFieldProps["inputRef"];
|
|
36
|
-
readonly initialOptions?: GenericOption[];
|
|
37
|
-
/**
|
|
38
|
-
* Set Autocomplete value.
|
|
39
|
-
*/
|
|
40
|
-
readonly value: GenericOptionValue | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Allow the autocomplete to use values not from the drop down menu.
|
|
43
|
-
*
|
|
44
|
-
* @default true
|
|
45
|
-
*/
|
|
46
|
-
readonly allowFreeForm?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Debounce in milliseconds for getOptions
|
|
49
|
-
*
|
|
50
|
-
* @default 300
|
|
51
|
-
*/
|
|
52
|
-
readonly debounce?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Simplified onChange handler that only provides the new value.
|
|
55
|
-
* @param newValue
|
|
56
|
-
*/
|
|
57
|
-
onChange(newValue?: GenericOptionValue): void;
|
|
58
|
-
/**
|
|
59
|
-
* Called as the user types in the input. The autocomplete will display what
|
|
60
|
-
* is returned from this method to the user as available options.
|
|
61
|
-
* @param newInputText
|
|
62
|
-
*/
|
|
63
|
-
getOptions(newInputText: string): Array<GenericGetOptionsValue | GenericOption> | Promise<Array<GenericGetOptionsValue | GenericOption>>;
|
|
64
|
-
/**
|
|
65
|
-
* Hint text that goes above the value once the form is filled out.
|
|
66
|
-
*/
|
|
67
|
-
readonly placeholder: string;
|
|
68
|
-
/**
|
|
69
|
-
* Override the content rendered in the menu.
|
|
70
|
-
*/
|
|
71
|
-
readonly customRenderMenu?: (props: CustomOptionsMenuProp<GenericOption | GenericGetOptionsValue, GenericOptionValue>) => React.ReactElement;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @deprecated Use the v2 Autocomplete component instead (version={2}).
|
|
75
|
-
*/
|
|
76
|
-
export interface AutocompleteLegacyProps<GenericOption extends AnyOption = AnyOption, GenericOptionValue extends Option = Option, GenericGetOptionsValue extends AnyOption = AnyOption> extends AutocompleteBaseProps<GenericOption, GenericOptionValue, GenericGetOptionsValue> {
|
|
77
|
-
/**
|
|
78
|
-
* Version of the component to use.
|
|
79
|
-
* @default 1
|
|
80
|
-
*/
|
|
81
|
-
readonly version?: 1;
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated
|
|
84
|
-
* Use `ref` instead.
|
|
85
|
-
*/
|
|
86
|
-
readonly inputRef?: FormFieldProps["inputRef"];
|
|
87
|
-
/**
|
|
88
|
-
* Initial options to display in the autocomplete.
|
|
89
|
-
*/
|
|
90
|
-
readonly initialOptions?: GenericOption[];
|
|
91
|
-
/**
|
|
92
|
-
* Called as the user types in the input. The autocomplete will display what
|
|
93
|
-
* is returned from this method to the user as available options.
|
|
94
|
-
* @param newInputText
|
|
95
|
-
*/
|
|
96
|
-
readonly getOptions: (newInputText: string) => Array<GenericGetOptionsValue | GenericOption> | Promise<Array<GenericGetOptionsValue | GenericOption>>;
|
|
97
|
-
}
|
|
98
|
-
export type AutocompleteProps<GenericOption extends AnyOption = AnyOption, GenericOptionValue extends Option = Option, GenericGetOptionsValue extends AnyOption = AnyOption> = AutocompleteLegacyProps<GenericOption, GenericOptionValue, GenericGetOptionsValue>;
|
|
99
|
-
export type CustomOptionsMenuType<GenericOption extends AnyOption = AnyOption> = (props: CustomOptionsMenuProp<GenericOption>) => React.ReactElement;
|
|
100
|
-
export interface MenuProps<GenericOption extends AnyOption = AnyOption, GenericOptionValue extends Option = Option> {
|
|
101
|
-
readonly options: GenericOption[];
|
|
102
|
-
readonly selectedOption?: GenericOptionValue;
|
|
103
|
-
readonly inputFocused: boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Element that the menu is attached to when the menu opens.
|
|
106
|
-
*/
|
|
107
|
-
readonly attachTo: HTMLDivElement | null;
|
|
108
|
-
/**
|
|
109
|
-
* Ref to the TextInput element.
|
|
110
|
-
*/
|
|
111
|
-
readonly inputRef: RefObject<HTMLInputElement | null>;
|
|
112
|
-
onOptionSelect(chosenOption?: GenericOptionValue): void;
|
|
113
|
-
readonly customRenderMenu?: (props: CustomOptionsMenuProp<GenericOption, GenericOptionValue>) => React.ReactElement;
|
|
114
|
-
}
|
|
115
|
-
export interface CustomOptionsMenuProp<GenericOption extends AnyOption = AnyOption, GenericOptionValue extends Option = Option> {
|
|
116
|
-
/**
|
|
117
|
-
* The options to display in the menu
|
|
118
|
-
*/
|
|
119
|
-
options: Array<OptionInGroup<GenericOption> | GenericOption>;
|
|
120
|
-
/**
|
|
121
|
-
* The currently selected option
|
|
122
|
-
*/
|
|
123
|
-
selectedOption?: GenericOptionValue;
|
|
124
|
-
/**
|
|
125
|
-
* The HTML element that wraps the menu content. Used for handling keyboard scroll behavior.
|
|
126
|
-
*/
|
|
127
|
-
readonly menuRef: HTMLElement | null | undefined;
|
|
128
|
-
/**
|
|
129
|
-
* Callback to select an option
|
|
130
|
-
*/
|
|
131
|
-
readonly onOptionSelect: (chosenOption?: GenericOptionValue) => void;
|
|
132
|
-
/**
|
|
133
|
-
* Determine if the input is focused. Can be used to conditionally render the menu.
|
|
134
|
-
*/
|
|
135
|
-
readonly inputFocused: boolean;
|
|
136
|
-
/**
|
|
137
|
-
* Ref to the TextInput element.
|
|
138
|
-
*/
|
|
139
|
-
readonly inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement | null>;
|
|
140
|
-
/**
|
|
141
|
-
* Component that wraps the menu content. Used for handling keyboard scroll behavior.
|
|
142
|
-
*/
|
|
143
|
-
readonly MenuWrapper: (props: {
|
|
144
|
-
children: React.ReactNode;
|
|
145
|
-
visible: boolean;
|
|
146
|
-
}) => React.ReactElement;
|
|
147
|
-
}
|
|
148
14
|
export interface OptionLike {
|
|
149
15
|
label: string;
|
|
150
16
|
/**
|
|
@@ -230,7 +96,7 @@ export type MenuFooter<Extra extends object = ExtraProps> = Extra & {
|
|
|
230
96
|
};
|
|
231
97
|
export type MenuItem<T extends OptionLike, SectionExtra extends object = ExtraProps, ActionExtra extends object = ExtraProps> = MenuSection<T, SectionExtra, ActionExtra> | MenuOptions<T, ActionExtra> | MenuHeader<ActionExtra> | MenuFooter<ActionExtra>;
|
|
232
98
|
export type AutocompleteValue<Value extends OptionLike, Multiple extends boolean> = Multiple extends true ? Value[] : Value | undefined;
|
|
233
|
-
interface
|
|
99
|
+
interface AutocompleteBaseProps<Value extends OptionLike, Multiple extends boolean, SectionExtra extends object, ActionExtra extends object> extends AriaInputPropsManaged, Pick<HTMLInputBaseProps, "name" | "disabled" | "readOnly" | "autoFocus">, Pick<RebuiltInputCommonProps, "placeholder" | "error" | "invalid" | "loading" | "clearable" | "description" | "size" | "prefix" | "suffix">, FocusEvents<HTMLInputElement | HTMLTextAreaElement> {
|
|
234
100
|
/**
|
|
235
101
|
* Whether the autocomplete allows multiple selections.
|
|
236
102
|
* When true, selected values are displayed as dismissible chips above the input.
|
|
@@ -486,7 +352,7 @@ interface FreeFormOn<Value extends OptionLike, Multiple extends boolean> {
|
|
|
486
352
|
readonly onChange: (value: AutocompleteValue<Value, Multiple>) => void;
|
|
487
353
|
}
|
|
488
354
|
export type ActionOrigin = "menu" | "empty";
|
|
489
|
-
export type
|
|
355
|
+
export type AutocompleteProps<Value extends OptionLike = OptionLike, Multiple extends boolean = false, SectionExtra extends object = ExtraProps, ActionExtra extends object = ExtraProps> = AutocompleteBaseProps<Value, Multiple, SectionExtra, ActionExtra> & (FreeFormOn<Value, Multiple> | FreeFormOff<Value, Multiple>);
|
|
490
356
|
export declare const menuOptions: <T extends OptionLike, ActionExtra extends object = ExtraProps>(options: T[], actions?: MenuAction<ActionExtra>[]) => MenuOptions<T, ActionExtra>;
|
|
491
357
|
export declare const menuSection: <T extends OptionLike, SectionExtra extends object = ExtraProps, ActionExtra extends object = ExtraProps>(label: string, options: T[], actions?: MenuAction<ActionExtra>[], extra?: SectionExtra) => MenuSection<T, SectionExtra, ActionExtra>;
|
|
492
358
|
export declare function defineMenu<T extends OptionLike, S extends object = ExtraProps, A extends object = ExtraProps>(menu: MenuItem<T, S, A>[]): MenuItem<T, S, A>[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { UseFloatingReturn, UseInteractionsReturn } from "@floating-ui/react";
|
|
3
|
-
import type { ActionConfig,
|
|
3
|
+
import type { ActionConfig, AutocompleteProps, MenuFooter, MenuHeader, OptionLike, RenderItem } from "../Autocomplete.types";
|
|
4
4
|
interface FloatingMenuProps<Value extends OptionLike> {
|
|
5
5
|
readonly context: UseFloatingReturn["context"];
|
|
6
6
|
readonly getFloatingProps: UseInteractionsReturn["getFloatingProps"];
|
|
@@ -27,11 +27,11 @@ interface FloatingMenuProps<Value extends OptionLike> {
|
|
|
27
27
|
readonly showEmptyStateMessage: boolean;
|
|
28
28
|
readonly emptyStateMessage?: React.ReactNode;
|
|
29
29
|
readonly customRenderLoading?: React.ReactNode;
|
|
30
|
-
readonly customRenderOption?:
|
|
31
|
-
readonly customRenderSection?:
|
|
32
|
-
readonly customRenderAction?:
|
|
33
|
-
readonly customRenderHeader?:
|
|
34
|
-
readonly customRenderFooter?:
|
|
30
|
+
readonly customRenderOption?: AutocompleteProps<Value, false>["customRenderOption"];
|
|
31
|
+
readonly customRenderSection?: AutocompleteProps<Value, false>["customRenderSection"];
|
|
32
|
+
readonly customRenderAction?: AutocompleteProps<Value, false>["customRenderAction"];
|
|
33
|
+
readonly customRenderHeader?: AutocompleteProps<Value, false>["customRenderHeader"];
|
|
34
|
+
readonly customRenderFooter?: AutocompleteProps<Value, false>["customRenderFooter"];
|
|
35
35
|
readonly slotOverrides?: {
|
|
36
36
|
option?: {
|
|
37
37
|
className?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ActionConfig,
|
|
2
|
+
import type { ActionConfig, AutocompleteProps, OptionLike, RenderItem } from "../Autocomplete.types";
|
|
3
3
|
interface MenuListProps<T extends OptionLike> {
|
|
4
4
|
readonly items: Array<RenderItem<T>>;
|
|
5
5
|
readonly activeIndex: number | null;
|
|
@@ -7,9 +7,9 @@ interface MenuListProps<T extends OptionLike> {
|
|
|
7
7
|
readonly getItemProps: (userProps?: Record<string, unknown>) => Record<string, unknown>;
|
|
8
8
|
readonly listRef: React.RefObject<Array<HTMLElement | null>>;
|
|
9
9
|
readonly listboxId: string;
|
|
10
|
-
readonly customRenderOption?:
|
|
11
|
-
readonly customRenderSection?:
|
|
12
|
-
readonly customRenderAction?:
|
|
10
|
+
readonly customRenderOption?: AutocompleteProps<T, false>["customRenderOption"];
|
|
11
|
+
readonly customRenderSection?: AutocompleteProps<T, false>["customRenderSection"];
|
|
12
|
+
readonly customRenderAction?: AutocompleteProps<T, false>["customRenderAction"];
|
|
13
13
|
readonly getOptionLabel: (option: T) => string;
|
|
14
14
|
readonly onSelect: (option: T) => void;
|
|
15
15
|
readonly onAction: (action: ActionConfig) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ActionConfig,
|
|
2
|
+
import type { ActionConfig, AutocompleteProps, MenuFooter, MenuHeader, OptionLike } from "../Autocomplete.types";
|
|
3
3
|
interface PersistentRegionProps<T extends OptionLike> {
|
|
4
4
|
readonly items: Array<MenuHeader<Record<string, unknown>> | MenuFooter<Record<string, unknown>>>;
|
|
5
5
|
readonly position: "header" | "footer";
|
|
@@ -8,8 +8,8 @@ interface PersistentRegionProps<T extends OptionLike> {
|
|
|
8
8
|
readonly listboxId?: string;
|
|
9
9
|
readonly getItemProps: (args?: Record<string, unknown>) => Record<string, unknown>;
|
|
10
10
|
readonly listRef: React.RefObject<Array<HTMLElement | null>>;
|
|
11
|
-
readonly customRenderHeader?:
|
|
12
|
-
readonly customRenderFooter?:
|
|
11
|
+
readonly customRenderHeader?: AutocompleteProps<T, false>["customRenderHeader"];
|
|
12
|
+
readonly customRenderFooter?: AutocompleteProps<T, false>["customRenderFooter"];
|
|
13
13
|
readonly className?: string;
|
|
14
14
|
readonly style?: React.CSSProperties;
|
|
15
15
|
readonly onAction: (action: ActionConfig) => void;
|