@altimateai/ui-components 0.0.4-beta.2 → 0.0.5-beta.1

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.
@@ -157,22 +157,153 @@ export const ComboboxExample: StoryFn = () => {
157
157
 
158
158
  const [value, setValue] = useState("");
159
159
 
160
+ const handleChange = (newValue: string | string[]) => {
161
+ setValue(newValue as string);
162
+ };
163
+
160
164
  return (
161
165
  <div className="al-flex al-flex-col al-gap-4 al-justify-start al-items-start">
166
+ <h3 className="al-text-lg al-font-medium">Single Select</h3>
162
167
  <Combobox
163
168
  options={options}
164
169
  value={value}
165
- onChange={setValue}
170
+ onChange={handleChange}
166
171
  placeholder="Select framework..."
167
172
  />
168
173
 
169
174
  <Combobox
170
175
  options={options}
171
176
  value={value}
172
- onChange={setValue}
177
+ onChange={handleChange}
173
178
  placeholder="Custom width..."
174
179
  buttonProps={{ className: "al-w-[300px]" }}
175
180
  />
181
+
182
+ <Combobox
183
+ options={options}
184
+ value={value}
185
+ onChange={handleChange}
186
+ placeholder="With icon..."
187
+ icon={<DatabaseIcon className="al-mr-2" />}
188
+ />
176
189
  </div>
177
190
  );
178
191
  };
192
+
193
+ export const ComboboxMultiSelectExample: StoryFn = () => {
194
+ const options = [
195
+ { value: "react", label: "React" },
196
+ { value: "vue", label: "Vue" },
197
+ { value: "angular", label: "Angular" },
198
+ { value: "svelte", label: "Svelte" },
199
+ { value: "nextjs", label: "Next.js" },
200
+ { value: "remix", label: "Remix" },
201
+ { value: "gatsby", label: "Gatsby" },
202
+ { value: "ember", label: "Ember.js" },
203
+ ];
204
+
205
+ const [selectedValues, setSelectedValues] = useState<string[]>([]);
206
+ const [selectedValuesWithApply, setSelectedValuesWithApply] = useState<string[]>([
207
+ "react",
208
+ "vue",
209
+ ]);
210
+
211
+ const handleMultiSelectChange = (newValue: string | string[]) => {
212
+ setSelectedValues(Array.isArray(newValue) ? newValue : []);
213
+ };
214
+
215
+ const handleMultiSelectWithApplyChange = (newValue: string | string[]) => {
216
+ setSelectedValuesWithApply(Array.isArray(newValue) ? newValue : []);
217
+ };
218
+
219
+ return (
220
+ <div className="al-flex al-flex-col al-gap-8 al-justify-start al-items-start">
221
+ <div className="al-flex al-flex-col al-gap-4">
222
+ <h3 className="al-text-lg al-font-medium">Multi-Select (Auto-Apply)</h3>
223
+ <p className="al-text-sm al-text-muted-foreground">
224
+ Changes are applied immediately when selecting/deselecting options
225
+ </p>
226
+ <Combobox
227
+ options={options}
228
+ value={selectedValues}
229
+ onChange={handleMultiSelectChange}
230
+ placeholder="Select frameworks..."
231
+ multiSelect={true}
232
+ buttonProps={{ className: "al-w-[250px]" }}
233
+ />
234
+ <div className="al-text-sm">
235
+ Selected: {selectedValues.length > 0 ? selectedValues.join(", ") : "None"}
236
+ </div>
237
+ </div>
238
+
239
+ <div className="al-flex al-flex-col al-gap-4">
240
+ <h3 className="al-text-lg al-font-medium">Multi-Select with Apply Button</h3>
241
+ <p className="al-text-sm al-text-muted-foreground">
242
+ Changes are only applied when clicking the Apply button
243
+ </p>
244
+ <Combobox
245
+ options={options}
246
+ value={selectedValuesWithApply}
247
+ onChange={handleMultiSelectWithApplyChange}
248
+ placeholder="Select frameworks..."
249
+ multiSelect={true}
250
+ showApplyButton={true}
251
+ buttonProps={{ className: "al-w-[250px]" }}
252
+ />
253
+ <div className="al-text-sm">
254
+ Selected:{" "}
255
+ {selectedValuesWithApply.length > 0 ? selectedValuesWithApply.join(", ") : "None"}
256
+ </div>
257
+ </div>
258
+
259
+ <div className="al-flex al-flex-col al-gap-4">
260
+ <h3 className="al-text-lg al-font-medium">Columns Selector Example</h3>
261
+ <p className="al-text-sm al-text-muted-foreground">
262
+ Similar to the UI shown in the screenshot
263
+ </p>
264
+ <ComboboxColumnsExample />
265
+ </div>
266
+ </div>
267
+ );
268
+ };
269
+
270
+ // Example that matches the UI in the screenshot
271
+ const ComboboxColumnsExample = () => {
272
+ const options = [
273
+ { value: "est_cost", label: "Est. Cost" },
274
+ { value: "exec_time", label: "Exec. Time" },
275
+ { value: "insights", label: "Insights" },
276
+ { value: "query_hash", label: "Query Hash" },
277
+ { value: "query_text", label: "Query Text" },
278
+ { value: "query_type", label: "Query Type" },
279
+ { value: "timestamp", label: "Timestamp" },
280
+ { value: "user", label: "User" },
281
+ ];
282
+
283
+ const [selectedColumns, setSelectedColumns] = useState<string[]>([
284
+ "est_cost",
285
+ "exec_time",
286
+ "insights",
287
+ "query_hash",
288
+ "query_text",
289
+ "query_type",
290
+ "timestamp",
291
+ "user",
292
+ ]);
293
+
294
+ const handleColumnsChange = (newValue: string | string[]) => {
295
+ setSelectedColumns(Array.isArray(newValue) ? newValue : []);
296
+ };
297
+
298
+ return (
299
+ <Combobox
300
+ options={options}
301
+ value={selectedColumns}
302
+ onChange={handleColumnsChange}
303
+ placeholder="Columns"
304
+ multiSelect={true}
305
+ showApplyButton={true}
306
+ buttonProps={{ className: "al-w-[200px]" }}
307
+ />
308
+ );
309
+ };
@@ -70,7 +70,10 @@ interface ChatbotProviderProps extends ChatbotProps {
70
70
  };
71
71
  contextOptions?: ContextOption[];
72
72
  isMarkdownResponse?: boolean;
73
- models?: string[];
73
+ models?: {
74
+ label: string;
75
+ value: string;
76
+ }[];
74
77
  }
75
78
  type InteractionType = "text" | "select" | "multiSelect" | "confirm";
76
79
  interface InteractionChoice {
@@ -130,7 +133,10 @@ interface ChatState {
130
133
  disableContext?: boolean;
131
134
  requestParams?: RequestInit;
132
135
  isMarkdownResponse?: boolean;
133
- models?: string[];
136
+ models?: {
137
+ label: string;
138
+ value: string;
139
+ }[];
134
140
  components?: {
135
141
  feedback?: ReactNode;
136
142
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altimateai/ui-components",
3
- "version": "0.0.4-beta.2",
3
+ "version": "0.0.5-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/AltimateAI/altimate-components.git"
@@ -52,4 +52,4 @@
52
52
  "react": "^17.0.0 || ^18.0.0",
53
53
  "react-dom": "^17.0.0 || ^18.0.0"
54
54
  }
55
- }
55
+ }