@northlight/ui 2.26.0 → 2.27.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.
@@ -1,8 +1,8 @@
1
- import { Accordion as Accordion$1, AccordionButton as AccordionButton$1, AccordionPanel as AccordionPanel$1, AccordionItem as AccordionItem$1, useInterval, useMediaQuery, useToken as useToken$1, Box, useMultiStyleConfig, chakra, Alert as Alert$2, AspectRatio as AspectRatio$1, forwardRef, useStyleConfig, Icon as Icon$2, Heading, Text, FormLabel as FormLabel$1, VisuallyHidden, HStack, Badge as Badge$2, Spinner as Spinner$2, Button as Button$2, Checkbox as Checkbox$2, FormControl, Stack, FormErrorMessage, Flex, IconButton as IconButton$1, Popover as Popover$2, useDisclosure, useBoolean, PopoverTrigger, PopoverContent, PopoverHeader, PopoverBody, SimpleGrid, SlideFade as SlideFade$1, keyframes, extendTheme, Table as Table$2, Thead, Tbody, Tr, Select as Select$2, PopoverAnchor, InputGroup, InputRightElement, Link as Link$1, Portal, Tooltip as Tooltip$2, VStack, Circle, Center, Fade as Fade$1, ScaleFade as ScaleFade$1, Slide as Slide$1, Collapse as Collapse$1, CloseButton as CloseButton$1, Radio as Radio$2, RadioGroup as RadioGroup$1, Tag as Tag$2, TagLabel, TagRightIcon, useEditableControls, useEditableState, Editable, InputLeftElement, Input as Input$1, EditablePreview, EditableInput, Modal as Modal$2, ModalOverlay, ModalContent, ModalCloseButton, ModalBody as ModalBody$1, ModalHeader, Slider, SliderTrack, SliderFilledTrack, SliderThumb, ModalFooter, Progress, Image as Image$1, ChakraProvider, Menu as Menu$2, NumberInputStepper as NumberInputStepper$1, Divider, NumberIncrementStepper, NumberDecrementStepper, NumberInput as NumberInput$2, NumberInputField as NumberInputField$1, PinInput as PinInput$2, Switch as Switch$2, TabPanel as TabPanel$1, Tabs as Tabs$2, Textarea as Textarea$2, useToast as useToast$1, TagLeftIcon, AlertTitle, AlertDescription, Tab, TabList, useClipboard, Grid, GridItem, useOutsideClick } from '@chakra-ui/react';
1
+ import { Accordion as Accordion$1, AccordionButton as AccordionButton$1, AccordionPanel as AccordionPanel$1, AccordionItem as AccordionItem$1, useInterval, useMediaQuery, useToken as useToken$1, Box, useMultiStyleConfig, chakra, Alert as Alert$2, AspectRatio as AspectRatio$1, forwardRef, useStyleConfig, Icon as Icon$2, Heading, Text, FormLabel as FormLabel$1, VisuallyHidden, HStack, Badge as Badge$2, Spinner as Spinner$2, Button as Button$2, Checkbox as Checkbox$2, FormControl, Stack, FormErrorMessage, Flex, IconButton as IconButton$1, Popover as Popover$2, useDisclosure, useBoolean, PopoverTrigger, PopoverContent, PopoverHeader, PopoverBody, SimpleGrid, SlideFade as SlideFade$1, keyframes, extendTheme, Table as Table$2, Thead, Tbody, Tr, Select as Select$2, PopoverAnchor, InputGroup, InputRightElement, Link as Link$1, Portal, Tooltip as Tooltip$2, VStack, Circle, Center, Fade as Fade$1, ScaleFade as ScaleFade$1, Slide as Slide$1, Collapse as Collapse$1, CloseButton as CloseButton$1, Radio as Radio$2, RadioGroup as RadioGroup$1, Tag as Tag$2, TagLabel, TagRightIcon, useEditableControls, useEditableState, Editable, InputLeftElement, Input as Input$1, EditablePreview, EditableInput, Modal as Modal$2, ModalOverlay, ModalContent, ModalCloseButton, ModalBody as ModalBody$1, ModalHeader, Slider, SliderTrack, SliderFilledTrack, SliderThumb, ModalFooter, Progress, Image as Image$1, ChakraProvider, Menu as Menu$2, NumberInputStepper as NumberInputStepper$1, Divider, NumberIncrementStepper, NumberDecrementStepper, NumberInput as NumberInput$2, NumberInputField as NumberInputField$1, PinInput as PinInput$2, Switch as Switch$2, TabPanel as TabPanel$1, Tabs as Tabs$2, Textarea as Textarea$2, useToast as useToast$1, TagLeftIcon, AlertTitle, AlertDescription, Tab, TabList, useClipboard, Grid, GridItem } from '@chakra-ui/react';
2
2
  export { AbsoluteCenter, AccordionIcon, AlertDescription, AlertDialog, AlertDialogBody, AlertDialogCloseButton, AlertDialogContent, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertIcon, AlertTitle, Box, BreadcrumbItem as Breadcrumb, BreadcrumbLink, BreadcrumbSeparator, Breadcrumb as Breadcrumbs, ButtonGroup, Card, CardBody, CardFooter, CardHeader, Center, Modal as ChakraModal, CheckboxGroup, Circle, CircularProgress, CircularProgressLabel, CloseButton, Code, Container, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, DrawerHeader, DrawerOverlay, Editable, EditableInput, EditablePreview, Flex, FormControl, FormErrorMessage, FormHelperText, Grid, GridItem, HStack, Heading, Hide, Highlight, Image, Input, InputAddon, InputGroup, InputLeftAddon, InputLeftElement, InputRightAddon, InputRightElement, Kbd, Link, LinkBox, LinkOverlay, List, ListIcon, ListItem, MenuButton, MenuCommand, MenuDivider, MenuGroup, MenuIcon, MenuItem, MenuItemOption, MenuList, MenuOptionGroup, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, NumberDecrementStepper, NumberIncrementStepper, OrderedList, PinInputField, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, Portal, RangeSlider, RangeSliderFilledTrack, RangeSliderMark, RangeSliderThumb, RangeSliderTrack, Show, SimpleGrid, Skeleton, SkeletonCircle, SkeletonText, Slider, SliderFilledTrack, SliderMark, SliderThumb, SliderTrack, Spacer, Stack, StackDivider, Stat, StatArrow, StatGroup, StatHelpText, StatLabel, StatNumber, TabIndicator as StepIndicator, TabPanels as StepPanels, Tab, TabIndicator, TabList, TabPanels, TableCaption, TableContainer, TagCloseButton, TagLabel, TagLeftIcon, TagRightIcon, Tbody, Td, Text, Tfoot, Th, Thead, Tr, UnorderedList, VStack, VisuallyHidden, VisuallyHiddenInput, Wrap, WrapItem, keyframes, useBoolean, useBreakpoint, useBreakpointValue, useClipboard, useControllableProp, useControllableState, useDisclosure, useEditable, useEditableControls, useEditableState, useInterval, useMediaQuery, useMergeRefs, useNumberInput, useOutsideClick, usePrefersReducedMotion, useRadio, useRadioGroup, useTab, useTabs, useTheme, useToken } from '@chakra-ui/react';
