@northlight/ui 2.38.3 → 2.39.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.
@@ -295,6 +295,286 @@ declare const SelectField: <T extends Option<string>, K extends boolean = false>
295
295
  onChange?: ((option: K extends true ? react_select_dist_declarations_src_types.MultiValue<T> | undefined : react_select_dist_declarations_src_types.SingleValue<T> | undefined, event: react_select.ActionMeta<T>) => void) | undefined;
296
296
  } & React__default.RefAttributes<HTMLDivElement>) => React__default.ReactElement<any, string | React__default.JSXElementConstructor<any>> | null;
297
297
 
298
+ interface SortableSelectProps<T extends Option> extends Omit<SelectProps<T, true>, 'isMulti'> {
299
+ /** The currently selected options */
300
+ value?: T[] | string[];
301
+ /** Callback when the order or selection changes */
302
+ onChange?: (selected: MultiValue<T>, event: ActionMeta<T>) => void;
303
+ }
304
+ /**
305
+ * SortableSelect component that provides drag-and-drop reordering for multi-select options.
306
+ * It is built on top of the Select component with @dnd-kit integration.
307
+ *
308
+ * Drag-and-drop reordering.
309
+ * Supports both string arrays and option objects as values.
310
+ * Preserves order from value prop (not options order).
311
+ * Works seamlessly with react-hook-form.
312
+ * All Select component props and styling supported.
313
+ *
314
+ * @see Select
315
+ * @see MultiSort
316
+ * @see Draggable
317
+ * @see {@link https://northlight.dev/reference/sortable-select}
318
+ *
319
+ * @example (Example)
320
+ * ## Basic Usage with String Array
321
+ * (?
322
+ * +
323
+ * const MyComponent = () => {
324
+ * const [selected, setSelected] = useState(['USD', 'EUR', 'GBP'])
325
+ *
326
+ * const currencyOptions = [
327
+ * { label: 'US Dollar', value: 'USD' },
328
+ * { label: 'Euro', value: 'EUR' },
329
+ * { label: 'British Pound', value: 'GBP' },
330
+ * { label: 'Japanese Yen', value: 'JPY' },
331
+ * ]
332
+ *
333
+ * return (
334
+ * <SortableSelect
335
+ * options={currencyOptions}
336
+ * value={selected}
337
+ * onChange={(value) => setSelected((value || []).map(v => v.value))}
338
+ * placeholder="Select currencies"
339
+ * />
340
+ * )
341
+ * }
342
+ *
343
+ * render(<MyComponent />)
344
+ * ?)
345
+ *
346
+ * @example (Example)
347
+ * ## Usage with Option Objects
348
+ * (?
349
+ * +
350
+ * const MyComponent = () => {
351
+ * const [selected, setSelected] = useState([
352
+ * { label: 'Apple', value: 'apple' },
353
+ * { label: 'Banana', value: 'banana' }
354
+ * ])
355
+ *
356
+ * const fruitOptions = [
357
+ * { label: 'Apple', value: 'apple' },
358
+ * { label: 'Banana', value: 'banana' },
359
+ * { label: 'Cherry', value: 'cherry' },
360
+ * { label: 'Date', value: 'date' },
361
+ * ]
362
+ *
363
+ * return (
364
+ * <SortableSelect
365
+ * options={fruitOptions}
366
+ * value={selected}
367
+ * onChange={(value) => setSelected(value || [])}
368
+ * />
369
+ * )
370
+ * }
371
+ *
372
+ * render(<MyComponent />)
373
+ * ?)
374
+ *
375
+ * @example (Example)
376
+ * ## React Hook Form Integration
377
+ * _Use with react-hook-form for controlled form state with reordering_
378
+ * (?
379
+ * +
380
+ * const tagOptions = [
381
+ * { label: 'React', value: 'react' },
382
+ * { label: 'TypeScript', value: 'typescript' },
383
+ * { label: 'JavaScript', value: 'javascript' },
384
+ * { label: 'Node.js', value: 'nodejs' },
385
+ * ]
386
+ *
387
+ * const MyFormFields = () => {
388
+ * const { setValue } = useFormContext()
389
+ * const selectedTags = useWatch({ name: 'tags' })
390
+ *
391
+ * const handleChange = (value, actionMeta) => {
392
+ * const tags = (value || []).map(v => v.value)
393
+ * setValue('tags', tags, {
394
+ * shouldDirty: true,
395
+ * shouldValidate: true,
396
+ * })
397
+ * }
398
+ *
399
+ * return (
400
+ * <SortableSelect
401
+ * name="tags"
402
+ * options={tagOptions}
403
+ * value={selectedTags}
404
+ * onChange={handleChange}
405
+ * />
406
+ * )
407
+ * }
408
+ *
409
+ * const MyForm = () => (
410
+ * <Form
411
+ * initialValues={{ tags: ['react'] }}
412
+ * onSubmit={(values) => console.log(values)}
413
+ * >
414
+ * {() => <MyFormFields />}
415
+ * </Form>
416
+ * )
417
+ *
418
+ * render(<MyForm />)
419
+ * ?)
420
+ *
421
+ * @example (Example)
422
+ * ## Handling Different Actions
423
+ * (?
424
+ * +
425
+ * const MyComponent = () => {
426
+ * const [selected, setSelected] = useState(['red'])
427
+ *
428
+ * const options = [
429
+ * { label: 'Red', value: 'red' },
430
+ * { label: 'Green', value: 'green' },
431
+ * { label: 'Blue', value: 'blue' },
432
+ * ]
433
+ *
434
+ * const handleChange = (value, actionMeta) => {
435
+ * const { action, removedValue, option } = actionMeta
436
+ *
437
+ * switch (action) {
438
+ * case 'select-option':
439
+ * console.log('Added:', option)
440
+ * break
441
+ * case 'remove-value':
442
+ * console.log('Removed:', removedValue)
443
+ * break
444
+ * case 'clear':
445
+ * console.log('Reordered:', value?.map(v => v.value))
446
+ * break
447
+ * }
448
+ *
449
+ * setSelected((value || []).map(v => v.value))
450
+ * }
451
+ *
452
+ * return (
453
+ * <SortableSelect
454
+ * options={options}
455
+ * value={selected}
456
+ * onChange={handleChange}
457
+ * />
458
+ * )
459
+ * }
460
+ *
461
+ * render(<MyComponent />)
462
+ * ?)
463
+ *
464
+ * @example (Example)
465
+ * ## Customizing Selected Options
466
+ * _Customize the appearance of selected option pills while keeping drag functionality_
467
+ * (?
468
+ * +
469
+ * const MyComponent = () => {
470
+ * const [selected, setSelected] = useState(['js', 'ts'])
471
+ *
472
+ * const options = [
473
+ * { label: 'JavaScript', value: 'js' },
474
+ * { label: 'TypeScript', value: 'ts' },
475
+ * { label: 'Python', value: 'py' },
476
+ * { label: 'Rust', value: 'rust' },
477
+ * ]
478
+ *
479
+ * return (
480
+ * <SortableSelect
481
+ * options={options}
482
+ * value={selected}
483
+ * onChange={(value) => setSelected((value || []).map(v => v.value))}
484
+ * components={{
485
+ * MultiValueLabel: (props) => (
486
+ * <HStack spacing={1} px={2}>
487
+ * <Icon as={Code} />
488
+ * <Text>{props.children}</Text>
489
+ * </HStack>
490
+ * )
491
+ * }}
492
+ * chakraStyles={{
493
+ * multiValue: (styles) => ({
494
+ * ...styles,
495
+ * backgroundColor: 'purple.100',
496
+ * borderRadius: 'full',
497
+ * }),
498
+ * }}
499
+ * />
500
+ * )
501
+ * }
502
+ *
503
+ * render(<MyComponent />)
504
+ * ?)
505
+ *
506
+ * @example (Example)
507
+ * ## With Custom Tag Component
508
+ * _Use customTag prop for simpler customization_
509
+ * (?
510
+ * +
511
+ * const customTag = ({ label }) => (
512
+ * <HStack spacing={1} px={2} py={1} bg="blue.50" borderRadius="md">
513
+ * <Badge colorScheme="blue" variant="solid" fontSize="xs">NEW</Badge>
514
+ * <Text fontSize="sm" fontWeight="medium">{label}</Text>
515
+ * </HStack>
516
+ * )
517
+ *
518
+ * const MyComponent = () => {
519
+ * const [selected, setSelected] = useState(['react'])
520
+ *
521
+ * return (
522
+ * <SortableSelect
523
+ * options={[
524
+ * { label: 'React', value: 'react' },
525
+ * { label: 'Vue', value: 'vue' },
526
+ * { label: 'Angular', value: 'angular' },
527
+ * ]}
528
+ * value={selected}
529
+ * onChange={(value) => setSelected((value || []).map(v => v.value))}
530
+ * customTag={customTag}
531
+ * />
532
+ * )
533
+ * }
534
+ *
535
+ * render(<MyComponent />)
536
+ * ?)
537
+ *
538
+ * @example (Example)
539
+ * ## Disabled State
540
+ * (?
541
+ * <SortableSelect
542
+ * options={[
543
+ * { label: 'Admin', value: 'admin' },
544
+ * { label: 'Editor', value: 'editor' },
545
+ * { label: 'Viewer', value: 'viewer' },
546
+ * ]}
547
+ * value={['viewer']}
548
+ * onChange={(value) => console.log('Changed:', value)}
549
+ * isDisabled={true}
550
+ * placeholder="Select items (disabled)"
551
+ * />
552
+ * ?)
553
+ *
554
+ * @example (Example)
555
+ * ## With Styling
556
+ * (?
557
+ * <SortableSelect
558
+ * options={[
559
+ * { label: 'Apple', value: 'apple' },
560
+ * { label: 'Banana', value: 'banana' },
561
+ * { label: 'Orange', value: 'orange' },
562
+ * { label: 'Pear', value: 'pear' },
563
+ * ]}
564
+ * value={['apple', 'banana']}
565
+ * onChange={(value) => console.log('Changed:', value)}
566
+ * colorScheme="blue"
567
+ * chakraStyles={{
568
+ * multiValue: (styles) => ({
569
+ * ...styles,
570
+ * backgroundColor: 'red.100',
571
+ * }),
572
+ * }}
573
+ * />
574
+ * ?)
575
+ */
576
+ declare const SortableSelect: <T extends Option<string>>({ value, onChange, components: customComponents, options, ...rest }: SortableSelectProps<T>) => JSX.Element;
577
+
298
578
  declare const getMatchingValue: <T extends Option<string>, K extends boolean>(value: (K extends true ? string[] | T[] : string | T | null) | undefined, options: react_select.OptionsOrGroups<T, react_select.GroupBase<T>> | undefined) => T | T[] | undefined;
