@adamosuiteservices/ui 1.5.6 → 1.6.7

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.
@@ -1,35 +1,230 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ /**
3
+ * Represents a single option in the combobox.
4
+ */
1
5
  type ComboboxOption = {
6
+ /** Unique value identifier for the option */
2
7
  value: string;
8
+ /** Display text for the option */
3
9
  label: string;
10
+ /** Whether the option is disabled and cannot be selected */
4
11
  disabled?: boolean;
5
12
  };
13
+ /**
14
+ * Customizable text labels used throughout the combobox.
15
+ */
6
16
  type ComboboxLabels = {
17
+ /** Text shown when no option is selected */
7
18
  placeholder?: string;
19
+ /** Placeholder text for the search input */
8
20
  searchPlaceholder?: string;
21
+ /** Message displayed when no options match the search */
9
22
  noItemsFound?: string;
23
+ /** Function to generate text when multiple items are selected. Receives the count of selected items. */
10
24
  multipleSelected?: (count: number) => string;
11
25
  };
26
+ /**
27
+ * CSS class names for customizing component styling.
28
+ */
12
29
  type ComboboxClassNames = {
30
+ /** Class name for the trigger button */
13
31
  trigger?: string;
32
+ /** Class name for the popover container */
14
33
  popover?: string;
34
+ /** Class name for the command component */
15
35
  command?: string;
36
+ /** Class name for the search input */
16
37
  input?: string;
38
+ /** Class name for the options list */
17
39
  list?: string;
40
+ /** Class name for the empty state message */
18
41
  empty?: string;
42
+ /** Class name for the option group */
19
43
  group?: string;
44
+ /** Class name for individual option items */
20
45
  item?: string;
46
+ /** Class name for checkbox elements */
21
47
  checkbox?: string;
48
+ /** Class name for check icon elements */
22
49
  check?: string;
23
50
  };
51
+ /**
52
+ * Render prop functions for customizing component rendering.
53
+ * Each render prop receives relevant data and allows complete control over that part of the UI.
54
+ */
55
+ type ComboboxRenderProps = {
56
+ /**
57
+ * Custom renderer for the entire trigger button.
58
+ * @param props.open - Whether the popover is open
59
+ * @param props.value - Current selected value(s)
60
+ * @param props.displayText - Formatted display text for selected value(s)
61
+ * @param props.placeholder - Placeholder text
62
+ * @param props.hasValue - Whether any value is selected
63
+ * @param props.icon - Optional icon component
64
+ * @param props.showIcon - Whether to show the icon
65
+ */
66
+ trigger?: (props: {
67
+ open: boolean;
68
+ value: string | string[];
69
+ displayText: string | null;
70
+ placeholder: string;
71
+ hasValue: boolean;
72
+ icon?: ComponentType<{
73
+ className?: string;
74
+ }>;
75
+ }) => ReactNode;
76
+ /**
77
+ * Custom renderer for the trigger dropdown icon.
78
+ * @param props.open - Whether the popover is open
79
+ */
80
+ triggerIcon?: (props: {
81
+ open: boolean;
82
+ }) => ReactNode;
83
+ /**
84
+ * Custom renderer for the placeholder text.
85
+ * @param props.text - The placeholder text
86
+ * @param props.hasValue - Whether any value is selected
87
+ */
88
+ placeholder?: (props: {
89
+ text: string;
90
+ hasValue: boolean;
91
+ }) => ReactNode;
92
+ /**
93
+ * Custom renderer for displaying selected value(s).
94
+ * @param props.text - Formatted display text
95
+ * @param props.value - Current selected value(s)
96
+ */
97
+ displayValue?: (props: {
98
+ text: string | null;
99
+ value: string | string[];
100
+ }) => ReactNode;
101
+ /**
102
+ * Custom renderer for an entire option item.
103
+ * @param props.option - The option data
104
+ * @param props.isSelected - Whether this option is currently selected
105
+ * @param props.selectedFeedback - Type of selection feedback ("checkbox" or "check")
106
+ */
107
+ option?: (props: {
108
+ option: ComboboxOption;
109
+ isSelected: boolean;
110
+ selectedFeedback: "checkbox" | "check";
111
+ }) => ReactNode;
112
+ /**
113
+ * Custom renderer for just the option label text.
114
+ * @param props.option - The option data
115
+ */
116
+ optionLabel?: (props: {
117
+ option: ComboboxOption;
118
+ }) => ReactNode;
119
+ /**
120
+ * Custom renderer for the selection feedback indicator (checkbox or check).
121
+ * @param props.option - The option data
122
+ * @param props.isSelected - Whether this option is currently selected
123
+ * @param props.type - Type of feedback indicator
124
+ */
125
+ selectedFeedback?: (props: {
126
+ option: ComboboxOption;
127
+ isSelected: boolean;
128
+ type: "checkbox" | "check";
129
+ }) => ReactNode;
130
+ /**
131
+ * Custom renderer for the empty state when no options match.
132
+ * @param props.text - The "no items found" message
133
+ */
134
+ empty?: (props: {
135
+ text: string;
136
+ }) => ReactNode;
137
+ /**
138
+ * Custom renderer for the search input field.
139
+ * @param props.placeholder - Placeholder text for the search input
140
+ */
141
+ searchInput?: (props: {
142
+ placeholder: string;
143
+ }) => ReactNode;
144
+ };
145
+ /**
146
+ * Props for the Combobox component.
147
+ */
24
148
  type ComboboxProps = Readonly<{
149
+ /** Enable search/filter functionality within the combobox */
25
150
  searchable?: boolean;
151
+ /** Allow multiple options to be selected simultaneously */
26
152
  multiple?: boolean;
153
+ /** Optional icon component to display in the trigger */
154
+ icon?: ComponentType<{
155
+ className?: string;
156
+ }>;
157
+ /** Controlled value for the combobox. Can be a single value or array of values for multiple selection. */
27
158
  value?: string | string[];
159
+ /** Callback fired when the selected value changes */
28
160
  onValueChange?: (value: string | string[]) => void;
161
+ /** Customizable text labels for various UI elements */
29
162
  labels?: ComboboxLabels;
163
+ /** Array of options to display in the combobox */
30
164
  options: ComboboxOption[];
165
+ /** CSS class names for styling various parts of the component */
31
166
  classNames?: ComboboxClassNames;
167
+ /** Type of selection feedback indicator to show ("checkbox" or "check") */
32
168
  selectedFeedback?: "checkbox" | "check";
169
+ /** Always show the placeholder text even when a value is selected. When enabled, both placeholder and value are displayed. */
170
+ alwaysShowPlaceholder?: boolean;
171
+ /** Position where the selected value is displayed when alwaysShowPlaceholder is true ("left" next to placeholder or "right" next to trigger icon) */
172
+ valuePosition?: "left" | "right";
173
+ /** Render prop functions for customizing component rendering */
174
+ renders?: ComboboxRenderProps;
33
175
  }>;
