@showwhat/configurator 2.0.0 → 2.1.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/index.d.ts CHANGED
@@ -3,9 +3,17 @@ import { ClassValue } from 'clsx';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as React$1 from 'react';
5
5
  import React__default, { Component, ReactNode, ErrorInfo, ComponentType } from 'react';
6
- import { Select as Select$1, Separator as Separator$1, ScrollArea as ScrollArea$1, Dialog as Dialog$1, DropdownMenu as DropdownMenu$1, Label as Label$1, Switch as Switch$1, Popover as Popover$1, Tabs as Tabs$1 } from 'radix-ui';
6
+ import { Select as Select$1 } from '@base-ui/react/select';
7
+ import { Separator as Separator$1 } from '@base-ui/react/separator';
8
+ import { ScrollArea as ScrollArea$1 } from '@base-ui/react/scroll-area';
9
+ import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
10
+ import { Menu as Menu$1 } from '@base-ui/react/menu';
11
+ import { Switch as Switch$1 } from '@base-ui/react/switch';
12
+ import { Popover as Popover$1 } from '@base-ui/react/popover';
13
+ import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
7
14
 
8
15
  type DefinitionListProps = {
16
+ keys: string[];
9
17
  definitions: Definitions;
10
18
  selectedKey: string | null;
11
19
  validationErrors?: Record<string, unknown[]>;
@@ -16,8 +24,8 @@ type DefinitionListProps = {
16
24
  };
17
25
  type DefinitionListItemProps = {
18
26
  definitionKey: string;
19
- variationCount: number;
20
- isActive: boolean;
27
+ variationCount?: number;
28
+ isActive?: boolean;
21
29
  hasErrors: boolean;
22
30
  isSelected: boolean;
23
31
  isDirty?: boolean;
@@ -34,6 +42,9 @@ type DefinitionEditorProps = {
34
42
  onRename: (newKey: string) => void | Promise<void>;
35
43
  onSave?: () => void;
36
44
  onDiscard?: () => void;
45
+ onRemove?: () => void;
46
+ onExport?: (format: "yaml" | "json") => void;
47
+ onRefresh?: () => void;
37
48
  };
38
49
  type VariationListProps = {
39
50
  variations: Variation[];
@@ -63,7 +74,7 @@ type ConditionBlockProps = {
63
74
  errors?: ValidationIssueDisplay[];
64
75
  };
65
76
  type ConditionGroupProps = {
66
- type: "and" | "or";
77
+ type: "and" | "or" | "checkAnnotations";
67
78
  conditions: Condition[];
68
79
  onChange: (conditions: Condition[]) => void;
69
80
  onRemove: () => void;
@@ -139,10 +150,9 @@ declare function buttonVariants(opts?: {
139
150
  size?: ButtonSize;
140
151
  className?: string;
141
152
  }): string;
142
- declare function Button({ className, variant, size, asChild, ref, ...props }: React__default.ComponentProps<"button"> & {
153
+ declare function Button({ className, variant, size, ref, ...props }: React__default.ComponentProps<"button"> & {
143
154
  variant?: ButtonVariant;
144
155
  size?: ButtonSize;
145
- asChild?: boolean;
146
156
  }): react_jsx_runtime.JSX.Element;
147
157
 
148
158
  declare function Input({ className, type, ...props }: React__default.ComponentProps<"input">): react_jsx_runtime.JSX.Element;
@@ -153,8 +163,8 @@ declare function SelectValue({ ...props }: React__default.ComponentProps<typeof
153
163
  declare function SelectTrigger({ className, size, children, ...props }: React__default.ComponentProps<typeof Select$1.Trigger> & {
154
164
  size?: "sm" | "default";
155
165
  }): react_jsx_runtime.JSX.Element;
156
- declare function SelectContent({ className, children, position, align, ...props }: React__default.ComponentProps<typeof Select$1.Content>): react_jsx_runtime.JSX.Element;
157
- declare function SelectLabel({ className, ...props }: React__default.ComponentProps<typeof Select$1.Label>): react_jsx_runtime.JSX.Element;
166
+ declare function SelectContent({ className, children, ...props }: React__default.ComponentProps<typeof Select$1.Popup>): react_jsx_runtime.JSX.Element;
167
+ declare function SelectLabel({ className, ...props }: React__default.ComponentProps<typeof Select$1.GroupLabel>): react_jsx_runtime.JSX.Element;
158
168
  declare function SelectItem({ className, children, ...props }: React__default.ComponentProps<typeof Select$1.Item>): react_jsx_runtime.JSX.Element;
159
169
  declare function SelectSeparator({ className, ...props }: React__default.ComponentProps<typeof Select$1.Separator>): react_jsx_runtime.JSX.Element;
160
170
 
@@ -171,20 +181,21 @@ declare function badgeVariants(opts?: {
171
181
  variant?: BadgeVariant;
172
182
  className?: string;
173
183
  }): string;
174
- declare function Badge({ className, variant, asChild, ...props }: React__default.ComponentProps<"span"> & {
184
+ declare function Badge({ className, variant, ...props }: React__default.ComponentProps<"span"> & {
175
185
  variant?: BadgeVariant;
176
- asChild?: boolean;
177
186
  }): react_jsx_runtime.JSX.Element;
178
187
 
179
- declare function Separator({ className, orientation, decorative, ...props }: React__default.ComponentProps<typeof Separator$1.Root>): react_jsx_runtime.JSX.Element;
188
+ declare function Separator({ className, orientation, ...props }: React__default.ComponentProps<typeof Separator$1> & {
189
+ decorative?: boolean;
190
+ }): react_jsx_runtime.JSX.Element;
180
191
 
181
192
  declare function ScrollArea({ className, children, ...props }: React__default.ComponentProps<typeof ScrollArea$1.Root>): react_jsx_runtime.JSX.Element;
182
- declare function ScrollBar({ className, orientation, ...props }: React__default.ComponentProps<typeof ScrollArea$1.ScrollAreaScrollbar>): react_jsx_runtime.JSX.Element;
193
+ declare function ScrollBar({ className, orientation, ...props }: React__default.ComponentProps<typeof ScrollArea$1.Scrollbar>): react_jsx_runtime.JSX.Element;
183
194
 
184
195
  declare function Dialog({ ...props }: React__default.ComponentProps<typeof Dialog$1.Root>): react_jsx_runtime.JSX.Element;
185
196
  declare function DialogTrigger({ ...props }: React__default.ComponentProps<typeof Dialog$1.Trigger>): react_jsx_runtime.JSX.Element;
186
197
  declare function DialogClose({ ...props }: React__default.ComponentProps<typeof Dialog$1.Close>): react_jsx_runtime.JSX.Element;
187
- declare function DialogContent({ className, children, showCloseButton, ...props }: React__default.ComponentProps<typeof Dialog$1.Content> & {
198
+ declare function DialogContent({ className, children, showCloseButton, ...props }: React__default.ComponentProps<typeof Dialog$1.Popup> & {
188
199
  showCloseButton?: boolean;
189
200
  }): react_jsx_runtime.JSX.Element;
190
201
  declare function DialogHeader({ className, ...props }: React__default.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
@@ -194,29 +205,35 @@ declare function DialogFooter({ className, showCloseButton, children, ...props }
194
205
  declare function DialogTitle({ className, ...props }: React__default.ComponentProps<typeof Dialog$1.Title>): react_jsx_runtime.JSX.Element;
195
206
  declare function DialogDescription({ className, ...props }: React__default.ComponentProps<typeof Dialog$1.Description>): react_jsx_runtime.JSX.Element;
196
207
 
197
- declare function DropdownMenu({ ...props }: React__default.ComponentProps<typeof DropdownMenu$1.Root>): react_jsx_runtime.JSX.Element;
198
- declare function DropdownMenuTrigger({ ...props }: React__default.ComponentProps<typeof DropdownMenu$1.Trigger>): react_jsx_runtime.JSX.Element;
199
- declare function DropdownMenuContent({ className, sideOffset, ...props }: React__default.ComponentProps<typeof DropdownMenu$1.Content>): react_jsx_runtime.JSX.Element;
200
- declare function DropdownMenuItem({ className, inset, variant, ...props }: React__default.ComponentProps<typeof DropdownMenu$1.Item> & {
208
+ declare function Menu({ ...props }: React__default.ComponentProps<typeof Menu$1.Root>): react_jsx_runtime.JSX.Element;
209
+ declare function MenuTrigger({ ...props }: React__default.ComponentProps<typeof Menu$1.Trigger>): react_jsx_runtime.JSX.Element;
210
+ declare function MenuContent({ className, sideOffset, align, ...props }: React__default.ComponentProps<typeof Menu$1.Popup> & {
211
+ sideOffset?: number;
212
+ align?: "start" | "center" | "end";
213
+ }): react_jsx_runtime.JSX.Element;
214
+ declare function MenuItem({ className, inset, variant, ...props }: React__default.ComponentProps<typeof Menu$1.Item> & {
201
215
  inset?: boolean;
202
216
  variant?: "default" | "destructive";
203
217
  }): react_jsx_runtime.JSX.Element;
204
- declare function DropdownMenuSeparator({ className, ...props }: React__default.ComponentProps<typeof DropdownMenu$1.Separator>): react_jsx_runtime.JSX.Element;
218
+ declare function MenuSeparator({ className, ...props }: React__default.ComponentProps<typeof Menu$1.Separator>): react_jsx_runtime.JSX.Element;
205
219
 
206
- declare function Label({ className, ...props }: React__default.ComponentProps<typeof Label$1.Root>): react_jsx_runtime.JSX.Element;
220
+ declare function Label({ className, ...props }: React__default.ComponentProps<"label">): react_jsx_runtime.JSX.Element;
207
221
 
208
- declare function Switch({ className, ...props }: React__default.ComponentProps<typeof Switch$1.Root>): react_jsx_runtime.JSX.Element;
222
+ declare function Switch({ className, checked, defaultChecked, onCheckedChange, disabled, name, ...props }: React__default.ComponentProps<typeof Switch$1.Root>): react_jsx_runtime.JSX.Element;
209
223
 
210
224
  declare function Textarea({ className, ...props }: React__default.ComponentProps<"textarea">): react_jsx_runtime.JSX.Element;
211
225
 
212
226
  declare function Popover({ ...props }: React__default.ComponentProps<typeof Popover$1.Root>): react_jsx_runtime.JSX.Element;
213
227
  declare function PopoverTrigger({ ...props }: React__default.ComponentProps<typeof Popover$1.Trigger>): react_jsx_runtime.JSX.Element;
214
- declare function PopoverContent({ className, align, sideOffset, ...props }: React__default.ComponentProps<typeof Popover$1.Content>): react_jsx_runtime.JSX.Element;
228
+ declare function PopoverContent({ className, align, sideOffset, ...props }: React__default.ComponentProps<typeof Popover$1.Popup> & {
229
+ align?: "start" | "center" | "end";
230
+ sideOffset?: number;
231
+ }): react_jsx_runtime.JSX.Element;
215
232
 
216
- declare function Tabs({ ...props }: React__default.ComponentProps<typeof Tabs$1.Root>): react_jsx_runtime.JSX.Element;
233
+ declare function Tabs({ className, ...props }: React__default.ComponentProps<typeof Tabs$1.Root>): react_jsx_runtime.JSX.Element;
217
234
  declare function TabsList({ className, ...props }: React__default.ComponentProps<typeof Tabs$1.List>): react_jsx_runtime.JSX.Element;
218
- declare function TabsTrigger({ className, ...props }: React__default.ComponentProps<typeof Tabs$1.Trigger>): react_jsx_runtime.JSX.Element;
219
- declare function TabsContent({ className, ...props }: React__default.ComponentProps<typeof Tabs$1.Content>): react_jsx_runtime.JSX.Element;
235
+ declare function TabsTab({ className, ...props }: React__default.ComponentProps<typeof Tabs$1.Tab>): react_jsx_runtime.JSX.Element;
236
+ declare function TabsPanel({ className, ...props }: React__default.ComponentProps<typeof Tabs$1.Panel>): react_jsx_runtime.JSX.Element;
220
237
 
221
238
  declare function ValueInput({ value, onChange, placeholder }: ValueInputProps): react_jsx_runtime.JSX.Element;
222
239
 
@@ -265,9 +282,9 @@ declare const VariationCard: React$1.NamedExoticComponent<VariationCardProps>;
265
282
 
266
283
  declare function VariationList({ variations: rawVariations, validationErrors, onChange, }: VariationListProps): react_jsx_runtime.JSX.Element;
267
284
 
268
- declare function DefinitionEditor({ definitionKey, definition, validationErrors, isDirty, isPending, onUpdate, onRename, onSave, onDiscard, }: DefinitionEditorProps): react_jsx_runtime.JSX.Element;
285
+ declare function DefinitionEditor({ definitionKey, definition, validationErrors, isDirty, isPending, onUpdate, onRename, onSave, onDiscard, onRemove, onExport, onRefresh, }: DefinitionEditorProps): react_jsx_runtime.JSX.Element;
269
286
 
270
- declare function DefinitionList({ definitions, selectedKey, validationErrors, dirtyKeys, onSelect, onAdd, onRemove, }: DefinitionListProps): react_jsx_runtime.JSX.Element;
287
+ declare function DefinitionList({ keys, definitions, selectedKey, validationErrors, dirtyKeys, onSelect, onAdd, onRemove, }: DefinitionListProps): react_jsx_runtime.JSX.Element;
271
288
 
272
289
  interface ConditionExtensions {
273
290
  extraConditionTypes: ConditionTypeMeta[];
@@ -311,12 +328,19 @@ interface ConfiguratorStore {
311
328
  discardDefinition(key: string): Promise<void>;
312
329
  }
313
330
 
314
- declare function Configurator({ store, className, emptyState, conditionExtensions, fallbackEvaluator, }: {
331
+ declare function Configurator({ store, className, emptyState, sidebarHeader, definitionKeys, onBeforeSelect, isLoadingDefinition, conditionExtensions, conditionExtensionsResolver, fallbackEvaluator, onRefreshDefinition, onExportDefinition, }: {
315
332
  store: ConfiguratorStore | ConfiguratorStoreSource;
316
333
  className?: string;
317
334
  emptyState?: React.ReactNode;
335
+ sidebarHeader?: React.ReactNode;
336
+ definitionKeys?: string[];
337
+ onBeforeSelect?: (key: string) => Promise<void> | void;
338
+ isLoadingDefinition?: boolean;
318
339
  conditionExtensions?: ConditionExtensions;
340
+ conditionExtensionsResolver?: (key: string) => ConditionExtensions;
319
341
  fallbackEvaluator?: ConditionEvaluator;
342
+ onRefreshDefinition?: (key: string) => void;
343
+ onExportDefinition?: (key: string, definition: Definition, format: "yaml" | "json") => void;
320
344
  }): react_jsx_runtime.JSX.Element;
321
345
 
322
346
  interface ActionStateContextValue {
@@ -362,4 +386,15 @@ type PreviewResult = {
362
386
  message: string;
363
387
  };
364
388
 
365
- export { AUTO_ID_PREFIX, type ActionState, ActionStateContext, type ActionStateContextValue, BUILTIN_CONDITION_TYPES, Badge, Button, CONDITION_TYPE_MAP, type ConditionBlockProps, ConditionBuilder, type ConditionBuilderProps, type ConditionExtensions, type ConditionGroupProps, type ConditionTypeMeta, type ConditionValueEditorProps, Configurator, type ConfiguratorStore, type ConfiguratorStoreSource, ConfirmDialog, DateTimeInput, type DateTimeInputProps, DefinitionEditor, type DefinitionEditorProps, DefinitionList, type DefinitionListItemProps, type DefinitionListProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, ErrorBoundary, Input, Label, Popover, PopoverContent, PopoverTrigger, type PreviewResult, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, StoreSourceContext, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeToggle, type ThemeToggleProps, type ValidationIssue, type ValidationIssueDisplay, ValidationMessage, type ValidationMessageProps, ValueInput, type ValueInputProps, VariationCard, type VariationCardProps, VariationList, type VariationListProps, badgeVariants, buttonVariants, cn, createPresetConditionMeta, createPresetUI, getConditionMeta, isAutoId, stripAutoIds, useActionState, useConfiguratorSelector, useConfiguratorStore, useStoreRef };
389
+ interface PreviewState {
390
+ contextText: string;
391
+ annotationsText: string;
392
+ evaluatorText: string;
393
+ setContextText: (text: string) => void;
394
+ setAnnotationsText: (text: string) => void;
395
+ setEvaluatorText: (text: string) => void;
396
+ resetPreview: () => void;
397
+ }
398
+ declare const PreviewStateProvider: React$1.Provider<PreviewState>;
399
+
400
+ export { AUTO_ID_PREFIX, type ActionState, ActionStateContext, type ActionStateContextValue, BUILTIN_CONDITION_TYPES, Badge, Button, CONDITION_TYPE_MAP, type ConditionBlockProps, ConditionBuilder, type ConditionBuilderProps, type ConditionExtensions, type ConditionGroupProps, type ConditionTypeMeta, type ConditionValueEditorProps, Configurator, type ConfiguratorStore, type ConfiguratorStoreSource, ConfirmDialog, DateTimeInput, type DateTimeInputProps, DefinitionEditor, type DefinitionEditorProps, DefinitionList, type DefinitionListItemProps, type DefinitionListProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, ErrorBoundary, Input, Label, Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Popover, PopoverContent, PopoverTrigger, type PreviewResult, type PreviewState, PreviewStateProvider, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, StoreSourceContext, Switch, Tabs, TabsList, TabsPanel, TabsTab, Textarea, ThemeToggle, type ThemeToggleProps, type ValidationIssue, type ValidationIssueDisplay, ValidationMessage, type ValidationMessageProps, ValueInput, type ValueInputProps, VariationCard, type VariationCardProps, VariationList, type VariationListProps, badgeVariants, buttonVariants, cn, createPresetConditionMeta, createPresetUI, getConditionMeta, isAutoId, stripAutoIds, useActionState, useConfiguratorSelector, useConfiguratorStore, useStoreRef };