@northlight/ui 2.24.1 → 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.
@@ -12199,6 +12199,7 @@
12199
12199
  "data-testid": testId,
12200
12200
  customOption = null,
12201
12201
  customTag = null,
12202
+ isClearable = false,
12202
12203
  value,
12203
12204
  icon
12204
12205
  } = _b, rest = __objRest$l(_b, [
@@ -12212,6 +12213,7 @@
12212
12213
  "data-testid",
12213
12214
  "customOption",
12214
12215
  "customTag",
12216
+ "isClearable",
12215
12217
  "value",
12216
12218
  "icon"
12217
12219
  ]);
@@ -12243,7 +12245,7 @@
12243
12245
  useBasicStyles: true,
12244
12246
  closeMenuOnSelect: !isMulti,
12245
12247
  hideSelectedOptions: false,
12246
- isClearable: false,
12248
+ isClearable,
12247
12249
  onChange: handleChange,
12248
12250
  selectedOptionStyle: "check",
12249
12251
  chakraStyles: customSelectStyles,
@@ -13809,18 +13811,35 @@
13809
13811
  onOptionChange,
13810
13812
  width = "100%",
13811
13813
  variant = "outline",
13812
- initialValue = ""
13814
+ initialValue
13813
13815
  }) => {
13814
13816
  const initialSelectedOption = React.useMemo(
13815
- () => standardOptions.find(
13816
- (option) => option.value === initialValue
13817
- ) || 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
+ },
13818
13824
  []
13819
13825
  );
13820
13826
  const [selectedOption, setSelectedOption] = React.useState(initialSelectedOption);
13821
13827
  const [newOptionText, setNewOptionText] = React.useState("");
13822
13828
  const [newOptionPlaceholder, setNewOptionPlaceholder] = React.useState(initialPlaceholder);
13823
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
+ });
13824
13843
  const handleInputChange = (newValue) => {
13825
13844
  setNewOptionText(newValue);
13826
13845
  };
@@ -13836,9 +13855,6 @@
13836
13855
  setNewOptionText("");
13837
13856
  setNewOptionPlaceholder(initialPlaceholder);
13838
13857
  };
13839
- function isCreationOption(option) {
13840
- return option && typeof option.isCreation === "string";
13841
- }
13842
13858
  const handleChange = (newValue, _actionMeta) => {
13843
13859
  const option = newValue;
13844
13860
  if (option === null) {
@@ -13846,11 +13862,10 @@
13846
13862
  }
13847
13863
  if (isCreationOption(option)) {
13848
13864
  setNewOptionPlaceholder(addOptionPlaceholder);
13849
- setSelectedOption(null);
13850
13865
  } else {
13851
13866
  setNewOptionPlaceholder(initialPlaceholder);
13852
- setSelectedOption(option);
13853
13867
  }
13868
+ setSelectedOption(option);
13854
13869
  onOptionChange(option);
13855
13870
  };
13856
13871
  const handleKeyDown = (event) => {
@@ -13862,11 +13877,11 @@
13862
13877
  const combinedOptions = [...standardOptions, ...createdOptions];
13863
13878
  const customOptions = [
13864
13879
  __spreadProps(__spreadValues({}, creationOption), {
13865
- icon: /* @__PURE__ */ React.createElement(Icon$1, { as: icons.PlusSolid, color: "brand" })
13880
+ icon: /* @__PURE__ */ React.createElement(react.Icon, { as: icons.PlusSolid, color: "brand" })
13866
13881
  }),
13867
13882
  ...combinedOptions
13868
13883
  ];
13869
- return /* @__PURE__ */ React.createElement(
13884
+ return /* @__PURE__ */ React.createElement(react.Box, { ref }, /* @__PURE__ */ React.createElement(
13870
13885
  chakraReactSelect.CreatableSelect,
13871
13886
  {
13872
13887
  chakraStyles: __spreadProps(__spreadValues({}, customSelectStyles), {
@@ -13890,7 +13905,7 @@
13890
13905
  useBasicStyles: true,
13891
13906
  variant
13892
13907
  }
13893
- );
13908
+ ));
13894
13909
  };
13895
13910
 
13896
13911
  Object.defineProperty(exports, 'AbsoluteCenter', {