@northlight/ui 2.24.2 → 2.24.3

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.
@@ -13811,18 +13811,35 @@
13811
13811
  onOptionChange,
13812
13812
  width = "100%",
13813
13813
  variant = "outline",
13814
- initialValue = ""
13814
+ initialValue
13815
13815
  }) => {
13816
13816
  const initialSelectedOption = React.useMemo(
13817
- () => standardOptions.find(
13818
- (option) => option.value === initialValue
13819
- ) || null,
13817
+ () => {
13818
+ var _a;
13819
+ if (ramda.isNil(initialValue)) {
13820
+ return null;
13821
+ }
13822
+ return (_a = standardOptions.find((option) => option.value === initialValue)) != null ? _a : null;
13823
+ },
13820
13824
  []
13821
13825
  );
13822
13826
  const [selectedOption, setSelectedOption] = React.useState(initialSelectedOption);
13823
13827
  const [newOptionText, setNewOptionText] = React.useState("");
13824
13828
  const [newOptionPlaceholder, setNewOptionPlaceholder] = React.useState(initialPlaceholder);
13825
13829
  const [createdOptions, setCreatedOptions] = React.useState([]);
13830
+ function isCreationOption(option) {
13831
+ return option && typeof option.isCreation === "boolean";
13832
+ }
13833
+ const ref = React.useRef(null);
13834
+ react.useOutsideClick({
13835
+ ref,
13836
+ handler: () => {
13837
+ if (isCreationOption(selectedOption)) {
13838
+ setSelectedOption(initialSelectedOption);
13839
+ setNewOptionPlaceholder(initialPlaceholder);
13840
+ }
13841
+ }
13842
+ });
13826
13843
  const handleInputChange = (newValue) => {
13827
13844
  setNewOptionText(newValue);
13828
13845
  };
@@ -13838,9 +13855,6 @@
13838
13855
  setNewOptionText("");
13839
13856
  setNewOptionPlaceholder(initialPlaceholder);
13840
13857
  };
13841
- function isCreationOption(option) {
13842
- return option && typeof option.isCreation === "string";
13843
- }
13844
13858
  const handleChange = (newValue, _actionMeta) => {
13845
13859
  const option = newValue;
13846
13860
  if (option === null) {
@@ -13848,11 +13862,10 @@
13848
13862
  }
13849
13863
  if (isCreationOption(option)) {
13850
13864
  setNewOptionPlaceholder(addOptionPlaceholder);
13851
- setSelectedOption(null);
13852
13865
  } else {
13853
13866
  setNewOptionPlaceholder(initialPlaceholder);
13854
- setSelectedOption(option);
13855
13867
  }
13868
+ setSelectedOption(option);
13856
13869
  onOptionChange(option);
13857
13870
  };
13858
13871
  const handleKeyDown = (event) => {
@@ -13864,11 +13877,11 @@
13864
13877
  const combinedOptions = [...standardOptions, ...createdOptions];
13865
13878
  const customOptions = [
13866
13879
  __spreadProps(__spreadValues({}, creationOption), {
13867
- icon: /* @__PURE__ */ React.createElement(Icon$1, { as: icons.PlusSolid, color: "brand" })
13880
+ icon: /* @__PURE__ */ React.createElement(react.Icon, { as: icons.PlusSolid, color: "brand" })
13868
13881
  }),
13869
13882
  ...combinedOptions
13870
13883
  ];
13871
- return /* @__PURE__ */ React.createElement(
13884
+ return /* @__PURE__ */ React.createElement(react.Box, { ref }, /* @__PURE__ */ React.createElement(
13872
13885
  chakraReactSelect.CreatableSelect,
13873
13886
  {
13874
13887
  chakraStyles: __spreadProps(__spreadValues({}, customSelectStyles), {
@@ -13892,7 +13905,7 @@
13892
13905
  useBasicStyles: true,
13893
13906
  variant
13894
13907
  }
13895
- );
13908
+ ));
13896
13909
  };
13897
13910
 
13898
13911
  Object.defineProperty(exports, 'AbsoluteCenter', {