3
3
  import React, { useState, useEffect, useRef, isValidElement, cloneElement, Children, createContext, useContext, forwardRef as forwardRef$1, useImperativeHandle, memo, useMemo, useCallback } from 'react';
4
4
  import { CreatableSelect, chakraComponents, AsyncSelect, Select as Select$3 } from 'chakra-react-select';
5
- export { AsyncCreatableSelect, AsyncSelect, Select as ChakraReactSelect, CreatableSelect } from 'chakra-react-select';
5
+ export { AsyncCreatableSelect, AsyncSelect, Select as ChakraReactSelect, CreatableSelect, chakraComponents as selectChakraComponents } from 'chakra-react-select';
6
6
  import { isNil, last, map, prop, difference, replace, split, path, T, identity, any, isEmpty, init, append, ifElse, gt, always, defaultTo, take, inc, dec, forEach, is, trim, keys, values, equals, omit, mergeAll, merge, toLower, find, times, add, has, not, all, filter, test, indexOf, remove, insert, intersection, findIndex, concat, head, match, length, propEq } from 'ramda';
7
7
  import { useFocusManager, FocusScope, useFocusRing } from '@react-aria/focus';
8
8
  import { useForm, FormProvider, useFormContext, Controller } from 'react-hook-form';
@@ -4034,91 +4034,94 @@ const NumberInput$1 = {
4034
4034
  radii: borderRadius,
4035
4035
  borders: borderWidth,
4036
4036
  opacity
4037
- }, isReadOnly }) => ({
4038
- root: {
4039
- borderRadius: borderRadius.input.outline
4040
- },
4041
- field: {
4042
- minWidth: sizing["44"],
4043
- paddingInlineStart: spacing["padding-inline"].input.default,
4044
- paddingInlineEnd: spacing["padding-inline"].input.default,
4045
- WebkitPaddingStart: spacing["padding-inline"].input.default,
4046
- WebkitPaddingEnd: spacing["padding-inline"].input.default,
4047
- color: color.text.default,
4048
- bg: color.background.input["outline-default"],
4049
- borderWidth: borderWidth.input.default,
4050
- borderColor: color.border.input.default,
4051
- paddingRight: spacing.paddingRight["number-input"].field,
4052
- _hover: {
4053
- bg: color.background.input["outline-hover"],
4054
- borderColor: color.border.input["default-hover"]
4055
- },
4056
- _focusVisible: {
4057
- bg: color.background.input["outline-focus"],
4058
- borderColor: color.border.input.focus,
4059
- boxShadow: `0 0 0 1px ${color.border.textarea.focus}`
4060
- },
4061
- _invalid: {
4062
- bg: color.background.input["outline-error"],
4063
- borderColor: color.border.input.error,
4064
- boxShadow: `0 0 0 1px ${color.border.input.error}`
4065
- },
4066
- _disabled: {
4067
- bg: color.background.input["outline-disabled"],
4068
- opacity: opacity.input.disabled,
4069
- borderColor: color.border.input.disabled
4037
+ }, isReadOnly, minWidth, minW }) => {
4038
+ var _a;
4039
+ return {
4040
+ root: {
4041
+ borderRadius: borderRadius.input.outline
4070
4042
  },
4071
- _readOnly: {
4072
- _focusVisible: {
4073
- borderColor: color.border.input.readonly,
4074
- boxShadow: "none"
4075
- },
4076
- _hover: {
4077
- borderColor: color.border.input.readonly
4078
- }
4079
- }
4080
- },
4081
- stepperGroup: {
4082
- width: "auto",
4083
- paddingRight: spacing.paddingRight["number-input"].stepper
4084
- },
4085
- stepper: {
4086
- _first: {
4087
- border: "none",
4088
- borderTopRightRadius: borderRadius["input-stepper"].default,
4089
- borderRadius: borderRadius["input-stepper"].default,
4090
- bg: color.background["input-stepper"].default,
4091
- opacity: isReadOnly ? opacity.input.disabled : "auto",
4043
+ field: {
4044
+ minWidth: (_a = minWidth != null ? minWidth : minW) != null ? _a : sizing["44"],
4045
+ paddingInlineStart: spacing["padding-inline"].input.default,
4046
+ paddingInlineEnd: spacing["padding-inline"].input.default,
4047
+ WebkitPaddingStart: spacing["padding-inline"].input.default,
4048
+ WebkitPaddingEnd: spacing["padding-inline"].input.default,
4049
+ color: color.text.default,
4050
+ bg: color.background.input["outline-default"],
4051
+ borderWidth: borderWidth.input.default,
4052
+ borderColor: color.border.input.default,
4053
+ paddingRight: spacing.paddingRight["number-input"].field,
4092
4054
  _hover: {
4093
- bg: isReadOnly ? "none" : color.background["input-stepper"].hover
4055
+ bg: color.background.input["outline-hover"],
4056
+ borderColor: color.border.input["default-hover"]
4094
4057
  },
4095
- _active: {
4096
- bg: color.background["input-stepper"].active
4058
+ _focusVisible: {
4059
+ bg: color.background.input["outline-focus"],
4060
+ borderColor: color.border.input.focus,
4061
+ boxShadow: `0 0 0 1px ${color.border.textarea.focus}`
4062
+ },
4063
+ _invalid: {
4064
+ bg: color.background.input["outline-error"],
4065
+ borderColor: color.border.input.error,
4066
+ boxShadow: `0 0 0 1px ${color.border.input.error}`
4097
4067
  },
4098
4068
  _disabled: {
4099
- bg: color.background["input-stepper"].disabled,
4100
- color: color.icon["input-stepper"].disabled
4069
+ bg: color.background.input["outline-disabled"],
4070
+ opacity: opacity.input.disabled,
4071
+ borderColor: color.border.input.disabled
4072
+ },
4073
+ _readOnly: {
4074
+ _focusVisible: {
4075
+ borderColor: color.border.input.readonly,
4076
+ boxShadow: "none"
4077
+ },
4078
+ _hover: {
4079
+ borderColor: color.border.input.readonly
4080
+ }
4101
4081
  }
4102
4082
  },
4103
- _last: {
4104
- border: "none",
4105
- bg: color.background["input-stepper"].default,
4106
- borderBottomRightRadius: borderRadius["input-stepper"].default,
4107
- borderRadius: borderRadius["input-stepper"].default,
4108
- opacity: isReadOnly ? opacity.input.disabled : "auto",
4109
- _hover: {
4110
- bg: isReadOnly ? "none" : color.background["input-stepper"].hover
4111
- },
4112
- _active: {
4113
- bg: color.background["input-stepper"].active
4083
+ stepperGroup: {
4084
+ width: "auto",
4085
+ paddingRight: spacing.paddingRight["number-input"].stepper
4086
+ },
4087
+ stepper: {
4088
+ _first: {
4089
+ border: "none",
4090
+ borderTopRightRadius: borderRadius["input-stepper"].default,
4091
+ borderRadius: borderRadius["input-stepper"].default,
4092
+ bg: color.background["input-stepper"].default,
4093
+ opacity: isReadOnly ? opacity.input.disabled : "auto",
4094
+ _hover: {
4095
+ bg: isReadOnly ? "none" : color.background["input-stepper"].hover
4096
+ },
4097
+ _active: {
4098
+ bg: color.background["input-stepper"].active
4099
+ },
4100
+ _disabled: {
4101
+ bg: color.background["input-stepper"].disabled,
4102
+ color: color.icon["input-stepper"].disabled
4103
+ }
4114
4104
  },
4115
- _disabled: {
4116
- bg: color.background["input-stepper"].disabled,
4117
- color: color.icon["input-stepper"].disabled
4105
+ _last: {
4106
+ border: "none",
4107
+ bg: color.background["input-stepper"].default,
4108
+ borderBottomRightRadius: borderRadius["input-stepper"].default,
4109
+ borderRadius: borderRadius["input-stepper"].default,
4110
+ opacity: isReadOnly ? opacity.input.disabled : "auto",
4111
+ _hover: {
4112
+ bg: isReadOnly ? "none" : color.background["input-stepper"].hover
4113
+ },
4114
+ _active: {
4115
+ bg: color.background["input-stepper"].active
4116
+ },
4117
+ _disabled: {
4118
+ bg: color.background["input-stepper"].disabled,
4119
+ color: color.icon["input-stepper"].disabled
4120
+ }
4118
4121
  }
4119
4122
  }
4120
- }
4121
- })
4123
+ };
4124
+ }
4122
4125
  };
4123
4126
 
4124
4127
  const NotificationIconButton$1 = {
@@ -8950,17 +8953,24 @@ var __objRest$R = (source, exclude) => {
8950
8953
  }
8951
8954
  return target;
8952
8955
  };
8953
- function getComponents() {
8954
- return {
8955
- Menu: (props) => /* @__PURE__ */ React.createElement(Box, { "data-testid": "select-menu-wrapper-test-id" }, /* @__PURE__ */ React.createElement(chakraComponents.Menu, __spreadValues$12({}, props), props.children)),
8956
- DropdownIndicator: (props) => props.selectProps.icon ? /* @__PURE__ */ React.createElement(chakraComponents.DropdownIndicator, __spreadValues$12({}, props), /* @__PURE__ */ React.createElement(Icon$1, { as: props.selectProps.icon })) : /* @__PURE__ */ React.createElement(chakraComponents.DropdownIndicator, __spreadValues$12({}, props)),
8957
- Option: (props) => props.selectProps.customOption ? /* @__PURE__ */ React.createElement(chakraComponents.Option, __spreadValues$12({}, props), props.selectProps.customOption(props.data)) : /* @__PURE__ */ React.createElement(chakraComponents.Option, __spreadValues$12({}, props)),
8958
- MultiValueContainer: (props) => props.selectProps.customTag ? /* @__PURE__ */ React.createElement(chakraComponents.MultiValueContainer, __spreadValues$12({}, props), props.selectProps.customTag(props.data)) : /* @__PURE__ */ React.createElement(chakraComponents.MultiValueContainer, __spreadValues$12({}, props)),
8959
- Control: (_a) => {
8960
- var _b = _a, { children } = _b, props = __objRest$R(_b, ["children"]);
8961
- return props.selectProps.leftComponent ? /* @__PURE__ */ React.createElement(chakraComponents.Control, __spreadValues$12({}, props), /* @__PURE__ */ React.createElement(HStack, { w: "full", pl: "2" }, props.selectProps.leftComponent, /* @__PURE__ */ React.createElement(HStack, { w: "full", justify: "space-between" }, children))) : /* @__PURE__ */ React.createElement(chakraComponents.Control, __spreadValues$12({}, props), children);
8962
- }
8963
- };
8956
+ function getComponents(components) {
8957
+ return merge(
8958
+ {
8959
+ Menu: (props) => /* @__PURE__ */ React.createElement(Box, { "data-testid": "select-menu-wrapper-test-id" }, /* @__PURE__ */ React.createElement(chakraComponents.Menu, __spreadValues$12({}, props), props.children)),
8960
+ DropdownIndicator: (props) => props.selectProps.icon ? /* @__PURE__ */ React.createElement(chakraComponents.DropdownIndicator, __spreadValues$12({}, props), /* @__PURE__ */ React.createElement(Icon$1, { as: props.selectProps.icon })) : /* @__PURE__ */ React.createElement(chakraComponents.DropdownIndicator, __spreadValues$12({}, props)),
8961
+ Option: (props) => props.selectProps.customOption ? /* @__PURE__ */ React.createElement(chakraComponents.Option, __spreadValues$12({}, props), props.selectProps.customOption(props.data)) : /* @__PURE__ */ React.createElement(chakraComponents.Option, __spreadValues$12({}, props)),
8962
+ MultiValueContainer: (props) => props.selectProps.customTag ? /* @__PURE__ */ React.createElement(chakraComponents.MultiValueContainer, __spreadValues$12({}, props), props.selectProps.customTag(props.data)) : /* @__PURE__ */ React.createElement(chakraComponents.MultiValueContainer, __spreadValues$12({}, props)),
8963
+ Control: (_a) => {
8964
+ var _b = _a, {
8965
+ children
8966
+ } = _b, props = __objRest$R(_b, [
8967
+ "children"
8968
+ ]);
8969
+ return props.selectProps.leftComponent ? /* @__PURE__ */ React.createElement(chakraComponents.Control, __spreadValues$12({}, props), /* @__PURE__ */ React.createElement(HStack, { w: "full", pl: "2" }, props.selectProps.leftComponent, /* @__PURE__ */ React.createElement(HStack, { w: "full", justify: "space-between" }, children))) : /* @__PURE__ */ React.createElement(chakraComponents.Control, __spreadValues$12({}, props), children);
8970
+ }
8971
+ },
8972
+ components || {}
8973
+ );
8964
8974
  }
8965
8975
 
8966
8976
  var __defProp$11 = Object.defineProperty;
@@ -10024,7 +10034,15 @@ var __spreadValues$O = (a, b) => {
10024
10034
  }
10025
10035
  return a;
10026
10036
  };
10027
- const EditableControls = ({ size }) => {
10037
+ const mapEditableVariantsToButtonSubmitVariants = {
10038
+ brand: "brand",
10039
+ default: "success"
10040
+ };
10041
+ const mapEditableVariantsToButtonCancelVariants = {
10042
+ brand: "ghost",
10043
+ default: "danger"
10044
+ };
10045
+ const EditableControls = ({ size, variant = "default" }) => {
10028
10046
  const {
10029
10047
  getSubmitButtonProps,
10030
10048
  getCancelButtonProps
@@ -10036,7 +10054,7 @@ const EditableControls = ({ size }) => {
10036
10054
  __spreadValues$O({
10037
10055
  "aria-label": "Cancel",
10038
10056
  sx: button,
10039
- variant: "danger"
10057
+ variant: mapEditableVariantsToButtonCancelVariants[variant]
10040
10058
  }, getCancelButtonProps()),
10041
10059
  /* @__PURE__ */ React.createElement(Icon$1, { sx: icon, as: XCloseSolid })
10042
10060
  ), /* @__PURE__ */ React.createElement(
@@ -10044,7 +10062,7 @@ const EditableControls = ({ size }) => {
10044
10062
  __spreadValues$O({
10045
10063
  "aria-label": "Save",
10046
10064
  sx: button,
10047
- variant: "success"
10065
+ variant: mapEditableVariantsToButtonSubmitVariants[variant]
10048
10066
  }, getSubmitButtonProps()),
10049
10067
  /* @__PURE__ */ React.createElement(Icon$1, { sx: icon, as: CheckDuo })
10050
10068
  )) : /* @__PURE__ */ React.createElement(
@@ -10092,12 +10110,14 @@ const EditableText = (_a) => {
10092
10110
  size = "md",
10093
10111
  value: inputValue,
10094
10112
  onSubmit,
10095
- leftItem
10113
+ leftItem,
10114
+ variant = "default"
10096
10115
  } = _b, rest = __objRest$E(_b, [
10097
10116
  "size",
10098
10117
  "value",
10099
10118
  "onSubmit",
10100
- "leftItem"
10119
+ "leftItem",
10120
+ "variant"
10101
10121
  ]);
10102
10122
  const [value, setValue] = useState(inputValue);
10103
10123
  const { input, preview } = useMultiStyleConfig("EditableText", { size, value });
@@ -10126,7 +10146,7 @@ const EditableText = (_a) => {
10126
10146
  size,
10127
10147
  sx: input
10128
10148
  }
10129
- ), /* @__PURE__ */ React.createElement(InputRightElement, { sx: { width: "min-content" } }, /* @__PURE__ */ React.createElement(EditableControls, { size })))
10149
+ ), /* @__PURE__ */ React.createElement(InputRightElement, { sx: { width: "min-content" } }, /* @__PURE__ */ React.createElement(EditableControls, { size, variant })))
10130
10150
  );
10131
10151
  };