299
579
 
300
580
  interface TagsInputProps<T> extends Omit<SelectProps<T, true>, 'value' | 'formatCreateLabel' | 'isValidNewOption' | 'onAdd' | 'onRemove' | 'leftIcon' | 'icon' | 'customOption'> {
@@ -4574,4 +4854,4 @@ declare const theme: Record<string, any>;
4574
4854
  declare const tottTheme: Record<string, any>;
4575
4855
  declare const camphouseLightTheme: Record<string, any>;
4576
4856
 
4577
- export { Accordion, AccordionButton, AccordionItem, AccordionPanel, Alert, AlertProps, AlertVariants, AspectRatio, AsyncError, AsyncErrorProps, Avatar, AvatarBadgeProps, AvatarGroup, AvatarGroupProps, AvatarProps, Badge, BasicOption, Blinker, BlinkerProps, Blockquote, BodyType, Button, ButtonProps, ButtonVariants, Capitalized, Carousel, Checkbox, CheckboxField, CheckboxFieldGroupProps, CheckboxFieldProps, CheckboxGroupField, CheckboxProps, CheckboxVariants, ChildrenType$1 as ChildrenType, Clickable, ClickableProps, ClipboardInput, ClipboardInputProps, Collapse, CollapseProps, Color, ColorButtonProps, ColorGrade, ColorPicker, ColorPickerField, ColorPickerFieldProps, ColorPickerProps, ColorShades, ColorsExpandButtonProps, ComboPicker, ComboPickerField, ComboPickerFieldProps, ComboPickerOption, ComboPickerProps, ComboPickerValue, ConfirmDeleteModalProps, CreatableSelectDropdown, CurrentTheme, CustomContainerPropsType, CustomElementType, CustomFlipButtonProps, CustomFlipButtonPropsType, CustomTheme, DatePicker, DatePickerField, DatePickerFieldProps, DatePickerLocaleWrapper, DatePickerProps, DateRange, DateRangePicker, DateRangePickerField, DateRangePickerFieldProps, DateRangePickerProps, DragAndDrop, DragHandle, DragHandleProps, DragItem, DragItemProps, Draggable, DraggableProps, DropZone, DropZoneProps, Droppable, DroppableProps, DurationType, EditableControlsProps, EditableProps, EditableSizes, EditableText, EditableVariant, Fade, FadeProps, FastGrid, FastGridProps, FastList, FastListProps, Field, FieldErrorType, FieldProps, FileEditorModalProps, FileFormat, FileIconButtonProps, FileItemProps, FilePicker, FilePickerField, FilePickerFieldProps, FilePickerProps, FileWithSizeAndType, FileWithSrcNameType, FileWithType, FlipButton, FlipButtonGroup, FlipButtonGroupField, FlipButtonGroupFieldProps, FlipButtonGroupProps, FlipButtonProps, Form, FormBody, FormLabel, FormLabelProps, FormProps, FormattedNumberInput, FormattedNumberInputField, FormattedNumberInputFieldProps, FormattedNumberInputPreset, FormattedNumberInputProps, H1, H2, H3, H4, H5, H6, HeadingProps, HeadingType, Icon, IconButton, IconButtonProps, IconProps, InputFieldProps, IntentButton, Label, LabelProps, LabelSizes, LabelType, Lead, ListenersType, LoadingBar, MaskedTextInput, MaskedTextInputProps, MediatoolThemeProvider, MediatoolThemeProviderProps, Menu, MenuProps, MenuVariants, Message, Modal, ModalBase, ModalBody, ModalBooleans, ModalProps, ModalSizes, MultiFileList, MultiFileListProps, MultiFilePicker, MultiFilePickerField, MultiFilePickerFieldProps, MultiFilePickerProps, MultiFileUploader, MultiFileUploaderProps, MultiItemType, MultiSort, MultiSortProps, NotificationIconButton, NotificationIconButtonProps, NumVal, NumValType, NumberInput, NumberInputField, NumberInputFieldProps, NumberInputProps, NumberInputSizeProps, NumberInputStepperProps, OffsetType, Option, OrganizationLogo, OrganizationLogoProps, OverflowGroup, OverflowGroupProps, OverflowIndicatorProps, P, PProps, PaneDivider, PaneItem, PinInput, PinInputProps, PinSize, PinSizeTuple, PinVariant, Popover, PresetOptions, ProgressBar, ProgressBarProps, Radio, RadioFieldGroupProps, RadioFieldProps, RadioGroup, RadioGroupField, RadioGroupProps, RadioProps, ResizeHandle, ScaleFade, ScaleFadeProps, SearchBar, SearchBarField, SearchBarFieldProps, SearchBarOptionType, SearchBarProps, Select, SelectActionMeta, SelectField, SelectFieldProps, SelectProps, SetValueOptionsType, Slide, SlideFade, SlideFadeProps, SlideProps, Small, Sortable, SortableContainer, SortableContainerProps, SortableItem, SortableItemProps, SortableList, SortableListProps, Spinner, SpinnerProps, SplitPane, SplitPaneProps, StatusPin, StatusPinProps, Step, StepList, StepListProps, StepPanel, StepPanelProps, StepProps, StepStack, Steps, StepsProps, StylizedType, Switch, SwitchField, SwitchFieldProps, SwitchProps, TabPanel, TabPanelProps, Table, TableProps, Tabs, TabsProps, Tag, TagGroup, TagGroupProps, TagProps, TagsInput, TagsInputProps, TextField, TextFieldProps, TextInputFormatter, TextSizeProps, Textarea, TextareaField, TextareaFieldProps, TextareaProps, Tiny, Toast, ToastProps, Toolbox, ToolboxContent, ToolboxContentProps, ToolboxFooter, ToolboxFooterProps, ToolboxHeader, ToolboxHeaderProps, ToolboxProps, Tooltip, TransitionDirection, UseFormReturn, UseSelectCallbacksProps, UseToastOptions, addAlpha, advancedParseFloat, camphouseLightTheme, clamp, createDebounceFunctionInstance, getChildrenWithProps, getConsistentRandomColorFromString, getContrastColor, getFieldError, getInitials, getMatchingValue, getShades, highlight, luminosity, ring, theme, tottTheme, trimFormValues, useArrowFocus, useCurrentTheme, useDebounce, useDidUpdateEffect, useLoadingMessage, useOutsideRectClick, useOverflowGroup, useResizeWidth, useScreenSize, useScrollToBottom, useSelectCallbacks, useSetValueRefreshed, useToast };
4857
+ export { Accordion, AccordionButton, AccordionItem, AccordionPanel, Alert, AlertProps, AlertVariants, AspectRatio, AsyncError, AsyncErrorProps, Avatar, AvatarBadgeProps, AvatarGroup, AvatarGroupProps, AvatarProps, Badge, BasicOption, Blinker, BlinkerProps, Blockquote, BodyType, Button, ButtonProps, ButtonVariants, Capitalized, Carousel, Checkbox, CheckboxField, CheckboxFieldGroupProps, CheckboxFieldProps, CheckboxGroupField, CheckboxProps, CheckboxVariants, ChildrenType$1 as ChildrenType, Clickable, ClickableProps, ClipboardInput, ClipboardInputProps, Collapse, CollapseProps, Color, ColorButtonProps, ColorGrade, ColorPicker, ColorPickerField, ColorPickerFieldProps, ColorPickerProps, ColorShades, ColorsExpandButtonProps, ComboPicker, ComboPickerField, ComboPickerFieldProps, ComboPickerOption, ComboPickerProps, ComboPickerValue, ConfirmDeleteModalProps, CreatableSelectDropdown, CurrentTheme, CustomContainerPropsType, CustomElementType, CustomFlipButtonProps, CustomFlipButtonPropsType, CustomTheme, DatePicker, DatePickerField, DatePickerFieldProps, DatePickerLocaleWrapper, DatePickerProps, DateRange, DateRangePicker, DateRangePickerField, DateRangePickerFieldProps, DateRangePickerProps, DragAndDrop, DragHandle, DragHandleProps, DragItem, DragItemProps, Draggable, DraggableProps, DropZone, DropZoneProps, Droppable, DroppableProps, DurationType, EditableControlsProps, EditableProps, EditableSizes, EditableText, EditableVariant, Fade, FadeProps, FastGrid, FastGridProps, FastList, FastListProps, Field, FieldErrorType, FieldProps, FileEditorModalProps, FileFormat, FileIconButtonProps, FileItemProps, FilePicker, FilePickerField, FilePickerFieldProps, FilePickerProps, FileWithSizeAndType, FileWithSrcNameType, FileWithType, FlipButton, FlipButtonGroup, FlipButtonGroupField, FlipButtonGroupFieldProps, FlipButtonGroupProps, FlipButtonProps, Form, FormBody, FormLabel, FormLabelProps, FormProps, FormattedNumberInput, FormattedNumberInputField, FormattedNumberInputFieldProps, FormattedNumberInputPreset, FormattedNumberInputProps, H1, H2, H3, H4, H5, H6, HeadingProps, HeadingType, Icon, IconButton, IconButtonProps, IconProps, InputFieldProps, IntentButton, Label, LabelProps, LabelSizes, LabelType, Lead, ListenersType, LoadingBar, MaskedTextInput, MaskedTextInputProps, MediatoolThemeProvider, MediatoolThemeProviderProps, Menu, MenuProps, MenuVariants, Message, Modal, ModalBase, ModalBody, ModalBooleans, ModalProps, ModalSizes, MultiFileList, MultiFileListProps, MultiFilePicker, MultiFilePickerField, MultiFilePickerFieldProps, MultiFilePickerProps, MultiFileUploader, MultiFileUploaderProps, MultiItemType, MultiSort, MultiSortProps, NotificationIconButton, NotificationIconButtonProps, NumVal, NumValType, NumberInput, NumberInputField, NumberInputFieldProps, NumberInputProps, NumberInputSizeProps, NumberInputStepperProps, OffsetType, Option, OrganizationLogo, OrganizationLogoProps, OverflowGroup, OverflowGroupProps, OverflowIndicatorProps, P, PProps, PaneDivider, PaneItem, PinInput, PinInputProps, PinSize, PinSizeTuple, PinVariant, Popover, PresetOptions, ProgressBar, ProgressBarProps, Radio, RadioFieldGroupProps, RadioFieldProps, RadioGroup, RadioGroupField, RadioGroupProps, RadioProps, ResizeHandle, ScaleFade, ScaleFadeProps, SearchBar, SearchBarField, SearchBarFieldProps, SearchBarOptionType, SearchBarProps, Select, SelectActionMeta, SelectField, SelectFieldProps, SelectProps, SetValueOptionsType, Slide, SlideFade, SlideFadeProps, SlideProps, Small, Sortable, SortableContainer, SortableContainerProps, SortableItem, SortableItemProps, SortableList, SortableListProps, SortableSelect, SortableSelectProps, Spinner, SpinnerProps, SplitPane, SplitPaneProps, StatusPin, StatusPinProps, Step, StepList, StepListProps, StepPanel, StepPanelProps, StepProps, StepStack, Steps, StepsProps, StylizedType, Switch, SwitchField, SwitchFieldProps, SwitchProps, TabPanel, TabPanelProps, Table, TableProps, Tabs, TabsProps, Tag, TagGroup, TagGroupProps, TagProps, TagsInput, TagsInputProps, TextField, TextFieldProps, TextInputFormatter, TextSizeProps, Textarea, TextareaField, TextareaFieldProps, TextareaProps, Tiny, Toast, ToastProps, Toolbox, ToolboxContent, ToolboxContentProps, ToolboxFooter, ToolboxFooterProps, ToolboxHeader, ToolboxHeaderProps, ToolboxProps, Tooltip, TransitionDirection, UseFormReturn, UseSelectCallbacksProps, UseToastOptions, addAlpha, advancedParseFloat, camphouseLightTheme, clamp, createDebounceFunctionInstance, getChildrenWithProps, getConsistentRandomColorFromString, getContrastColor, getFieldError, getInitials, getMatchingValue, getShades, highlight, luminosity, ring, theme, tottTheme, trimFormValues, useArrowFocus, useCurrentTheme, useDebounce, useDidUpdateEffect, useLoadingMessage, useOutsideRectClick, useOverflowGroup, useResizeWidth, useScreenSize, useScrollToBottom, useSelectCallbacks, useSetValueRefreshed, useToast };