@showwhat/configurator 1.0.1 → 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/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @showwhat/configurator
2
2
 
3
- A reusable React component library for visually editing showwhat feature flag definitions. Provides a complete rule-builder UI bring your own store and persistence.
3
+ A reusable React component library for visually editing showwhat definitions like Swagger UI for your flag and config rules.
4
+
5
+ Provides a complete rule-builder UI while letting your app own storage, workflow, and persistence.
4
6
 
5
7
  ## Installation
6
8
 
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;
@@ -84,6 +95,7 @@ type ValueInputProps = {
84
95
  type DateTimeInputProps = {
85
96
  value: string;
86
97
  onChange: (value: string) => void;
98
+ disabled?: boolean;
87
99
  };
88
100
  type ValidationIssueDisplay = {
89
101
  path: (string | number)[];
@@ -138,10 +150,9 @@ declare function buttonVariants(opts?: {
138
150
  size?: ButtonSize;
139
151
  className?: string;
140
152
  }): string;
141
- 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"> & {
142
154
  variant?: ButtonVariant;
143
155
  size?: ButtonSize;
144
- asChild?: boolean;
145
156
  }): react_jsx_runtime.JSX.Element;
146
157
 
147
158
  declare function Input({ className, type, ...props }: React__default.ComponentProps<"input">): react_jsx_runtime.JSX.Element;