34
- declare function Combobox({ searchable, multiple, value: controlledValue, onValueChange, labels, options, classNames, selectedFeedback, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
176
+ /**
177
+ * A flexible combobox component with support for single/multiple selection, search, and extensive customization.
178
+ *
179
+ * @example
180
+ * ```tsx
181
+ * // Basic single select
182
+ * <Combobox
183
+ * options={[
184
+ * { value: "1", label: "Option 1" },
185
+ * { value: "2", label: "Option 2" },
186
+ * ]}
187
+ * value={value}
188
+ * onValueChange={setValue}
189
+ * />
190
+ *
191
+ * // Multiple select with search
192
+ * <Combobox
193
+ * multiple
194
+ * searchable
195
+ * options={options}
196
+ * value={selectedValues}
197
+ * onValueChange={setSelectedValues}
198
+ * labels={{
199
+ * placeholder: "Select items...",
200
+ * searchPlaceholder: "Search...",
201
+ * }}
202
+ * />
203
+ *
204
+ * // With custom rendering
205
+ * <Combobox
206
+ * options={options}
207
+ * value={value}
208
+ * onValueChange={setValue}
209
+ * renders={{
210
+ * optionLabel: ({ option }) => (
211
+ * <div className="flex items-center gap-2">
212
+ * <Avatar src={option.avatar} />
213
+ * <span>{option.label}</span>
214
+ * </div>
215
+ * ),
216
+ * }}
217
+ * />
218
+ *
219
+ * // Always show placeholder with value
220
+ * <Combobox
221
+ * alwaysShowPlaceholder
222
+ * options={options}
223
+ * value={value}
224
+ * onValueChange={setValue}
225
+ * labels={{ placeholder: "Country" }}
226
+ * />
227
+ * ```
228
+ */
229
+ declare function Combobox({ searchable, multiple, icon: Icon, value: controlledValue, onValueChange, labels, options, classNames, selectedFeedback, alwaysShowPlaceholder, valuePosition, renders, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
35
230
  export { Combobox };
@@ -25,3 +25,12 @@ export declare const ControlledMultiple: Story;
25
25
  export declare const CustomLabels: Story;
26
26
  export declare const CustomStyling: Story;
27
27
  export declare const InForm: Story;
28
+ export declare const WithIcon: Story;
29
+ export declare const AlwaysShowPlaceholder: Story;
30
+ export declare const AlwaysShowPlaceholderMultiple: Story;
31
+ export declare const CustomRendering: Story;
32
+ export declare const CustomTrigger: Story;
33
+ export declare const CustomEmptyState: Story;
34
+ export declare const CustomSelectedFeedback: Story;
35
+ export declare const WithIconAndPlaceholder: Story;
36
+ export declare const ValuePositionLeft: Story;