@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.
- package/dist/es/northlight.d.ts +8 -73
- package/dist/es/northlight.js +205 -149
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +207 -147
- package/dist/umd/northlight.cjs.map +1 -1
- package/dist/umd/northlight.min.cjs +3 -3
- package/dist/umd/northlight.min.cjs.map +1 -1
- package/package.json +2 -2
package/dist/umd/northlight.cjs
CHANGED
|
@@ -3997,91 +3997,94 @@
|
|
|
3997
3997
|
radii: borderRadius,
|
|
3998
3998
|
borders: borderWidth,
|
|
3999
3999
|
opacity
|
|
4000
|
-
}, isReadOnly }) =>
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
minWidth: sizing["44"],
|
|
4006
|
-
paddingInlineStart: spacing["padding-inline"].input.default,
|
|
4007
|
-
paddingInlineEnd: spacing["padding-inline"].input.default,
|
|
4008
|
-
WebkitPaddingStart: spacing["padding-inline"].input.default,
|
|
4009
|
-
WebkitPaddingEnd: spacing["padding-inline"].input.default,
|
|
4010
|
-
color: color.text.default,
|
|
4011
|
-
bg: color.background.input["outline-default"],
|
|
4012
|
-
borderWidth: borderWidth.input.default,
|
|
4013
|
-
borderColor: color.border.input.default,
|
|
4014
|
-
paddingRight: spacing.paddingRight["number-input"].field,
|
|
4015
|
-
_hover: {
|
|
4016
|
-
bg: color.background.input["outline-hover"],
|
|
4017
|
-
borderColor: color.border.input["default-hover"]
|
|
4018
|
-
},
|
|
4019
|
-
_focusVisible: {
|
|
4020
|
-
bg: color.background.input["outline-focus"],
|
|
4021
|
-
borderColor: color.border.input.focus,
|
|
4022
|
-
boxShadow: `0 0 0 1px ${color.border.textarea.focus}`
|
|
4023
|
-
},
|
|
4024
|
-
_invalid: {
|
|
4025
|
-
bg: color.background.input["outline-error"],
|
|
4026
|
-
borderColor: color.border.input.error,
|
|
4027
|
-
boxShadow: `0 0 0 1px ${color.border.input.error}`
|
|
4028
|
-
},
|
|
4029
|
-
_disabled: {
|
|
4030
|
-
bg: color.background.input["outline-disabled"],
|
|
4031
|
-
opacity: opacity.input.disabled,
|
|
4032
|
-
borderColor: color.border.input.disabled
|
|
4000
|
+
}, isReadOnly, minWidth, minW }) => {
|
|
4001
|
+
var _a;
|
|
4002
|
+
return {
|
|
4003
|
+
root: {
|
|
4004
|
+
borderRadius: borderRadius.input.outline
|
|
4033
4005
|
},
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
width: "auto",
|
|
4046
|
-
paddingRight: spacing.paddingRight["number-input"].stepper
|
|
4047
|
-
},
|
|
4048
|
-
stepper: {
|
|
4049
|
-
_first: {
|
|
4050
|
-
border: "none",
|
|
4051
|
-
borderTopRightRadius: borderRadius["input-stepper"].default,
|
|
4052
|
-
borderRadius: borderRadius["input-stepper"].default,
|
|
4053
|
-
bg: color.background["input-stepper"].default,
|
|
4054
|
-
opacity: isReadOnly ? opacity.input.disabled : "auto",
|
|
4006
|
+
field: {
|
|
4007
|
+
minWidth: (_a = minWidth != null ? minWidth : minW) != null ? _a : sizing["44"],
|
|
4008
|
+
paddingInlineStart: spacing["padding-inline"].input.default,
|
|
4009
|
+
paddingInlineEnd: spacing["padding-inline"].input.default,
|
|
4010
|
+
WebkitPaddingStart: spacing["padding-inline"].input.default,
|
|
4011
|
+
WebkitPaddingEnd: spacing["padding-inline"].input.default,
|
|
4012
|
+
color: color.text.default,
|
|
4013
|
+
bg: color.background.input["outline-default"],
|
|
4014
|
+
borderWidth: borderWidth.input.default,
|
|
4015
|
+
borderColor: color.border.input.default,
|
|
4016
|
+
paddingRight: spacing.paddingRight["number-input"].field,
|
|
4055
4017
|
_hover: {
|
|
4056
|
-
bg:
|
|
4018
|
+
bg: color.background.input["outline-hover"],
|
|
4019
|
+
borderColor: color.border.input["default-hover"]
|
|
4057
4020
|
},
|
|
4058
|
-
|
|
4059
|
-
bg: color.background["
|
|
4021
|
+
_focusVisible: {
|
|
4022
|
+
bg: color.background.input["outline-focus"],
|
|
4023
|
+
borderColor: color.border.input.focus,
|
|
4024
|
+
boxShadow: `0 0 0 1px ${color.border.textarea.focus}`
|
|
4025
|
+
},
|
|
4026
|
+
_invalid: {
|
|
4027
|
+
bg: color.background.input["outline-error"],
|
|
4028
|
+
borderColor: color.border.input.error,
|
|
4029
|
+
boxShadow: `0 0 0 1px ${color.border.input.error}`
|
|
4060
4030
|
},
|
|
4061
4031
|
_disabled: {
|
|
4062
|
-
bg: color.background["
|
|
4063
|
-
|
|
4032
|
+
bg: color.background.input["outline-disabled"],
|
|
4033
|
+
opacity: opacity.input.disabled,
|
|
4034
|
+
borderColor: color.border.input.disabled
|
|
4035
|
+
},
|
|
4036
|
+
_readOnly: {
|
|
4037
|
+
_focusVisible: {
|
|
4038
|
+
borderColor: color.border.input.readonly,
|
|
4039
|
+
boxShadow: "none"
|
|
4040
|
+
},
|
|
4041
|
+
_hover: {
|
|
4042
|
+
borderColor: color.border.input.readonly
|
|
4043
|
+
}
|
|
4064
4044
|
}
|
|
4065
4045
|
},
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4046
|
+
stepperGroup: {
|
|
4047
|
+
width: "auto",
|
|
4048
|
+
paddingRight: spacing.paddingRight["number-input"].stepper
|
|
4049
|
+
},
|
|
4050
|
+
stepper: {
|
|
4051
|
+
_first: {
|
|
4052
|
+
border: "none",
|
|
4053
|
+
borderTopRightRadius: borderRadius["input-stepper"].default,
|
|
4054
|
+
borderRadius: borderRadius["input-stepper"].default,
|
|
4055
|
+
bg: color.background["input-stepper"].default,
|
|
4056
|
+
opacity: isReadOnly ? opacity.input.disabled : "auto",
|
|
4057
|
+
_hover: {
|
|
4058
|
+
bg: isReadOnly ? "none" : color.background["input-stepper"].hover
|
|
4059
|
+
},
|
|
4060
|
+
_active: {
|
|
4061
|
+
bg: color.background["input-stepper"].active
|
|
4062
|
+
},
|
|
4063
|
+
_disabled: {
|
|
4064
|
+
bg: color.background["input-stepper"].disabled,
|
|
4065
|
+
color: color.icon["input-stepper"].disabled
|
|
4066
|
+
}
|
|
4077
4067
|
},
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4068
|
+
_last: {
|
|
4069
|
+
border: "none",
|
|
4070
|
+
bg: color.background["input-stepper"].default,
|
|
4071
|
+
borderBottomRightRadius: borderRadius["input-stepper"].default,
|
|
4072
|
+
borderRadius: borderRadius["input-stepper"].default,
|
|
4073
|
+
opacity: isReadOnly ? opacity.input.disabled : "auto",
|
|
4074
|
+
_hover: {
|
|
4075
|
+
bg: isReadOnly ? "none" : color.background["input-stepper"].hover
|
|
4076
|
+
},
|
|
4077
|
+
_active: {
|
|
4078
|
+
bg: color.background["input-stepper"].active
|
|
4079
|
+
},
|
|
4080
|
+
_disabled: {
|
|
4081
|
+
bg: color.background["input-stepper"].disabled,
|
|
4082
|
+
color: color.icon["input-stepper"].disabled
|
|
4083
|
+
}
|
|
4081
4084
|
}
|
|
4082
4085
|
}
|
|
4083
|
-
}
|
|
4084
|
-
}
|
|
4086
|
+
};
|
|
4087
|
+
}
|
|
4085
4088
|
};
|
|
4086
4089
|
|
|
4087
4090
|
const NotificationIconButton$1 = {
|
|
@@ -8913,17 +8916,24 @@
|
|
|
8913
8916
|
}
|
|
8914
8917
|
return target;
|
|
8915
8918
|
};
|
|
8916
|
-
function getComponents() {
|
|
8917
|
-
return
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8919
|
+
function getComponents(components) {
|
|
8920
|
+
return ramda.merge(
|
|
8921
|
+
{
|
|
8922
|
+
Menu: (props) => /* @__PURE__ */ React.createElement(react.Box, { "data-testid": "select-menu-wrapper-test-id" }, /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.Menu, __spreadValues$12({}, props), props.children)),
|
|
8923
|
+
DropdownIndicator: (props) => props.selectProps.icon ? /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.DropdownIndicator, __spreadValues$12({}, props), /* @__PURE__ */ React.createElement(Icon$1, { as: props.selectProps.icon })) : /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.DropdownIndicator, __spreadValues$12({}, props)),
|
|
8924
|
+
Option: (props) => props.selectProps.customOption ? /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.Option, __spreadValues$12({}, props), props.selectProps.customOption(props.data)) : /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.Option, __spreadValues$12({}, props)),
|
|
8925
|
+
MultiValueContainer: (props) => props.selectProps.customTag ? /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.MultiValueContainer, __spreadValues$12({}, props), props.selectProps.customTag(props.data)) : /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.MultiValueContainer, __spreadValues$12({}, props)),
|
|
8926
|
+
Control: (_a) => {
|
|
8927
|
+
var _b = _a, {
|
|
8928
|
+
children
|
|
8929
|
+
} = _b, props = __objRest$R(_b, [
|
|
8930
|
+
"children"
|
|
8931
|
+
]);
|
|
8932
|
+
return props.selectProps.leftComponent ? /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.Control, __spreadValues$12({}, props), /* @__PURE__ */ React.createElement(react.HStack, { w: "full", pl: "2" }, props.selectProps.leftComponent, /* @__PURE__ */ React.createElement(react.HStack, { w: "full", justify: "space-between" }, children))) : /* @__PURE__ */ React.createElement(chakraReactSelect.chakraComponents.Control, __spreadValues$12({}, props), children);
|
|
8933
|
+
}
|
|
8934
|
+
},
|
|
8935
|
+
components || {}
|
|
8936
|
+
);
|
|
8927
8937
|
}
|
|
8928
8938
|
|
|
8929
8939
|
var __defProp$11 = Object.defineProperty;
|
|
@@ -9987,7 +9997,15 @@
|
|
|
9987
9997
|
}
|
|
9988
9998
|
return a;
|
|
9989
9999
|
};
|
|
9990
|
-
const
|
|
10000
|
+
const mapEditableVariantsToButtonSubmitVariants = {
|
|
10001
|
+
brand: "brand",
|
|
10002
|
+
default: "success"
|
|
10003
|
+
};
|
|
10004
|
+
const mapEditableVariantsToButtonCancelVariants = {
|
|
10005
|
+
brand: "ghost",
|
|
10006
|
+
default: "danger"
|
|
10007
|
+
};
|
|
10008
|
+
const EditableControls = ({ size, variant = "default" }) => {
|
|
9991
10009
|
const {
|
|
9992
10010
|
getSubmitButtonProps,
|
|
9993
10011
|
getCancelButtonProps
|
|
@@ -9999,7 +10017,7 @@
|
|
|
9999
10017
|
__spreadValues$O({
|
|
10000
10018
|
"aria-label": "Cancel",
|
|
10001
10019
|
sx: button,
|
|
10002
|
-
variant:
|
|
10020
|
+
variant: mapEditableVariantsToButtonCancelVariants[variant]
|
|
10003
10021
|
}, getCancelButtonProps()),
|
|
10004
10022
|
/* @__PURE__ */ React.createElement(Icon$1, { sx: icon, as: icons.XCloseSolid })
|
|
10005
10023
|
), /* @__PURE__ */ React.createElement(
|
|
@@ -10007,7 +10025,7 @@
|
|
|
10007
10025
|
__spreadValues$O({
|
|
10008
10026
|
"aria-label": "Save",
|
|
10009
10027
|
sx: button,
|
|
10010
|
-
variant:
|
|
10028
|
+
variant: mapEditableVariantsToButtonSubmitVariants[variant]
|
|
10011
10029
|
}, getSubmitButtonProps()),
|
|
10012
10030
|
/* @__PURE__ */ React.createElement(Icon$1, { sx: icon, as: icons.CheckDuo })
|
|
10013
10031
|
)) : /* @__PURE__ */ React.createElement(
|
|
@@ -10055,12 +10073,14 @@
|
|
|
10055
10073
|
size = "md",
|
|
10056
10074
|
value: inputValue,
|
|
10057
10075
|
onSubmit,
|
|
10058
|
-
leftItem
|
|
10076
|
+
leftItem,
|
|
10077
|
+
variant = "default"
|
|
10059
10078
|
} = _b, rest = __objRest$E(_b, [
|
|
10060
10079
|
"size",
|
|
10061
10080
|
"value",
|
|
10062
10081
|
"onSubmit",
|
|
10063
|
-
"leftItem"
|
|
10082
|
+
"leftItem",
|
|
10083
|
+
"variant"
|
|
10064
10084
|
]);
|
|
10065
10085
|
const [value, setValue] = React.useState(inputValue);
|
|
10066
10086
|
const { input, preview } = react.useMultiStyleConfig("EditableText", { size, value });
|
|
@@ -10089,7 +10109,7 @@
|
|
|
10089
10109
|
size,
|
|
10090
10110
|
sx: input
|
|
10091
10111
|
}
|
|
10092
|
-
), /* @__PURE__ */ React.createElement(react.InputRightElement, { sx: { width: "min-content" } }, /* @__PURE__ */ React.createElement(EditableControls, { size })))
|
|
10112
|
+
), /* @__PURE__ */ React.createElement(react.InputRightElement, { sx: { width: "min-content" } }, /* @__PURE__ */ React.createElement(EditableControls, { size, variant })))
|
|
10093
10113
|
);
|
|
10094
10114
|
};
|
|
10095
10115
|
|
|
@@ -12252,7 +12272,8 @@
|
|
|
12252
12272
|
customTag = null,
|
|
12253
12273
|
isClearable = false,
|
|
12254
12274
|
value,
|
|
12255
|
-
icon
|
|
12275
|
+
icon,
|
|
12276
|
+
components
|
|
12256
12277
|
} = _b, rest = __objRest$l(_b, [
|
|
12257
12278
|
"options",
|
|
12258
12279
|
"isMulti",
|
|
@@ -12266,7 +12287,8 @@
|
|
|
12266
12287
|
"customTag",
|
|
12267
12288
|
"isClearable",
|
|
12268
12289
|
"value",
|
|
12269
|
-
"icon"
|
|
12290
|
+
"icon",
|
|
12291
|
+
"components"
|
|
12270
12292
|
]);
|
|
12271
12293
|
const handleChange = useSelectCallbacks({
|
|
12272
12294
|
onChange,
|
|
@@ -12276,7 +12298,7 @@
|
|
|
12276
12298
|
value: ramda.is(Array, value) ? value : []
|
|
12277
12299
|
});
|
|
12278
12300
|
const customComponents = React.useMemo(
|
|
12279
|
-
() => getComponents(),
|
|
12301
|
+
() => getComponents(components),
|
|
12280
12302
|
[]
|
|
12281
12303
|
);
|
|
12282
12304
|
const prevOptions = React.useRef(
|
|
@@ -13828,10 +13850,28 @@
|
|
|
13828
13850
|
}
|
|
13829
13851
|
return target;
|
|
13830
13852
|
};
|
|
13853
|
+
const { Option: ChakraOption } = chakraReactSelect.chakraComponents;
|
|
13831
13854
|
const customComponents = {
|
|
13832
13855
|
Option: (_a) => {
|
|
13833
13856
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
13834
|
-
return /* @__PURE__ */ React.createElement(
|
|
13857
|
+
return /* @__PURE__ */ React.createElement(ChakraOption, __spreadValues$1({}, props), props.data.isCreation && /* @__PURE__ */ React.createElement(
|
|
13858
|
+
react.Flex,
|
|
13859
|
+
{
|
|
13860
|
+
mr: 3,
|
|
13861
|
+
width: 1.5,
|
|
13862
|
+
mb: 0.5,
|
|
13863
|
+
justifyContent: "center",
|
|
13864
|
+
alignItems: "center"
|
|
13865
|
+
},
|
|
13866
|
+
/* @__PURE__ */ React.createElement(Icon$1, { as: icons.PlusSolid, color: "brand" })
|
|
13867
|
+
), !props.data.isCreation && /* @__PURE__ */ React.createElement(react.Box, { mr: 3, width: 1.5 }), /* @__PURE__ */ React.createElement(
|
|
13868
|
+
react.Text,
|
|
13869
|
+
{
|
|
13870
|
+
color: props.data.isCreation ? "text.brand" : "text.default",
|
|
13871
|
+
fontWeight: props.data.isCreation ? "semibold" : "normal"
|
|
13872
|
+
},
|
|
13873
|
+
children
|
|
13874
|
+
));
|
|
13835
13875
|
}
|
|
13836
13876
|
};
|
|
13837
13877
|
|
|
@@ -13854,70 +13894,67 @@
|
|
|
13854
13894
|
return a;
|
|
13855
13895
|
};
|
|
13856
13896
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
13897
|
+
const CREATION_OPTION_VALUE = "add_field";
|
|
13857
13898
|
const CreatableSelectDropdown = ({
|
|
13858
13899
|
standardOptions,
|
|
13859
13900
|
initialPlaceholder = "Select or create...",
|
|
13860
|
-
addOptionPlaceholder = "
|
|
13901
|
+
addOptionPlaceholder = "Select or create...",
|
|
13861
13902
|
creationOption = {
|
|
13862
|
-
label: "Add
|
|
13863
|
-
value:
|
|
13903
|
+
label: "Add field",
|
|
13904
|
+
value: CREATION_OPTION_VALUE,
|
|
13864
13905
|
isCreation: true
|
|
13865
13906
|
},
|
|
13866
13907
|
onOptionChange,
|
|
13867
|
-
width = "100%",
|
|
13868
13908
|
variant = "outline",
|
|
13869
13909
|
defaultValue,
|
|
13870
13910
|
value,
|
|
13871
13911
|
menuPlacement = "bottom"
|
|
13872
13912
|
}) => {
|
|
13873
|
-
const
|
|
13874
|
-
|
|
13875
|
-
|
|
13876
|
-
|
|
13877
|
-
|
|
13878
|
-
}
|
|
13879
|
-
if (!ramda.isNil(defaultValue)) {
|
|
13880
|
-
return (_b = standardOptions.find((option) => option.value === defaultValue)) != null ? _b : null;
|
|
13881
|
-
}
|
|
13882
|
-
return null;
|
|
13883
|
-
},
|
|
13884
|
-
[value]
|
|
13885
|
-
);
|
|
13886
|
-
const [selectedOption, setSelectedOption] = React.useState(initialSelectedOption);
|
|
13887
|
-
const [newOptionText, setNewOptionText] = React.useState("");
|
|
13913
|
+
const [selectedOption, setSelectedOption] = React.useState(() => {
|
|
13914
|
+
var _a, _b;
|
|
13915
|
+
const targetValue = (_a = value != null ? value : defaultValue) != null ? _a : null;
|
|
13916
|
+
return targetValue ? (_b = standardOptions.find((option) => option.value === targetValue)) != null ? _b : null : null;
|
|
13917
|
+
});
|
|
13888
13918
|
const [newOptionPlaceholder, setNewOptionPlaceholder] = React.useState(initialPlaceholder);
|
|
13889
13919
|
const [createdOptions, setCreatedOptions] = React.useState([]);
|
|
13920
|
+
const [createNewOption, setCreateNewOption] = React.useState(false);
|
|
13921
|
+
const [addFieldInputValue, setAddFieldInputValue] = React.useState("");
|
|
13890
13922
|
function isCreationOption(option) {
|
|
13891
13923
|
return option && typeof option.isCreation === "boolean";
|
|
13892
13924
|
}
|
|
13893
13925
|
const ref = React.useRef(null);
|
|
13894
|
-
|
|
13895
|
-
|
|
13896
|
-
|
|
13897
|
-
|
|
13898
|
-
|
|
13899
|
-
setNewOptionPlaceholder(initialPlaceholder);
|
|
13900
|
-
}
|
|
13926
|
+
const checkIfNewOptionTextExistsInOptions = (string, options) => ramda.any((option) => ramda.toLower(option.value) === string, options);
|
|
13927
|
+
const handleCreateOption = (newOptionTextString) => {
|
|
13928
|
+
setCreateNewOption(true);
|
|
13929
|
+
if (ramda.isEmpty(ramda.trim(newOptionTextString))) {
|
|
13930
|
+
return;
|
|
13901
13931
|
}
|
|
13902
|
-
|
|
13903
|
-
|
|
13904
|
-
|
|
13905
|
-
|
|
13906
|
-
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
|
|
13932
|
+
const newOptionTextLower = ramda.toLower(newOptionTextString);
|
|
13933
|
+
const newOptionExistsInStandardOptions = checkIfNewOptionTextExistsInOptions(newOptionTextLower, standardOptions);
|
|
13934
|
+
const newOptionExistsInCreatedOptions = checkIfNewOptionTextExistsInOptions(
|
|
13935
|
+
newOptionTextLower,
|
|
13936
|
+
createdOptions
|
|
13937
|
+
);
|
|
13938
|
+
if (!newOptionExistsInCreatedOptions && !newOptionExistsInStandardOptions) {
|
|
13939
|
+
const newOption = {
|
|
13940
|
+
label: newOptionTextString,
|
|
13941
|
+
value: newOptionTextString
|
|
13942
|
+
};
|
|
13943
|
+
setCreatedOptions((currentCreatedOptions) => [
|
|
13944
|
+
...currentCreatedOptions,
|
|
13945
|
+
newOption
|
|
13946
|
+
]);
|
|
13912
13947
|
setSelectedOption(newOption);
|
|
13913
13948
|
onOptionChange(newOption);
|
|
13914
13949
|
}
|
|
13915
|
-
setNewOptionText("");
|
|
13916
13950
|
setNewOptionPlaceholder(initialPlaceholder);
|
|
13917
13951
|
};
|
|
13918
13952
|
const handleChange = (newValue, _actionMeta) => {
|
|
13919
13953
|
const option = newValue;
|
|
13920
|
-
if (
|
|
13954
|
+
if (newValue == null ? void 0 : newValue.isCreation) {
|
|
13955
|
+
setCreateNewOption(true);
|
|
13956
|
+
}
|
|
13957
|
+
if (option == null) {
|
|
13921
13958
|
return;
|
|
13922
13959
|
}
|
|
13923
13960
|
if (isCreationOption(option)) {
|
|
@@ -13925,14 +13962,10 @@
|
|
|
13925
13962
|
} else {
|
|
13926
13963
|
setNewOptionPlaceholder(initialPlaceholder);
|
|
13927
13964
|
}
|
|
13928
|
-
|
|
13929
|
-
|
|
13930
|
-
};
|
|
13931
|
-
const handleKeyDown = (event) => {
|
|
13932
|
-
if (event.key === "Enter" && newOptionText) {
|
|
13933
|
-
handleCreateOption();
|
|
13934
|
-
event.preventDefault();
|
|
13965
|
+
if (option.value !== CREATION_OPTION_VALUE) {
|
|
13966
|
+
setSelectedOption(option);
|
|
13935
13967
|
}
|
|
13968
|
+
onOptionChange(option);
|
|
13936
13969
|
};
|
|
13937
13970
|
const combinedOptions = [...standardOptions, ...createdOptions];
|
|
13938
13971
|
const customOptions = [
|
|
@@ -13941,13 +13974,36 @@
|
|
|
13941
13974
|
}),
|
|
13942
13975
|
...combinedOptions
|
|
13943
13976
|
];
|
|
13944
|
-
return /* @__PURE__ */ React.createElement(react.Box, { ref }, /* @__PURE__ */ React.createElement(
|
|
13977
|
+
return /* @__PURE__ */ React.createElement(react.Box, { ref, w: "sm", maxW: "full" }, createNewOption && /* @__PURE__ */ React.createElement(
|
|
13978
|
+
EditableText,
|
|
13979
|
+
{
|
|
13980
|
+
value: addFieldInputValue,
|
|
13981
|
+
startWithEditView: true,
|
|
13982
|
+
onChange: (v) => {
|
|
13983
|
+
setAddFieldInputValue(v);
|
|
13984
|
+
},
|
|
13985
|
+
submitOnBlur: false,
|
|
13986
|
+
onCancel: () => {
|
|
13987
|
+
setAddFieldInputValue("");
|
|
13988
|
+
setCreateNewOption(false);
|
|
13989
|
+
},
|
|
13990
|
+
onSubmit: (v) => {
|
|
13991
|
+
handleCreateOption(v);
|
|
13992
|
+
setCreateNewOption(false);
|
|
13993
|
+
},
|
|
13994
|
+
variant: "brand",
|
|
13995
|
+
sx: {
|
|
13996
|
+
minWidth: "100%",
|
|
13997
|
+
width: "100%"
|
|
13998
|
+
}
|
|
13999
|
+
}
|
|
14000
|
+
), !createNewOption && /* @__PURE__ */ React.createElement(
|
|
13945
14001
|
chakraReactSelect.CreatableSelect,
|
|
13946
14002
|
{
|
|
13947
14003
|
menuPlacement,
|
|
13948
14004
|
chakraStyles: __spreadProps(__spreadValues({}, customSelectStyles), {
|
|
13949
14005
|
container: (provided) => __spreadProps(__spreadValues({}, provided), {
|
|
13950
|
-
width
|
|
14006
|
+
width: "100%"
|
|
13951
14007
|
}),
|
|
13952
14008
|
option: (provided, { isSelected }) => __spreadValues(__spreadValues({}, provided), isSelected && {
|
|
13953
14009
|
color: "black"
|
|
@@ -13958,11 +14014,11 @@
|
|
|
13958
14014
|
value: selectedOption,
|
|
13959
14015
|
onChange: handleChange,
|
|
13960
14016
|
isMulti: false,
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
|
|
14017
|
+
onCreateOption: (v) => {
|
|
14018
|
+
setCreateNewOption(true);
|
|
14019
|
+
setAddFieldInputValue(v);
|
|
14020
|
+
},
|
|
13964
14021
|
placeholder: newOptionPlaceholder,
|
|
13965
|
-
inputValue: newOptionText,
|
|
13966
14022
|
useBasicStyles: true,
|
|
13967
14023
|
variant
|
|
13968
14024
|
}
|
|
@@ -14645,6 +14701,10 @@
|
|
|
14645
14701
|
enumerable: true,
|
|
14646
14702
|
get: function () { return chakraReactSelect.CreatableSelect; }
|
|
14647
14703
|
});
|
|
14704
|
+
Object.defineProperty(exports, 'selectChakraComponents', {
|
|
14705
|
+
enumerable: true,
|
|
14706
|
+
get: function () { return chakraReactSelect.chakraComponents; }
|
|
14707
|
+
});
|
|
14648
14708
|
Object.defineProperty(exports, 'useController', {
|
|
14649
14709
|
enumerable: true,
|
|
14650
14710
|
get: function () { return reactHookForm.useController; }
|