@ostack.tech/ui-kform 0.14.0 → 0.14.2

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.
@@ -3011,9 +3011,7 @@ const CheckboxControl = forwardRef(function CheckboxControl2({
3011
3011
  );
3012
3012
  }
3013
3013
  const [inlineIssues, popoverIssues] = useControlIssues({
3014
- issuesToDisplay: {
3015
- [absolutePath.toString()]: issuesToDisplay
3016
- },
3014
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
3017
3015
  issueMessages: { [absolutePath.toString()]: issueMessages },
3018
3016
  displayIssues,
3019
3017
  issueMessagesProps
@@ -3061,26 +3059,39 @@ function parseCheckboxValue(formattedValue, state) {
3061
3059
  function formatToCheckboxValue(value) {
3062
3060
  return value === void 0 ? false : value ?? "indeterminate";
3063
3061
  }
3064
- function parseSelectionValueFromOptionIndex(formattedValue, schema, options) {
3062
+ function isUnknownValue(value, options) {
3063
+ return value != null && value !== "" && options.every((opt) => !equals(opt.value, value));
3064
+ }
3065
+ function parseSelectionValueFromOptionIndex(formattedValue, schema, options, unknownValues) {
3065
3066
  if (formattedValue === "") {
3066
3067
  return schema.typeInfo.nullable ? null : schema.initialValue;
3068
+ } else if (formattedValue.startsWith("-")) {
3069
+ return unknownValues[-+formattedValue - 1];
3067
3070
  }
3068
3071
  return options[+formattedValue].value;
3069
3072
  }
3070
3073
  function formatSelectionValueAsOptionIndex(value, options) {
3071
3074
  const idx = options.findIndex((option) => equals(option.value, value));
3072
- return idx === -1 ? "" : idx.toString();
3075
+ return idx === -1 ? value == null || value === "" ? "" : "-1" : idx.toString();
3073
3076
  }
3074
- function parseSelectionValuesFromOptionIndices(formattedValue, schema, options) {
3075
- if (formattedValue.length === 0) {
3076
- return schema.typeInfo.nullable ? null : [];
3077
+ function getUnknownValues(arrayValue, options) {
3078
+ const unknownValues = [];
3079
+ for (const v of arrayValue ?? []) {
3080
+ if (options.every((opt) => !equals(opt.value, v)) && unknownValues.every((u) => !equals(u, v))) {
3081
+ unknownValues.push(v);
3082
+ }
3077
3083
  }
3078
- return formattedValue.map((idx) => options[+idx].value);
3084
+ return unknownValues;
3085
+ }
3086
+ function parseSelectionValuesFromOptionIndices(formattedValue, schema, options, unknownValues) {
3087
+ return formattedValue.length === 0 ? schema.typeInfo.nullable ? null : [] : formattedValue.map(
3088
+ (v) => v.startsWith("-") ? unknownValues[-+v - 1] : options[+v].value
3089
+ );
3079
3090
  }
3080
- function formatSelectionValuesAsOptionIndices(arrayValue, options) {
3091
+ function formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues) {
3081
3092
  return arrayValue?.map((v) => {
3082
3093
  const idx = options.findIndex((option) => equals(option.value, v));
3083
- return idx === -1 ? "" : idx.toString();
3094
+ return idx === -1 ? (-unknownValues.findIndex((u) => equals(u, v)) - 1).toString() : idx.toString();
3084
3095
  }) ?? [];
3085
3096
  }
3086
3097
  function optionObjectsToNodes(options) {
@@ -3091,12 +3102,35 @@ function optionObjectsToNodes(options) {
3091
3102
  ) }, key ?? i) : /* @__PURE__ */ jsx(Option, { ...optionOrGroup, value: optionIndex++, children: optionOrGroup.text ?? optionOrGroup.value?.toString() ?? "" }, key ?? i)
3092
3103
  );
3093
3104
  }
3105
+ function UnknownValue({
3106
+ value,
3107
+ label
3108
+ }) {
3109
+ const [locale7] = useLocale();
3110
+ label ??= locale7.UnknownValue.label;
3111
+ const prefix = usePrefix();
3112
+ const valueStr = value == null ? "" : String(value);
3113
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3114
+ valueStr && /* @__PURE__ */ jsxs(Fragment, { children: [
3115
+ "“",
3116
+ /* @__PURE__ */ jsx("span", { className: prefix("unknown-value"), children: valueStr }),
3117
+ "”"
3118
+ ] }),
3119
+ valueStr && label && /* @__PURE__ */ jsx(Fragment, { children: " " }),
3120
+ label && /* @__PURE__ */ jsxs("span", { className: prefix("unknown-value__label"), children: [
3121
+ "(",
3122
+ label,
3123
+ ")"
3124
+ ] })
3125
+ ] });
3126
+ }
3094
3127
  const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
3095
3128
  path,
3096
3129
  options,
3097
3130
  issueMessages,
3098
3131
  issuesPanelLabel,
3099
3132
  displayIssues = true,
3133
+ unknownValueLabel,
3100
3134
  preventAutoFocus,
3101
3135
  apiRef,
3102
3136
  issueMessagesProps,
@@ -3117,35 +3151,28 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
3117
3151
  onBlurToOutside,
3118
3152
  ...otherProps
3119
3153
  }, forwardedRef) {
3154
+ const [locale7] = useLocale();
3155
+ unknownValueLabel ??= locale7.SelectMultipleControl.unknownValueLabel;
3120
3156
  const [arrayValue, setArrayValue] = useState(null);
3121
- const formattedValue = useMemo(
3122
- () => formatSelectionValuesAsOptionIndices(arrayValue, options),
3157
+ const unknownValues = useMemo(
3158
+ () => getUnknownValues(arrayValue, options),
3123
3159
  [options, arrayValue]
3124
3160
  );
3161
+ const formattedValue = useMemo(
3162
+ () => formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),
3163
+ [options, unknownValues, arrayValue]
3164
+ );
3125
3165
  const controller = useListableInput(path, {
3126
3166
  enabled: !useFormIsLoading(),
3127
3167
  parseToArray: useCallback(
3128
- (formattedValue2, state) => parseSelectionValuesFromOptionIndices(
3129
- formattedValue2,
3130
- state.schema,
3131
- options
3132
- ),
3133
- [options]
3168
+ (formattedValue2) => formattedValue2 && [...formattedValue2],
3169
+ []
3134
3170
  ),
3135
3171
  formatFromArray: useCallback(
3136
- (arrayValue2) => formatSelectionValuesAsOptionIndices(arrayValue2, options),
3137
- [options]
3138
- ),
3139
- setFormattedValue: useCallback(
3140
- (formattedValue2, state) => setArrayValue(
3141
- parseSelectionValuesFromOptionIndices(
3142
- formattedValue2,
3143
- state.schema,
3144
- options
3145
- )
3146
- ),
3147
- [options]
3172
+ (arrayValue2) => arrayValue2 && [...arrayValue2],
3173
+ []
3148
3174
  ),
3175
+ setFormattedValue: setArrayValue,
3149
3176
  formManager,
3150
3177
  onInitialized,
3151
3178
  onFormManagerEvent,
@@ -3155,8 +3182,9 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
3155
3182
  onDirtyStatusChange,
3156
3183
  onTouchedStatusChange
3157
3184
  });
3158
- const { getState, useSchema, usePath, inputProps } = controller;
3159
- const { restrictions } = useSchema().typeInfo;
3185
+ const { useSchema, usePath, inputProps } = controller;
3186
+ const schema = useSchema();
3187
+ const { restrictions } = schema.typeInfo;
3160
3188
  const absolutePath = usePath();
3161
3189
  const {
3162
3190
  displayLoading,
@@ -3174,20 +3202,22 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
3174
3202
  preventAutoFocus,
3175
3203
  apiRef
3176
3204
  });