10132
10152
 
@@ -12289,7 +12309,8 @@ const Select = forwardRef$1((_a, ref) => {
12289
12309
  customTag = null,
12290
12310
  isClearable = false,
12291
12311
  value,
12292
- icon
12312
+ icon,
12313
+ components
12293
12314
  } = _b, rest = __objRest$l(_b, [
12294
12315
  "options",
12295
12316
  "isMulti",
@@ -12303,7 +12324,8 @@ const Select = forwardRef$1((_a, ref) => {
12303
12324
  "customTag",
12304
12325
  "isClearable",
12305
12326
  "value",
12306
- "icon"
12327
+ "icon",
12328
+ "components"
12307
12329
  ]);
12308
12330
  const handleChange = useSelectCallbacks({
12309
12331
  onChange,
@@ -12313,7 +12335,7 @@ const Select = forwardRef$1((_a, ref) => {
12313
12335
  value: is(Array, value) ? value : []
12314
12336
  });
12315
12337
  const customComponents = useMemo(
12316
- () => getComponents(),
12338
+ () => getComponents(components),
12317
12339
  []
12318
12340
  );
12319
12341
  const prevOptions = useRef(
@@ -13865,10 +13887,28 @@ var __objRest = (source, exclude) => {
13865
13887
  }
13866
13888
  return target;
13867
13889
  };
13890
+ const { Option: ChakraOption } = chakraComponents;
13868
13891
  const customComponents = {
13869
13892
  Option: (_a) => {
13870
13893
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
13871
- return /* @__PURE__ */ React.createElement(chakraComponents.Option, __spreadValues$1({}, props), /* @__PURE__ */ React.createElement(React.Fragment, null, props.data.isCreation ? /* @__PURE__ */ React.createElement(Flex, { mr: 3, width: 1.5, mb: 0.5, justifyContent: "center", alignItems: "center" }, /* @__PURE__ */ React.createElement(Icon$1, { mb: "4px", as: PlusSolid, color: "brand" })) : /* @__PURE__ */ React.createElement(Box, { mr: 3, width: 1.5 }), children));
13894
+ return /* @__PURE__ */ React.createElement(ChakraOption, __spreadValues$1({}, props), props.data.isCreation && /* @__PURE__ */ React.createElement(
13895
+ Flex,
13896
+ {
13897
+ mr: 3,
13898
+ width: 1.5,
13899
+ mb: 0.5,
13900
+ justifyContent: "center",
13901
+ alignItems: "center"
13902
+ },
13903
+ /* @__PURE__ */ React.createElement(Icon$1, { as: PlusSolid, color: "brand" })
13904
+ ), !props.data.isCreation && /* @__PURE__ */ React.createElement(Box, { mr: 3, width: 1.5 }), /* @__PURE__ */ React.createElement(
13905
+ Text,
13906
+ {
13907
+ color: props.data.isCreation ? "text.brand" : "text.default",
13908
+ fontWeight: props.data.isCreation ? "semibold" : "normal"
13909
+ },
13910
+ children
13911
+ ));
13872
13912
  }
13873
13913
  };
13874
13914
 
@@ -13891,70 +13931,67 @@ var __spreadValues = (a, b) => {
13891
13931
  return a;
13892
13932
  };
13893
13933
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
13934
+ const CREATION_OPTION_VALUE = "add_field";
13894
13935
  const CreatableSelectDropdown = ({
13895
13936
  standardOptions,
13896
13937
  initialPlaceholder = "Select or create...",
13897
- addOptionPlaceholder = "Enter text...",
13938
+ addOptionPlaceholder = "Select or create...",
13898
13939
  creationOption = {
13899
- label: "Add option...",
13900
- value: "Add option...",
13940
+ label: "Add field",
13941
+ value: CREATION_OPTION_VALUE,
13901
13942
  isCreation: true
13902
13943
  },
13903
13944
  onOptionChange,
13904
- width = "100%",
13905
13945
  variant = "outline",
13906
13946
  defaultValue,
13907
13947
  value,
13908
13948
  menuPlacement = "bottom"
13909
13949
  }) => {
13910
- const initialSelectedOption = useMemo(
13911
- () => {
13912
- var _a, _b;
13913
- if (!isNil(value)) {
13914
- return (_a = standardOptions.find((option) => option.value === value)) != null ? _a : null;
13915
- }
13916
- if (!isNil(defaultValue)) {
13917
- return (_b = standardOptions.find((option) => option.value === defaultValue)) != null ? _b : null;
13918
- }
13919
- return null;
13920
- },
13921
- [value]
13922
- );
13923
- const [selectedOption, setSelectedOption] = useState(initialSelectedOption);
13924
- const [newOptionText, setNewOptionText] = useState("");
13950
+ const [selectedOption, setSelectedOption] = useState(() => {
13951
+ var _a, _b;
13952
+ const targetValue = (_a = value != null ? value : defaultValue) != null ? _a : null;
13953
+ return targetValue ? (_b = standardOptions.find((option) => option.value === targetValue)) != null ? _b : null : null;
13954
+ });
13925
13955
  const [newOptionPlaceholder, setNewOptionPlaceholder] = useState(initialPlaceholder);
13926
13956
  const [createdOptions, setCreatedOptions] = useState([]);
13957
+ const [createNewOption, setCreateNewOption] = useState(false);
13958
+ const [addFieldInputValue, setAddFieldInputValue] = useState("");
13927
13959
  function isCreationOption(option) {
13928
13960
  return option && typeof option.isCreation === "boolean";
13929
13961
  }
13930
13962
  const ref = useRef(null);
13931
- useOutsideClick({
13932
- ref,
13933
- handler: () => {
13934
- if (isCreationOption(selectedOption)) {
13935
- setSelectedOption(initialSelectedOption);
13936
- setNewOptionPlaceholder(initialPlaceholder);
13937
- }
13963
+ const checkIfNewOptionTextExistsInOptions = (string, options) => any((option) => toLower(option.value) === string, options);
13964
+ const handleCreateOption = (newOptionTextString) => {
13965
+ setCreateNewOption(true);
13966
+ if (isEmpty(trim(newOptionTextString))) {
13967
+ return;
13938
13968
  }
13939
- });
13940
- const handleInputChange = (newValue) => {
13941
- setNewOptionText(newValue);
13942
- };
13943
- const handleCreateOption = () => {
13944
- const newOptionTextLower = newOptionText.toLowerCase();
13945
- const newOptionExists = standardOptions.some((option) => option.value.toLowerCase() === newOptionTextLower);
13946
- if (!newOptionExists) {
13947
- const newOption = { label: newOptionText, value: newOptionText };
13948
- setCreatedOptions((currentCreatedOptions) => [...currentCreatedOptions, newOption]);
13969
+ const newOptionTextLower = toLower(newOptionTextString);
13970
+ const newOptionExistsInStandardOptions = checkIfNewOptionTextExistsInOptions(newOptionTextLower, standardOptions);
13971
+ const newOptionExistsInCreatedOptions = checkIfNewOptionTextExistsInOptions(
13972
+ newOptionTextLower,
13973
+ createdOptions
13974
+ );
13975
+ if (!newOptionExistsInCreatedOptions && !newOptionExistsInStandardOptions) {
13976
+ const newOption = {
13977
+ label: newOptionTextString,
13978
+ value: newOptionTextString
13979
+ };
13980
+ setCreatedOptions((currentCreatedOptions) => [
13981
+ ...currentCreatedOptions,
13982
+ newOption
13983
+ ]);
13949
13984
  setSelectedOption(newOption);
13950
13985
  onOptionChange(newOption);
13951
13986
  }
13952
- setNewOptionText("");
13953
13987
  setNewOptionPlaceholder(initialPlaceholder);
13954
13988
  };
13955
13989
  const handleChange = (newValue, _actionMeta) => {
13956
13990
  const option = newValue;
13957
- if (option === null) {
13991
+ if (newValue == null ? void 0 : newValue.isCreation) {
13992
+ setCreateNewOption(true);
13993
+ }
13994
+ if (option == null) {
13958
13995
  return;
13959
13996
  }
13960
13997
  if (isCreationOption(option)) {
@@ -13962,14 +13999,10 @@ const CreatableSelectDropdown = ({
13962
13999
  } else {
13963
14000
  setNewOptionPlaceholder(initialPlaceholder);
13964
14001
  }
13965
- setSelectedOption(option);
13966
- onOptionChange(option);
13967
- };
13968
- const handleKeyDown = (event) => {
13969
- if (event.key === "Enter" && newOptionText) {
13970
- handleCreateOption();
13971
- event.preventDefault();
14002
+ if (option.value !== CREATION_OPTION_VALUE) {
14003
+ setSelectedOption(option);
13972
14004
  }
14005
+ onOptionChange(option);
13973
14006
  };
13974
14007
  const combinedOptions = [...standardOptions, ...createdOptions];
13975
14008
  const customOptions = [
@@ -13978,13 +14011,36 @@ const CreatableSelectDropdown = ({
13978
14011
  }),
13979
14012
  ...combinedOptions
13980
14013
  ];
13981
- return /* @__PURE__ */ React.createElement(Box, { ref }, /* @__PURE__ */ React.createElement(
14014
+ return /* @__PURE__ */ React.createElement(Box, { ref, w: "sm", maxW: "full" }, createNewOption && /* @__PURE__ */ React.createElement(
14015
+ EditableText,
14016
+ {
14017
+ value: addFieldInputValue,
14018
+ startWithEditView: true,
14019
+ onChange: (v) => {
14020
+ setAddFieldInputValue(v);
14021
+ },
14022
+ submitOnBlur: false,
14023
+ onCancel: () => {
14024
+ setAddFieldInputValue("");
14025
+ setCreateNewOption(false);
14026
+ },
14027
+ onSubmit: (v) => {
14028
+ handleCreateOption(v);
14029
+ setCreateNewOption(false);
14030
+ },
14031
+ variant: "brand",
14032
+ sx: {
14033
+ minWidth: "100%",
14034
+ width: "100%"
14035
+ }
14036
+ }
14037
+ ), !createNewOption && /* @__PURE__ */ React.createElement(
13982
14038
  CreatableSelect,
13983
14039
  {
13984
14040
  menuPlacement,
13985
14041
  chakraStyles: __spreadProps(__spreadValues({}, customSelectStyles), {
13986
14042
  container: (provided) => __spreadProps(__spreadValues({}, provided), {
13987
- width
14043
+ width: "100%"
13988
14044
  }),
13989
14045
  option: (provided, { isSelected }) => __spreadValues(__spreadValues({}, provided), isSelected && {
13990
14046
  color: "black"
@@ -13995,11 +14051,11 @@ const CreatableSelectDropdown = ({
13995
14051
  value: selectedOption,
13996
14052
  onChange: handleChange,
13997
14053
  isMulti: false,
13998
- onInputChange: handleInputChange,
13999
- onKeyDown: handleKeyDown,
14000
- onCreateOption: handleCreateOption,
14054
+ onCreateOption: (v) => {
14055
+ setCreateNewOption(true);
14056
+ setAddFieldInputValue(v);
14057
+ },
14001
14058
  placeholder: newOptionPlaceholder,
14002
- inputValue: newOptionText,
14003
14059
  useBasicStyles: true,
14004
14060
  variant
14005
14061
  }