@@ -152,8 +163,8 @@ declare function SelectValue({ ...props }: React__default.ComponentProps<typeof
152
163
  declare function SelectTrigger({ className, size, children, ...props }: React__default.ComponentProps<typeof Select$1.Trigger> & {
153
164
  size?: "sm" | "default";
154
165
  }): react_jsx_runtime.JSX.Element;
155
- declare function SelectContent({ className, children, position, align, ...props }: React__default.ComponentProps<typeof Select$1.Content>): react_jsx_runtime.JSX.Element;
156
- 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;
157
168
  declare function SelectItem({ className, children, ...props }: React__default.ComponentProps<typeof Select$1.Item>): react_jsx_runtime.JSX.Element;
158
169
  declare function SelectSeparator({ className, ...props }: React__default.ComponentProps<typeof Select$1.Separator>): react_jsx_runtime.JSX.Element;
159
170
 
@@ -170,20 +181,21 @@ declare function badgeVariants(opts?: {
170
181
  variant?: BadgeVariant;
171
182
  className?: string;
172
183
  }): string;
173
- declare function Badge({ className, variant, asChild, ...props }: React__default.ComponentProps<"span"> & {
184
+ declare function Badge({ className, variant, ...props }: React__default.ComponentProps<"span"> & {
174
185
  variant?: BadgeVariant;
175
- asChild?: boolean;
176
186
  }): react_jsx_runtime.JSX.Element;
177
187
 
178
- 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;
179
191
 
180
192
  declare function ScrollArea({ className, children, ...props }: React__default.ComponentProps<typeof ScrollArea$1.Root>): react_jsx_runtime.JSX.Element;
181
- 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;
182
194
 
183
195
  declare function Dialog({ ...props }: React__default.ComponentProps<typeof Dialog$1.Root>): react_jsx_runtime.JSX.Element;
184
196
  declare function DialogTrigger({ ...props }: React__default.ComponentProps<typeof Dialog$1.Trigger>): react_jsx_runtime.JSX.Element;
185
197
  declare function DialogClose({ ...props }: React__default.ComponentProps<typeof Dialog$1.Close>): react_jsx_runtime.JSX.Element;
186
- 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> & {
187
199
  showCloseButton?: boolean;
188
200
  }): react_jsx_runtime.JSX.Element;
189
201
  declare function DialogHeader({ className, ...props }: React__default.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
@@ -193,33 +205,39 @@ declare function DialogFooter({ className, showCloseButton, children, ...props }
193
205
  declare function DialogTitle({ className, ...props }: React__default.ComponentProps<typeof Dialog$1.Title>): react_jsx_runtime.JSX.Element;
194
206
  declare function DialogDescription({ className, ...props }: React__default.ComponentProps<typeof Dialog$1.Description>): react_jsx_runtime.JSX.Element;
195
207
 
196
- declare function DropdownMenu({ ...props }: React__default.ComponentProps<typeof DropdownMenu$1.Root>): react_jsx_runtime.JSX.Element;
197
- declare function DropdownMenuTrigger({ ...props }: React__default.ComponentProps<typeof DropdownMenu$1.Trigger>): react_jsx_runtime.JSX.Element;
198
- declare function DropdownMenuContent({ className, sideOffset, ...props }: React__default.ComponentProps<typeof DropdownMenu$1.Content>): react_jsx_runtime.JSX.Element;
199
- 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> & {
200
215
  inset?: boolean;
201
216
  variant?: "default" | "destructive";
202
217
  }): react_jsx_runtime.JSX.Element;
203
- 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;
204
219
 
205
- 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;
206
221
 
207
- 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;
208
223
 
209
224
  declare function Textarea({ className, ...props }: React__default.ComponentProps<"textarea">): react_jsx_runtime.JSX.Element;
210
225
 
211
226
  declare function Popover({ ...props }: React__default.ComponentProps<typeof Popover$1.Root>): react_jsx_runtime.JSX.Element;
212
227
  declare function PopoverTrigger({ ...props }: React__default.ComponentProps<typeof Popover$1.Trigger>): react_jsx_runtime.JSX.Element;
213
- 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;
214
232
 
215
- 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;
216
234
  declare function TabsList({ className, ...props }: React__default.ComponentProps<typeof Tabs$1.List>): react_jsx_runtime.JSX.Element;
217
- declare function TabsTrigger({ className, ...props }: React__default.ComponentProps<typeof Tabs$1.Trigger>): react_jsx_runtime.JSX.Element;
218
- 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;
219
237
 
220
238
  declare function ValueInput({ value, onChange, placeholder }: ValueInputProps): react_jsx_runtime.JSX.Element;
221
239
 
222
- declare function DateTimeInput({ value, onChange }: DateTimeInputProps): react_jsx_runtime.JSX.Element;
240
+ declare function DateTimeInput({ value, onChange, disabled }: DateTimeInputProps): react_jsx_runtime.JSX.Element;
223
241
 
224
242
  declare function ValidationMessage({ errors }: ValidationMessageProps): react_jsx_runtime.JSX.Element | null;
225
243
 
@@ -264,9 +282,9 @@ declare const VariationCard: React$1.NamedExoticComponent<VariationCardProps>;
264
282
 
265
283
  declare function VariationList({ variations: rawVariations, validationErrors, onChange, }: VariationListProps): react_jsx_runtime.JSX.Element;
266
284
 
267
- 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;
268
286
 
269
- 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;
270
288
 
271
289
  interface ConditionExtensions {
272
290
  extraConditionTypes: ConditionTypeMeta[];
@@ -310,12 +328,19 @@ interface ConfiguratorStore {
310
328
  discardDefinition(key: string): Promise<void>;
311
329
  }
312
330
 
313
- declare function Configurator({ store, className, emptyState, conditionExtensions, fallbackEvaluator, }: {
331
+ declare function Configurator({ store, className, emptyState, sidebarHeader, definitionKeys, onBeforeSelect, isLoadingDefinition, conditionExtensions, conditionExtensionsResolver, fallbackEvaluator, onRefreshDefinition, onExportDefinition, }: {
314
332
  store: ConfiguratorStore | ConfiguratorStoreSource;
315
333
  className?: string;
316
334
  emptyState?: React.ReactNode;
335
+ sidebarHeader?: React.ReactNode;
336
+ definitionKeys?: string[];
337
+ onBeforeSelect?: (key: string) => Promise<void> | void;
338
+ isLoadingDefinition?: boolean;
317
339
  conditionExtensions?: ConditionExtensions;
340
+ conditionExtensionsResolver?: (key: string) => ConditionExtensions;
318
341
  fallbackEvaluator?: ConditionEvaluator;
342
+ onRefreshDefinition?: (key: string) => void;
343
+ onExportDefinition?: (key: string, definition: Definition, format: "yaml" | "json") => void;
319
344
  }): react_jsx_runtime.JSX.Element;
320
345
 
321
346
  interface ActionStateContextValue {
@@ -361,4 +386,15 @@ type PreviewResult = {
361
386
  message: string;
362
387
  };
363
388
 
364
- 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 };