3205
+ const { onChange: inputOnChange } = inputProps;
3177
3206
  const handleValueChange = useCallback(
3178
- (formattedValue2) => setArrayValue(
3179
- parseSelectionValuesFromOptionIndices(
3207
+ (formattedValue2) => {
3208
+ const newValue = parseSelectionValuesFromOptionIndices(
3180
3209
  formattedValue2,
3181
- getState().schema,
3182
- options
3183
- )
3184
- ),
3185
- [getState, options]
3210
+ schema,
3211
+ options,
3212
+ unknownValues
3213
+ );
3214
+ inputOnChange(newValue);
3215
+ setArrayValue(newValue);
3216
+ },
3217
+ [inputOnChange, options, schema, unknownValues]
3186
3218
  );
3187
3219
  const [inlineIssues, popoverIssues] = useControlIssues({
3188
- issuesToDisplay: {
3189
- [absolutePath.toString()]: issuesToDisplay
3190
- },
3220
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
3191
3221
  issueMessages: { [absolutePath.toString()]: issueMessages },
3192
3222
  displayIssues,
3193
3223
  issueMessagesProps
@@ -3198,7 +3228,7 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
3198
3228
  forwardedRef
3199
3229
  );
3200
3230
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3201
- /* @__PURE__ */ jsx(
3231
+ /* @__PURE__ */ jsxs(
3202
3232
  CheckboxGroup,
3203
3233
  {
3204
3234
  value: formattedValue,
@@ -3209,10 +3239,7 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
3209
3239
  disabled: displayDisabled || disabled,
3210
3240
  readOnly: displayReadOnly || readOnly || inputProps.readOnly,
3211
3241
  status: displayStatusToControlStatus(displayStatusToDisplay),
3212
- onValueChange: combineEventHandlers(
3213
- inputProps.onChange,
3214
- handleValueChange
3215
- ),
3242
+ onValueChange: handleValueChange,
3216
3243
  onFocus: combineEventHandlers(onFocus, handleFocus),
3217
3244
  onBlurToOutside: combineEventHandlers(
3218
3245
  onBlurToOutside,
@@ -3220,7 +3247,10 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
3220
3247
  ),
3221
3248
  ...otherProps,
3222
3249
  ref: combinedCheckboxGroupRef,
3223
- children: options.map(({ value, text, key, ...checkboxProps }, i) => /* @__PURE__ */ jsx(Checkbox, { value: i, ...checkboxProps, children: text ?? value?.toString() ?? "" }, key ?? i))
3250
+ children: [
3251
+ unknownValues.map((v, i) => /* @__PURE__ */ jsx(Checkbox, { value: -i - 1, status: "invalid", children: /* @__PURE__ */ jsx(UnknownValue, { value: v, label: unknownValueLabel }) }, i)),
3252
+ options.map(({ value, text, key, ...checkboxProps }, i) => /* @__PURE__ */ jsx(Checkbox, { value: i, ...checkboxProps, children: text ?? value?.toString() ?? "" }, key ?? i))
3253
+ ]
3224
3254
  }
3225
3255
  ),
3226
3256
  inlineIssues,
@@ -3355,9 +3385,7 @@ const DateControl = forwardRef(function DateControl2({
3355
3385
  [inputProps]
3356
3386
  );
3357
3387
  const [inlineIssues, popoverIssues] = useControlIssues({
3358
- issuesToDisplay: {
3359
- [absolutePath.toString()]: issuesToDisplay
3360
- },
3388
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
3361
3389
  issueMessages: { [absolutePath.toString()]: issueMessages },
3362
3390
  displayIssues,
3363
3391
  issueMessagesProps
@@ -3738,9 +3766,7 @@ const FileControl = forwardRef(function FileControl2({
3738
3766
  [file, fileInteraction]
3739
3767
  );
3740
3768
  const [inlineIssues, popoverIssues] = useControlIssues({
3741
- issuesToDisplay: {
3742
- [absolutePath.toString()]: issuesToDisplay
3743
- },
3769
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
3744
3770
  issueMessages: { [absolutePath.toString()]: issueMessages },
3745
3771
  displayIssues,
3746
3772
  issueMessagesProps
@@ -6155,9 +6181,7 @@ const NumericControl = forwardRef(function NumericControl2({
6155
6181
  );
6156
6182
  }
6157
6183
  const [inlineIssues, popoverIssues] = useControlIssues({
6158
- issuesToDisplay: {
6159
- [absolutePath.toString()]: issuesToDisplay
6160
- },
6184
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
6161
6185
  issueMessages: { [absolutePath.toString()]: issueMessages },
6162
6186
  displayIssues,
6163
6187
  issueMessagesProps
@@ -6288,6 +6312,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
6288
6312
  issueMessages,
6289
6313
  issuesPanelLabel,
6290
6314
  displayIssues = true,
6315
+ unknownValueLabel,
6291
6316
  preventAutoFocus,
6292
6317
  apiRef,
6293
6318
  issueMessagesProps,
@@ -6309,47 +6334,29 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
6309
6334
  onBlurToOutside,
6310
6335
  ...otherProps
6311
6336
  }, forwardedRef) {
6337
+ const [locale7] = useLocale();
6338
+ unknownValueLabel ??= locale7.RadioGroupControl.unknownValueLabel;
6312
6339
  const [value, setValue] = useState();
6340
+ const isUnknown = useMemo(
6341
+ () => isUnknownValue(value, options),
6342
+ [options, value]
6343
+ );
6313
6344
  const formattedValue = useMemo(
6314
6345
  () => formatSelectionValueAsOptionIndex(value, options),
6315
6346
  [options, value]
6316
6347
  );
6317
- const controller = useInput(
6318
- path,
6319
- {
6320
- enabled: !useFormIsLoading(),
6321
- parse: useCallback(
6322
- (formattedValue2, state) => parseSelectionValueFromOptionIndex(
6323
- formattedValue2,
6324
- state.schema,
6325
- options
6326
- ),
6327
- [options]
6328
- ),
6329
- format: useCallback(
6330
- (value2) => formatSelectionValueAsOptionIndex(value2, options),
6331
- [options]
6332
- ),
6333
- setFormattedValue: useCallback(
6334
- (formattedValue2, state) => setValue(
6335
- parseSelectionValueFromOptionIndex(
6336
- formattedValue2,
6337
- state.schema,
6338
- options
6339
- )
6340
- ),
6341
- [options]
6342
- ),
6343
- formManager,
6344
- onInitialized,
6345
- onFormManagerEvent,
6346
- onValueChange,
6347
- onValidationStatusChange,
6348
- onDisplayStatusChange,
6349
- onDirtyStatusChange,
6350
- onTouchedStatusChange
6351
- }
6352
- );
6348
+ const controller = useInput(path, {
6349
+ enabled: !useFormIsLoading(),
6350
+ setFormattedValue: setValue,
6351
+ formManager,
6352
+ onInitialized,
6353
+ onFormManagerEvent,
6354
+ onValueChange,
6355
+ onValidationStatusChange,
6356
+ onDisplayStatusChange,
6357
+ onDirtyStatusChange,
6358
+ onTouchedStatusChange
6359
+ });
6353
6360
  const { useSchema, usePath, inputProps } = controller;
6354
6361
  const schema = useSchema();
6355
6362
  const absolutePath = usePath();
@@ -6373,16 +6380,16 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
6373
6380
  const { onChange: inputOnChange } = inputProps;
6374
6381
  const handleValueChange = useCallback(
6375
6382
  (formattedValue2) => {
6376
- inputOnChange(formattedValue2 ?? "");
6377
- setValue(
6378
- parseSelectionValueFromOptionIndex(
6379
- formattedValue2 ?? "",
6380
- schema,
6381
- options
6382
- )
6383
+ const newValue = parseSelectionValueFromOptionIndex(
6384
+ formattedValue2 ?? "",
6385
+ schema,
6386
+ options,
6387
+ isUnknown ? [value] : []
6383
6388
  );
6389
+ inputOnChange(newValue);
6390
+ setValue(newValue);
6384
6391
  },
6385
- [inputOnChange, options, schema]
6392
+ [inputOnChange, isUnknown, options, schema, value]
6386
6393
  );
6387
6394
  const clearedValue = nullable ? null : schema.initialValue;
6388
6395
  const clearedIdx = useMemo(
@@ -6391,9 +6398,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
6391
6398
  );
6392
6399
  const clearedFormattedValue = clearedIdx === -1 ? "" : clearedIdx.toString();
6393
6400
  const [inlineIssues, popoverIssues] = useControlIssues({
6394
- issuesToDisplay: {
6395
- [absolutePath.toString()]: issuesToDisplay
6396
- },
6401
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
6397
6402
  issueMessages: { [absolutePath.toString()]: issueMessages },
6398
6403
  displayIssues,
6399
6404
  issueMessagesProps
@@ -6404,7 +6409,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
6404
6409
  forwardedRef
6405
6410
  );
6406
6411
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6407
- /* @__PURE__ */ jsx(
6412
+ /* @__PURE__ */ jsxs(
6408
6413
  RadioGroup,
6409
6414
  {
6410
6415
  value: formattedValue,
@@ -6424,7 +6429,10 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
6424
6429
  ),
6425
6430
  ...otherProps,
6426
6431
  ref: combinedRadioGroupRef,
6427
- children: options.map(({ value: value2, text, key, ...radioProps }, i) => /* @__PURE__ */ jsx(Radio, { value: i, ...radioProps, children: text ?? value2?.toString() ?? "" }, key ?? i))
6432
+ children: [
6433
+ isUnknown && /* @__PURE__ */ jsx(Radio, { value: -1, status: "invalid", children: /* @__PURE__ */ jsx(UnknownValue, { value, label: unknownValueLabel }) }),
6434
+ options.map(({ value: value2, text, key, ...radioProps }, i) => /* @__PURE__ */ jsx(Radio, { value: i, ...radioProps, children: text ?? value2?.toString() ?? "" }, key ?? i))
6435
+ ]
6428
6436
  }
6429
6437
  ),
6430
6438
  inlineIssues,
@@ -6698,6 +6706,7 @@ const SelectControl = forwardRef(function SelectControl2({
6698
6706
  issueMessages,
6699
6707
  issuesPanelLabel,
6700
6708
  displayIssues = true,
6709
+ unknownValueLabel,
6701
6710
  preventAutoFocus,
6702
6711
  apiRef,
6703
6712
  issueMessagesProps,
@@ -6720,6 +6729,8 @@ const SelectControl = forwardRef(function SelectControl2({
6720
6729
  onBlurToOutside,
6721
6730
  ...otherProps
6722
6731
  }, forwardedRef) {
6732
+ const [locale7] = useLocale();
6733
+ unknownValueLabel ??= locale7.SelectControl.unknownValueLabel;
6723
6734
  const options = useMemo(
6724
6735
  () => groupedOptions.reduce((options2, optionOrGroup) => {
6725
6736
  if ("options" in optionOrGroup) {
@@ -6732,34 +6743,17 @@ const SelectControl = forwardRef(function SelectControl2({
6732
6743
  [groupedOptions]
6733
6744
  );
6734
6745
  const [value, setValue] = useState();
6746
+ const isUnknown = useMemo(
6747
+ () => isUnknownValue(value, options),
6748
+ [options, value]
6749
+ );
6735
6750
  const formattedValue = useMemo(
6736
6751
  () => formatSelectionValueAsOptionIndex(value, options),
6737
6752
  [options, value]
6738
6753
  );
6739
6754
  const controller = useInput(path, {
6740
6755
  enabled: !useFormIsLoading(),
6741
- parse: useCallback(
6742
- (formattedValue2, state) => parseSelectionValueFromOptionIndex(
6743
- formattedValue2,
6744
- state.schema,
6745
- options
6746
- ),
6747
- [options]
6748
- ),
6749
- format: useCallback(
6750
- (value2) => formatSelectionValueAsOptionIndex(value2, options),
6751
- [options]
6752
- ),
6753
- setFormattedValue: useCallback(
6754
- (formattedValue2, state) => setValue(
6755
- parseSelectionValueFromOptionIndex(
6756
- formattedValue2,
6757
- state.schema,
6758
- options
6759
- )
6760
- ),
6761
- [options]
6762
- ),
6756
+ setFormattedValue: setValue,
6763
6757
  formManager,
6764
6758
  onInitialized,
6765
6759
  onFormManagerEvent,
@@ -6769,7 +6763,7 @@ const SelectControl = forwardRef(function SelectControl2({
6769
6763
  onDirtyStatusChange,
6770
6764
  onTouchedStatusChange
6771
6765
  });
6772
- const { getState, useSchema, usePath, inputProps } = controller;
6766
+ const { useSchema, usePath, inputProps } = controller;
6773
6767
  const schema = useSchema();
6774
6768
  const absolutePath = usePath();
6775
6769
  const { nullable, restrictions } = schema.typeInfo;
@@ -6789,15 +6783,19 @@ const SelectControl = forwardRef(function SelectControl2({
6789
6783
  preventAutoFocus,
6790
6784
  apiRef
6791
6785
  });
6786
+ const { onChange: inputOnChange } = inputProps;
6792
6787
  const handleValueChange = useCallback(
6793
- (formattedValue2) => setValue(
6794
- parseSelectionValueFromOptionIndex(
6788
+ (formattedValue2) => {
6789
+ const newValue = parseSelectionValueFromOptionIndex(
6795
6790
  formattedValue2,
6796
- getState().schema,
6797
- options
6798
- )
6799
- ),
6800
- [getState, options]
6791
+ schema,
6792
+ options,
6793
+ isUnknown ? [value] : []
6794
+ );
6795
+ inputOnChange(newValue);
6796
+ setValue(newValue);
6797
+ },
6798
+ [inputOnChange, isUnknown, options, schema, value]
6801
6799
  );
6802
6800
  showClearButton ??= nullable ? "auto" : false;
6803
6801
  const clearedValue = nullable ? null : schema.initialValue;
@@ -6811,9 +6809,7 @@ const SelectControl = forwardRef(function SelectControl2({
6811
6809
  [groupedOptions]
6812
6810
  );
6813
6811
  const [inlineIssues, popoverIssues] = useControlIssues({
6814
- issuesToDisplay: {
6815
- [absolutePath.toString()]: issuesToDisplay
6816
- },
6812
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
6817
6813
  issueMessages: { [absolutePath.toString()]: issueMessages },
6818
6814
  displayIssues,
6819
6815
  issueMessagesProps
@@ -6824,7 +6820,7 @@ const SelectControl = forwardRef(function SelectControl2({
6824
6820
  forwardedRef
6825
6821
  );
6826
6822
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6827
- /* @__PURE__ */ jsx(
6823
+ /* @__PURE__ */ jsxs(
6828
6824
  Select,
6829
6825
  {
6830
6826
  value: formattedValue,
@@ -6840,10 +6836,7 @@ const SelectControl = forwardRef(function SelectControl2({
6840
6836
  popoverIssues,
6841
6837
  endAdornment
6842
6838
  ] }),
6843
- onValueChange: combineEventHandlers(
6844
- inputProps.onChange,
6845
- handleValueChange
6846
- ),
6839
+ onValueChange: handleValueChange,
6847
6840
  onFocus: combineEventHandlers(onFocus, handleFocus),
6848
6841
  onBlurToOutside: combineEventHandlers(
6849
6842
  onBlurToOutside,
@@ -6851,7 +6844,10 @@ const SelectControl = forwardRef(function SelectControl2({
6851
6844
  ),
6852
6845
  ...otherProps,
6853
6846
  ref: combinedSelectRef,
6854
- children: optionNodes
6847
+ children: [
6848
+ isUnknown && /* @__PURE__ */ jsx(Option, { value: -1, color: "danger", keywords: [String(value)], children: /* @__PURE__ */ jsx(UnknownValue, { value, label: unknownValueLabel }) }),
6849
+ optionNodes
6850
+ ]
6855
6851
  }
6856
6852
  ),
6857
6853
  inlineIssues
@@ -6859,10 +6855,11 @@ const SelectControl = forwardRef(function SelectControl2({
6859
6855
  });
6860
6856
  const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
6861
6857
  path,
6858
+ options: groupedOptions,
6862
6859
  issueMessages,
6863
6860
  issuesPanelLabel,
6864
6861
  displayIssues = true,
6865
- options: groupedOptions,
6862
+ unknownValueLabel,
6866
6863
  preventAutoFocus,
6867
6864
  apiRef,
6868
6865
  issueMessagesProps,
@@ -6884,6 +6881,8 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
6884
6881
  onBlurToOutside,
6885
6882
  ...otherProps
6886
6883
  }, forwardedRef) {
6884
+ const [locale7] = useLocale();
6885
+ unknownValueLabel ??= locale7.SelectMultipleControl.unknownValueLabel;
6887
6886
  const options = useMemo(
6888
6887
  () => groupedOptions.reduce((options2, optionOrGroup) => {
6889
6888
  if ("options" in optionOrGroup) {
@@ -6896,34 +6895,25 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
6896
6895
  [groupedOptions]
6897
6896
  );
6898
6897
  const [arrayValue, setArrayValue] = useState(null);
6899
- const formattedValue = useMemo(
6900
- () => formatSelectionValuesAsOptionIndices(arrayValue, options),
6898
+ const unknownValues = useMemo(
6899
+ () => getUnknownValues(arrayValue, options),
6901
6900
  [options, arrayValue]
6902
6901
  );
6902
+ const formattedValue = useMemo(
6903
+ () => formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),
6904
+ [options, unknownValues, arrayValue]
6905
+ );
6903
6906
  const controller = useListableInput(path, {
6904
6907
  enabled: !useFormIsLoading(),
6905
6908
  parseToArray: useCallback(
6906
- (formattedValue2, state) => parseSelectionValuesFromOptionIndices(
6907
- formattedValue2,
6908
- state.schema,
6909
- options
6910
- ),
6911
- [options]
6909
+ (formattedValue2) => formattedValue2 && [...formattedValue2],
6910
+ []
6912
6911
  ),
6913
6912
  formatFromArray: useCallback(
6914
- (arrayValue2) => formatSelectionValuesAsOptionIndices(arrayValue2, options),
6915
- [options]
6916
- ),
6917
- setFormattedValue: useCallback(
6918
- (formattedValue2, state) => setArrayValue(
6919
- parseSelectionValuesFromOptionIndices(
6920
- formattedValue2,
6921
- state.schema,
6922
- options
6923
- )
6924
- ),
6925
- [options]
6913
+ (arrayValue2) => arrayValue2 && [...arrayValue2],
6914
+ []
6926
6915
  ),
6916
+ setFormattedValue: setArrayValue,
6927
6917
  formManager,
6928
6918
  onInitialized,
6929
6919
  onFormManagerEvent,
@@ -6933,8 +6923,9 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
6933
6923
  onDirtyStatusChange,
6934
6924
  onTouchedStatusChange
6935
6925
  });
6936
- const { getState, useSchema, usePath, inputProps } = controller;
6937
- const { restrictions } = useSchema().typeInfo;
6926
+ const { useSchema, usePath, inputProps } = controller;
6927
+ const schema = useSchema();
6928
+ const { restrictions } = schema.typeInfo;
6938
6929
  const absolutePath = usePath();
6939
6930
  const {
6940
6931
  displayLoading,
@@ -6952,24 +6943,26 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
6952
6943
  preventAutoFocus,
6953
6944
  apiRef
6954
6945
  });
6946
+ const { onChange: inputOnChange } = inputProps;
6955
6947
  const handleValueChange = useCallback(
6956
- (formattedValue2) => setArrayValue(
6957
- parseSelectionValuesFromOptionIndices(
6948
+ (formattedValue2) => {
6949
+ const newValue = parseSelectionValuesFromOptionIndices(
6958
6950
  formattedValue2,
6959
- getState().schema,
6960
- options
6961
- )
6962
- ),
6963
- [getState, options]
6951
+ schema,
6952
+ options,
6953
+ unknownValues
6954
+ );
6955
+ inputOnChange(newValue);
6956
+ setArrayValue(newValue);
6957
+ },
6958
+ [inputOnChange, options, schema, unknownValues]
6964
6959
  );
6965
6960
  const optionNodes = useMemo(
6966
6961
  () => optionObjectsToNodes(groupedOptions),
6967
6962
  [groupedOptions]
6968
6963
  );
6969
6964
  const [inlineIssues, popoverIssues] = useControlIssues({
6970
- issuesToDisplay: {
6971
- [absolutePath.toString()]: issuesToDisplay
6972
- },
6965
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
6973
6966
  issueMessages: { [absolutePath.toString()]: issueMessages },
6974
6967
  displayIssues,
6975
6968
  issueMessagesProps
@@ -6980,7 +6973,7 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
6980
6973
  forwardedRef
6981
6974
  );
6982
6975
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6983
- /* @__PURE__ */ jsx(
6976
+ /* @__PURE__ */ jsxs(
6984
6977
  Select,
6985
6978
  {
6986
6979
  multiple: true,
@@ -6996,10 +6989,7 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
6996
6989
  popoverIssues,
6997
6990
  endAdornment
6998
6991
  ] }),
6999
- onValueChange: combineEventHandlers(
7000
- inputProps.onChange,
7001
- handleValueChange
7002
- ),
6992
+ onValueChange: handleValueChange,
7003
6993
  onFocus: combineEventHandlers(onFocus, handleFocus),
7004
6994
  onBlurToOutside: combineEventHandlers(
7005
6995
  onBlurToOutside,
@@ -7007,7 +6997,19 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
7007
6997
  ),
7008
6998
  ...otherProps,
7009
6999
  ref: combinedSelectRef,
7010
- children: optionNodes
7000
+ children: [
7001
+ unknownValues.map((v, i) => /* @__PURE__ */ jsx(
7002
+ Option,
7003
+ {
7004
+ value: -i - 1,
7005
+ color: "danger",
7006
+ keywords: v == null ? [] : [String(v)],
7007
+ children: /* @__PURE__ */ jsx(UnknownValue, { value: v, label: unknownValueLabel })
7008
+ },
7009
+ i
7010
+ )),
7011
+ optionNodes
7012
+ ]
7011
7013
  }
7012
7014
  ),
7013
7015
  inlineIssues
@@ -7501,9 +7503,7 @@ const TableControl = forwardRef(function TableControl2({
7501
7503
  [controller, ownController]
7502
7504
  );
7503
7505
  const [inlineIssues] = useControlIssues({
7504
- issuesToDisplay: {
7505
- [absolutePath.toString()]: issuesToDisplay
7506
- },
7506
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
7507
7507
  issueMessages: { [absolutePath.toString()]: issueMessages },
7508
7508
  displayIssues,
7509
7509
  issueMessagesProps
@@ -7843,9 +7843,7 @@ const TextControl = forwardRef(function TextControl2({
7843
7843
  }
7844
7844
  }, [multiline]);
7845
7845
  const [inlineIssues, popoverIssues] = useControlIssues({
7846
- issuesToDisplay: {
7847
- [absolutePath.toString()]: issuesToDisplay
7848
- },
7846
+ issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
7849
7847
  issueMessages: { [absolutePath.toString()]: issueMessages },
7850
7848
  displayIssues,
7851
7849
  issueMessagesProps