@ostack.tech/ui-kform 0.14.0 → 0.14.1
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/chunks/{en-3JcwFYXc.js → en-Cb79GQnj.js} +8 -1
- package/dist/chunks/en-Cb79GQnj.js.map +1 -0
- package/dist/locales/en-GB.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/fr-FR.js +7 -0
- package/dist/locales/fr-FR.js.map +1 -1
- package/dist/locales/pt-PT.js +7 -0
- package/dist/locales/pt-PT.js.map +1 -1
- package/dist/ostack-ui-kform.css +10 -0
- package/dist/ostack-ui-kform.js +183 -173
- package/dist/ostack-ui-kform.js.map +1 -1
- package/dist/types/components/CheckboxGroupControl/CheckboxGroupControl.d.ts +3 -1
- package/dist/types/components/RadioGroupControl/RadioGroupControl.d.ts +3 -1
- package/dist/types/components/SelectControl/SelectControl.d.ts +3 -1
- package/dist/types/components/SelectMultipleControl/SelectMultipleControl.d.ts +5 -3
- package/dist/types/components/UnknownValue/UnknownValue.d.ts +9 -0
- package/dist/types/components/UnknownValue/index.d.ts +1 -0
- package/dist/types/providers/LocalizationProvider/LocalizationObject.d.ts +10 -0
- package/dist/types/utils/selectionTransformations.d.ts +11 -3
- package/package.json +2 -2
- package/scss/_utils.scss +1 -0
- package/scss/components/UnknownValue/_UnknownValue-variables.scss +10 -0
- package/scss/components/UnknownValue/_UnknownValue.scss +14 -0
- package/scss/index.scss +1 -0
- package/dist/chunks/en-3JcwFYXc.js.map +0 -1
package/dist/ostack-ui-kform.js
CHANGED
|
@@ -3061,26 +3061,39 @@ function parseCheckboxValue(formattedValue, state) {
|
|
|
3061
3061
|
function formatToCheckboxValue(value) {
|
|
3062
3062
|
return value === void 0 ? false : value ?? "indeterminate";
|
|
3063
3063
|
}
|
|
3064
|
-
function
|
|
3064
|
+
function isUnknownValue(value, options) {
|
|
3065
|
+
return value != null && value !== "" && options.every((opt) => !equals(opt.value, value));
|
|
3066
|
+
}
|
|
3067
|
+
function parseSelectionValueFromOptionIndex(formattedValue, schema, options, unknownValues) {
|
|
3065
3068
|
if (formattedValue === "") {
|
|
3066
3069
|
return schema.typeInfo.nullable ? null : schema.initialValue;
|
|
3070
|
+
} else if (formattedValue.startsWith("-")) {
|
|
3071
|
+
return unknownValues[-+formattedValue - 1];
|
|
3067
3072
|
}
|
|
3068
3073
|
return options[+formattedValue].value;
|
|
3069
3074
|
}
|
|
3070
3075
|
function formatSelectionValueAsOptionIndex(value, options) {
|
|
3071
3076
|
const idx = options.findIndex((option) => equals(option.value, value));
|
|
3072
|
-
return idx === -1 ? "" : idx.toString();
|
|
3077
|
+
return idx === -1 ? value == null || value === "" ? "" : "-1" : idx.toString();
|
|
3073
3078
|
}
|
|
3074
|
-
function
|
|
3075
|
-
|
|
3076
|
-
|
|
3079
|
+
function getUnknownValues(arrayValue, options) {
|
|
3080
|
+
const unknownValues = [];
|
|
3081
|
+
for (const v of arrayValue ?? []) {
|
|
3082
|
+
if (options.every((opt) => !equals(opt.value, v)) && unknownValues.every((u) => !equals(u, v))) {
|
|
3083
|
+
unknownValues.push(v);
|
|
3084
|
+
}
|
|
3077
3085
|
}
|
|
3078
|
-
return
|
|
3086
|
+
return unknownValues;
|
|
3079
3087
|
}
|
|
3080
|
-
function
|
|
3088
|
+
function parseSelectionValuesFromOptionIndices(formattedValue, schema, options, unknownValues) {
|
|
3089
|
+
return formattedValue.length === 0 ? schema.typeInfo.nullable ? null : [] : formattedValue.map(
|
|
3090
|
+
(v) => v.startsWith("-") ? unknownValues[-+v - 1] : options[+v].value
|
|
3091
|
+
);
|
|
3092
|
+
}
|
|
3093
|
+
function formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues) {
|
|
3081
3094
|
return arrayValue?.map((v) => {
|
|
3082
3095
|
const idx = options.findIndex((option) => equals(option.value, v));
|
|
3083
|
-
return idx === -1 ?
|
|
3096
|
+
return idx === -1 ? (-unknownValues.findIndex((u) => equals(u, v)) - 1).toString() : idx.toString();
|
|
3084
3097
|
}) ?? [];
|
|
3085
3098
|
}
|
|
3086
3099
|
function optionObjectsToNodes(options) {
|
|
@@ -3091,12 +3104,35 @@ function optionObjectsToNodes(options) {
|
|
|
3091
3104
|
) }, key ?? i) : /* @__PURE__ */ jsx(Option, { ...optionOrGroup, value: optionIndex++, children: optionOrGroup.text ?? optionOrGroup.value?.toString() ?? "" }, key ?? i)
|
|
3092
3105
|
);
|
|
3093
3106
|
}
|
|
3107
|
+
function UnknownValue({
|
|
3108
|
+
value,
|
|
3109
|
+
label
|
|
3110
|
+
}) {
|
|
3111
|
+
const [locale7] = useLocale();
|
|
3112
|
+
label ??= locale7.UnknownValue.label;
|
|
3113
|
+
const prefix = usePrefix();
|
|
3114
|
+
const valueStr = value == null ? "" : String(value);
|
|
3115
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3116
|
+
valueStr && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3117
|
+
"“",
|
|
3118
|
+
/* @__PURE__ */ jsx("span", { className: prefix("unknown-value"), children: valueStr }),
|
|
3119
|
+
"”"
|
|
3120
|
+
] }),
|
|
3121
|
+
valueStr && label && /* @__PURE__ */ jsx(Fragment, { children: " " }),
|
|
3122
|
+
label && /* @__PURE__ */ jsxs("span", { className: prefix("unknown-value__label"), children: [
|
|
3123
|
+
"(",
|
|
3124
|
+
label,
|
|
3125
|
+
")"
|
|
3126
|
+
] })
|
|
3127
|
+
] });
|
|
3128
|
+
}
|
|
3094
3129
|
const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
|
|
3095
3130
|
path,
|
|
3096
3131
|
options,
|
|
3097
3132
|
issueMessages,
|
|
3098
3133
|
issuesPanelLabel,
|
|
3099
3134
|
displayIssues = true,
|
|
3135
|
+
unknownValueLabel,
|
|
3100
3136
|
preventAutoFocus,
|
|
3101
3137
|
apiRef,
|
|
3102
3138
|
issueMessagesProps,
|
|
@@ -3117,35 +3153,28 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
|
|
|
3117
3153
|
onBlurToOutside,
|
|
3118
3154
|
...otherProps
|
|
3119
3155
|
}, forwardedRef) {
|
|
3156
|
+
const [locale7] = useLocale();
|
|
3157
|
+
unknownValueLabel ??= locale7.SelectMultipleControl.unknownValueLabel;
|
|
3120
3158
|
const [arrayValue, setArrayValue] = useState(null);
|
|
3121
|
-
const
|
|
3122
|
-
() =>
|
|
3159
|
+
const unknownValues = useMemo(
|
|
3160
|
+
() => getUnknownValues(arrayValue, options),
|
|
3123
3161
|
[options, arrayValue]
|
|
3124
3162
|
);
|
|
3163
|
+
const formattedValue = useMemo(
|
|
3164
|
+
() => formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),
|
|
3165
|
+
[options, unknownValues, arrayValue]
|
|
3166
|
+
);
|
|
3125
3167
|
const controller = useListableInput(path, {
|
|
3126
3168
|
enabled: !useFormIsLoading(),
|
|
3127
3169
|
parseToArray: useCallback(
|
|
3128
|
-
(formattedValue2
|
|
3129
|
-
|
|
3130
|
-
state.schema,
|
|
3131
|
-
options
|
|
3132
|
-
),
|
|
3133
|
-
[options]
|
|
3170
|
+
(formattedValue2) => formattedValue2 && [...formattedValue2],
|
|
3171
|
+
[]
|
|
3134
3172
|
),
|
|
3135
3173
|
formatFromArray: useCallback(
|
|
3136
|
-
(arrayValue2) =>
|
|
3137
|
-
[
|
|
3138
|
-
),
|
|
3139
|
-
setFormattedValue: useCallback(
|
|
3140
|
-
(formattedValue2, state) => setArrayValue(
|
|
3141
|
-
parseSelectionValuesFromOptionIndices(
|
|
3142
|
-
formattedValue2,
|
|
3143
|
-
state.schema,
|
|
3144
|
-
options
|
|
3145
|
-
)
|
|
3146
|
-
),
|
|
3147
|
-
[options]
|
|
3174
|
+
(arrayValue2) => arrayValue2 && [...arrayValue2],
|
|
3175
|
+
[]
|
|
3148
3176
|
),
|
|
3177
|
+
setFormattedValue: setArrayValue,
|
|
3149
3178
|
formManager,
|
|
3150
3179
|
onInitialized,
|
|
3151
3180
|
onFormManagerEvent,
|
|
@@ -3155,8 +3184,9 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
|
|
|
3155
3184
|
onDirtyStatusChange,
|
|
3156
3185
|
onTouchedStatusChange
|
|
3157
3186
|
});
|
|
3158
|
-
const {
|
|
3159
|
-
const
|
|
3187
|
+
const { useSchema, usePath, inputProps } = controller;
|
|
3188
|
+
const schema = useSchema();
|
|
3189
|
+
const { restrictions } = schema.typeInfo;
|
|
3160
3190
|
const absolutePath = usePath();
|
|
3161
3191
|
const {
|
|
3162
3192
|
displayLoading,
|
|
@@ -3174,20 +3204,22 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
|
|
|
3174
3204
|
preventAutoFocus,
|
|
3175
3205
|
apiRef
|
|
3176
3206
|
});
|
|
3207
|
+
const { onChange: inputOnChange } = inputProps;
|
|
3177
3208
|
const handleValueChange = useCallback(
|
|
3178
|
-
(formattedValue2) =>
|
|
3179
|
-
parseSelectionValuesFromOptionIndices(
|
|
3209
|
+
(formattedValue2) => {
|
|
3210
|
+
const newValue = parseSelectionValuesFromOptionIndices(
|
|
3180
3211
|
formattedValue2,
|
|
3181
|
-
|
|
3182
|
-
options
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3212
|
+
schema,
|
|
3213
|
+
options,
|
|
3214
|
+
unknownValues
|
|
3215
|
+
);
|
|
3216
|
+
inputOnChange(newValue);
|
|
3217
|
+
setArrayValue(newValue);
|
|
3218
|
+
},
|
|
3219
|
+
[inputOnChange, options, schema, unknownValues]
|
|
3186
3220
|
);
|
|
3187
3221
|
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
3188
|
-
issuesToDisplay: {
|
|
3189
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
3190
|
-
},
|
|
3222
|
+
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
3191
3223
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
3192
3224
|
displayIssues,
|
|
3193
3225
|
issueMessagesProps
|
|
@@ -3198,7 +3230,7 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
|
|
|
3198
3230
|
forwardedRef
|
|
3199
3231
|
);
|
|
3200
3232
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3201
|
-
/* @__PURE__ */
|
|
3233
|
+
/* @__PURE__ */ jsxs(
|
|
3202
3234
|
CheckboxGroup,
|
|
3203
3235
|
{
|
|
3204
3236
|
value: formattedValue,
|
|
@@ -3209,10 +3241,7 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
|
|
|
3209
3241
|
disabled: displayDisabled || disabled,
|
|
3210
3242
|
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
3211
3243
|
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
3212
|
-
onValueChange:
|
|
3213
|
-
inputProps.onChange,
|
|
3214
|
-
handleValueChange
|
|
3215
|
-
),
|
|
3244
|
+
onValueChange: handleValueChange,
|
|
3216
3245
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
3217
3246
|
onBlurToOutside: combineEventHandlers(
|
|
3218
3247
|
onBlurToOutside,
|
|
@@ -3220,7 +3249,10 @@ const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
|
|
|
3220
3249
|
),
|
|
3221
3250
|
...otherProps,
|
|
3222
3251
|
ref: combinedCheckboxGroupRef,
|
|
3223
|
-
children:
|
|
3252
|
+
children: [
|
|
3253
|
+
unknownValues.map((v, i) => /* @__PURE__ */ jsx(Checkbox, { value: -i - 1, status: "invalid", children: /* @__PURE__ */ jsx(UnknownValue, { value: v, label: unknownValueLabel }) }, i)),
|
|
3254
|
+
options.map(({ value, text, key, ...checkboxProps }, i) => /* @__PURE__ */ jsx(Checkbox, { value: i, ...checkboxProps, children: text ?? value?.toString() ?? "" }, key ?? i))
|
|
3255
|
+
]
|
|
3224
3256
|
}
|
|
3225
3257
|
),
|
|
3226
3258
|
inlineIssues,
|
|
@@ -6288,6 +6320,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6288
6320
|
issueMessages,
|
|
6289
6321
|
issuesPanelLabel,
|
|
6290
6322
|
displayIssues = true,
|
|
6323
|
+
unknownValueLabel,
|
|
6291
6324
|
preventAutoFocus,
|
|
6292
6325
|
apiRef,
|
|
6293
6326
|
issueMessagesProps,
|
|
@@ -6309,47 +6342,29 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6309
6342
|
onBlurToOutside,
|
|
6310
6343
|
...otherProps
|
|
6311
6344
|
}, forwardedRef) {
|
|
6345
|
+
const [locale7] = useLocale();
|
|
6346
|
+
unknownValueLabel ??= locale7.RadioGroupControl.unknownValueLabel;
|
|
6312
6347
|
const [value, setValue] = useState();
|
|
6348
|
+
const isUnknown = useMemo(
|
|
6349
|
+
() => isUnknownValue(value, options),
|
|
6350
|
+
[options, value]
|
|
6351
|
+
);
|
|
6313
6352
|
const formattedValue = useMemo(
|
|
6314
6353
|
() => formatSelectionValueAsOptionIndex(value, options),
|
|
6315
6354
|
[options, value]
|
|
6316
6355
|
);
|
|
6317
|
-
const controller = useInput(
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
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
|
-
);
|
|
6356
|
+
const controller = useInput(path, {
|
|
6357
|
+
enabled: !useFormIsLoading(),
|
|
6358
|
+
setFormattedValue: setValue,
|
|
6359
|
+
formManager,
|
|
6360
|
+
onInitialized,
|
|
6361
|
+
onFormManagerEvent,
|
|
6362
|
+
onValueChange,
|
|
6363
|
+
onValidationStatusChange,
|
|
6364
|
+
onDisplayStatusChange,
|
|
6365
|
+
onDirtyStatusChange,
|
|
6366
|
+
onTouchedStatusChange
|
|
6367
|
+
});
|
|
6353
6368
|
const { useSchema, usePath, inputProps } = controller;
|
|
6354
6369
|
const schema = useSchema();
|
|
6355
6370
|
const absolutePath = usePath();
|
|
@@ -6373,16 +6388,16 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6373
6388
|
const { onChange: inputOnChange } = inputProps;
|
|
6374
6389
|
const handleValueChange = useCallback(
|
|
6375
6390
|
(formattedValue2) => {
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
options
|
|
6382
|
-
)
|
|
6391
|
+
const newValue = parseSelectionValueFromOptionIndex(
|
|
6392
|
+
formattedValue2 ?? "",
|
|
6393
|
+
schema,
|
|
6394
|
+
options,
|
|
6395
|
+
isUnknown ? [value] : []
|
|
6383
6396
|
);
|
|
6397
|
+
inputOnChange(newValue);
|
|
6398
|
+
setValue(newValue);
|
|
6384
6399
|
},
|
|
6385
|
-
[inputOnChange, options, schema]
|
|
6400
|
+
[inputOnChange, isUnknown, options, schema, value]
|
|
6386
6401
|
);
|
|
6387
6402
|
const clearedValue = nullable ? null : schema.initialValue;
|
|
6388
6403
|
const clearedIdx = useMemo(
|
|
@@ -6391,9 +6406,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6391
6406
|
);
|
|
6392
6407
|
const clearedFormattedValue = clearedIdx === -1 ? "" : clearedIdx.toString();
|
|
6393
6408
|
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6394
|
-
issuesToDisplay: {
|
|
6395
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
6396
|
-
},
|
|
6409
|
+
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
6397
6410
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
6398
6411
|
displayIssues,
|
|
6399
6412
|
issueMessagesProps
|
|
@@ -6404,7 +6417,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6404
6417
|
forwardedRef
|
|
6405
6418
|
);
|
|
6406
6419
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6407
|
-
/* @__PURE__ */
|
|
6420
|
+
/* @__PURE__ */ jsxs(
|
|
6408
6421
|
RadioGroup,
|
|
6409
6422
|
{
|
|
6410
6423
|
value: formattedValue,
|
|
@@ -6424,7 +6437,10 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6424
6437
|
),
|
|
6425
6438
|
...otherProps,
|
|
6426
6439
|
ref: combinedRadioGroupRef,
|
|
6427
|
-
children:
|
|
6440
|
+
children: [
|
|
6441
|
+
isUnknown && /* @__PURE__ */ jsx(Radio, { value: -1, status: "invalid", children: /* @__PURE__ */ jsx(UnknownValue, { value, label: unknownValueLabel }) }),
|
|
6442
|
+
options.map(({ value: value2, text, key, ...radioProps }, i) => /* @__PURE__ */ jsx(Radio, { value: i, ...radioProps, children: text ?? value2?.toString() ?? "" }, key ?? i))
|
|
6443
|
+
]
|
|
6428
6444
|
}
|
|
6429
6445
|
),
|
|
6430
6446
|
inlineIssues,
|
|
@@ -6698,6 +6714,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6698
6714
|
issueMessages,
|
|
6699
6715
|
issuesPanelLabel,
|
|
6700
6716
|
displayIssues = true,
|
|
6717
|
+
unknownValueLabel,
|
|
6701
6718
|
preventAutoFocus,
|
|
6702
6719
|
apiRef,
|
|
6703
6720
|
issueMessagesProps,
|
|
@@ -6720,6 +6737,8 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6720
6737
|
onBlurToOutside,
|
|
6721
6738
|
...otherProps
|
|
6722
6739
|
}, forwardedRef) {
|
|
6740
|
+
const [locale7] = useLocale();
|
|
6741
|
+
unknownValueLabel ??= locale7.SelectControl.unknownValueLabel;
|
|
6723
6742
|
const options = useMemo(
|
|
6724
6743
|
() => groupedOptions.reduce((options2, optionOrGroup) => {
|
|
6725
6744
|
if ("options" in optionOrGroup) {
|
|
@@ -6732,34 +6751,17 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6732
6751
|
[groupedOptions]
|
|
6733
6752
|
);
|
|
6734
6753
|
const [value, setValue] = useState();
|
|
6754
|
+
const isUnknown = useMemo(
|
|
6755
|
+
() => isUnknownValue(value, options),
|
|
6756
|
+
[options, value]
|
|
6757
|
+
);
|
|
6735
6758
|
const formattedValue = useMemo(
|
|
6736
6759
|
() => formatSelectionValueAsOptionIndex(value, options),
|
|
6737
6760
|
[options, value]
|
|
6738
6761
|
);
|
|
6739
6762
|
const controller = useInput(path, {
|
|
6740
6763
|
enabled: !useFormIsLoading(),
|
|
6741
|
-
|
|
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
|
-
),
|
|
6764
|
+
setFormattedValue: setValue,
|
|
6763
6765
|
formManager,
|
|
6764
6766
|
onInitialized,
|
|
6765
6767
|
onFormManagerEvent,
|
|
@@ -6769,7 +6771,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6769
6771
|
onDirtyStatusChange,
|
|
6770
6772
|
onTouchedStatusChange
|
|
6771
6773
|
});
|
|
6772
|
-
const {
|
|
6774
|
+
const { useSchema, usePath, inputProps } = controller;
|
|
6773
6775
|
const schema = useSchema();
|
|
6774
6776
|
const absolutePath = usePath();
|
|
6775
6777
|
const { nullable, restrictions } = schema.typeInfo;
|
|
@@ -6789,15 +6791,19 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6789
6791
|
preventAutoFocus,
|
|
6790
6792
|
apiRef
|
|
6791
6793
|
});
|
|
6794
|
+
const { onChange: inputOnChange } = inputProps;
|
|
6792
6795
|
const handleValueChange = useCallback(
|
|
6793
|
-
(formattedValue2) =>
|
|
6794
|
-
parseSelectionValueFromOptionIndex(
|
|
6796
|
+
(formattedValue2) => {
|
|
6797
|
+
const newValue = parseSelectionValueFromOptionIndex(
|
|
6795
6798
|
formattedValue2,
|
|
6796
|
-
|
|
6797
|
-
options
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6799
|
+
schema,
|
|
6800
|
+
options,
|
|
6801
|
+
isUnknown ? [value] : []
|
|
6802
|
+
);
|
|
6803
|
+
inputOnChange(newValue);
|
|
6804
|
+
setValue(newValue);
|
|
6805
|
+
},
|
|
6806
|
+
[inputOnChange, isUnknown, options, schema, value]
|
|
6801
6807
|
);
|
|
6802
6808
|
showClearButton ??= nullable ? "auto" : false;
|
|
6803
6809
|
const clearedValue = nullable ? null : schema.initialValue;
|
|
@@ -6811,9 +6817,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6811
6817
|
[groupedOptions]
|
|
6812
6818
|
);
|
|
6813
6819
|
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6814
|
-
issuesToDisplay: {
|
|
6815
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
6816
|
-
},
|
|
6820
|
+
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
6817
6821
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
6818
6822
|
displayIssues,
|
|
6819
6823
|
issueMessagesProps
|
|
@@ -6824,7 +6828,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6824
6828
|
forwardedRef
|
|
6825
6829
|
);
|
|
6826
6830
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6827
|
-
/* @__PURE__ */
|
|
6831
|
+
/* @__PURE__ */ jsxs(
|
|
6828
6832
|
Select,
|
|
6829
6833
|
{
|
|
6830
6834
|
value: formattedValue,
|
|
@@ -6840,10 +6844,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6840
6844
|
popoverIssues,
|
|
6841
6845
|
endAdornment
|
|
6842
6846
|
] }),
|
|
6843
|
-
onValueChange:
|
|
6844
|
-
inputProps.onChange,
|
|
6845
|
-
handleValueChange
|
|
6846
|
-
),
|
|
6847
|
+
onValueChange: handleValueChange,
|
|
6847
6848
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
6848
6849
|
onBlurToOutside: combineEventHandlers(
|
|
6849
6850
|
onBlurToOutside,
|
|
@@ -6851,7 +6852,10 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6851
6852
|
),
|
|
6852
6853
|
...otherProps,
|
|
6853
6854
|
ref: combinedSelectRef,
|
|
6854
|
-
children:
|
|
6855
|
+
children: [
|
|
6856
|
+
isUnknown && /* @__PURE__ */ jsx(Option, { value: -1, color: "danger", keywords: [String(value)], children: /* @__PURE__ */ jsx(UnknownValue, { value, label: unknownValueLabel }) }),
|
|
6857
|
+
optionNodes
|
|
6858
|
+
]
|
|
6855
6859
|
}
|
|
6856
6860
|
),
|
|
6857
6861
|
inlineIssues
|
|
@@ -6859,10 +6863,11 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6859
6863
|
});
|
|
6860
6864
|
const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
6861
6865
|
path,
|
|
6866
|
+
options: groupedOptions,
|
|
6862
6867
|
issueMessages,
|
|
6863
6868
|
issuesPanelLabel,
|
|
6864
6869
|
displayIssues = true,
|
|
6865
|
-
|
|
6870
|
+
unknownValueLabel,
|
|
6866
6871
|
preventAutoFocus,
|
|
6867
6872
|
apiRef,
|
|
6868
6873
|
issueMessagesProps,
|
|
@@ -6884,6 +6889,8 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6884
6889
|
onBlurToOutside,
|
|
6885
6890
|
...otherProps
|
|
6886
6891
|
}, forwardedRef) {
|
|
6892
|
+
const [locale7] = useLocale();
|
|
6893
|
+
unknownValueLabel ??= locale7.SelectMultipleControl.unknownValueLabel;
|
|
6887
6894
|
const options = useMemo(
|
|
6888
6895
|
() => groupedOptions.reduce((options2, optionOrGroup) => {
|
|
6889
6896
|
if ("options" in optionOrGroup) {
|
|
@@ -6896,34 +6903,25 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6896
6903
|
[groupedOptions]
|
|
6897
6904
|
);
|
|
6898
6905
|
const [arrayValue, setArrayValue] = useState(null);
|
|
6899
|
-
const
|
|
6900
|
-
() =>
|
|
6906
|
+
const unknownValues = useMemo(
|
|
6907
|
+
() => getUnknownValues(arrayValue, options),
|
|
6901
6908
|
[options, arrayValue]
|
|
6902
6909
|
);
|
|
6910
|
+
const formattedValue = useMemo(
|
|
6911
|
+
() => formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),
|
|
6912
|
+
[options, unknownValues, arrayValue]
|
|
6913
|
+
);
|
|
6903
6914
|
const controller = useListableInput(path, {
|
|
6904
6915
|
enabled: !useFormIsLoading(),
|
|
6905
6916
|
parseToArray: useCallback(
|
|
6906
|
-
(formattedValue2
|
|
6907
|
-
|
|
6908
|
-
state.schema,
|
|
6909
|
-
options
|
|
6910
|
-
),
|
|
6911
|
-
[options]
|
|
6917
|
+
(formattedValue2) => formattedValue2 && [...formattedValue2],
|
|
6918
|
+
[]
|
|
6912
6919
|
),
|
|
6913
6920
|
formatFromArray: useCallback(
|
|
6914
|
-
(arrayValue2) =>
|
|
6915
|
-
[
|
|
6916
|
-
),
|
|
6917
|
-
setFormattedValue: useCallback(
|
|
6918
|
-
(formattedValue2, state) => setArrayValue(
|
|
6919
|
-
parseSelectionValuesFromOptionIndices(
|
|
6920
|
-
formattedValue2,
|
|
6921
|
-
state.schema,
|
|
6922
|
-
options
|
|
6923
|
-
)
|
|
6924
|
-
),
|
|
6925
|
-
[options]
|
|
6921
|
+
(arrayValue2) => arrayValue2 && [...arrayValue2],
|
|
6922
|
+
[]
|
|
6926
6923
|
),
|
|
6924
|
+
setFormattedValue: setArrayValue,
|
|
6927
6925
|
formManager,
|
|
6928
6926
|
onInitialized,
|
|
6929
6927
|
onFormManagerEvent,
|
|
@@ -6933,8 +6931,9 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6933
6931
|
onDirtyStatusChange,
|
|
6934
6932
|
onTouchedStatusChange
|
|
6935
6933
|
});
|
|
6936
|
-
const {
|
|
6937
|
-
const
|
|
6934
|
+
const { useSchema, usePath, inputProps } = controller;
|
|
6935
|
+
const schema = useSchema();
|
|
6936
|
+
const { restrictions } = schema.typeInfo;
|
|
6938
6937
|
const absolutePath = usePath();
|
|
6939
6938
|
const {
|
|
6940
6939
|
displayLoading,
|
|
@@ -6952,24 +6951,26 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6952
6951
|
preventAutoFocus,
|
|
6953
6952
|
apiRef
|
|
6954
6953
|
});
|
|
6954
|
+
const { onChange: inputOnChange } = inputProps;
|
|
6955
6955
|
const handleValueChange = useCallback(
|
|
6956
|
-
(formattedValue2) =>
|
|
6957
|
-
parseSelectionValuesFromOptionIndices(
|
|
6956
|
+
(formattedValue2) => {
|
|
6957
|
+
const newValue = parseSelectionValuesFromOptionIndices(
|
|
6958
6958
|
formattedValue2,
|
|
6959
|
-
|
|
6960
|
-
options
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6959
|
+
schema,
|
|
6960
|
+
options,
|
|
6961
|
+
unknownValues
|
|
6962
|
+
);
|
|
6963
|
+
inputOnChange(newValue);
|
|
6964
|
+
setArrayValue(newValue);
|
|
6965
|
+
},
|
|
6966
|
+
[inputOnChange, options, schema, unknownValues]
|
|
6964
6967
|
);
|
|
6965
6968
|
const optionNodes = useMemo(
|
|
6966
6969
|
() => optionObjectsToNodes(groupedOptions),
|
|
6967
6970
|
[groupedOptions]
|
|
6968
6971
|
);
|
|
6969
6972
|
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6970
|
-
issuesToDisplay: {
|
|
6971
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
6972
|
-
},
|
|
6973
|
+
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
6973
6974
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
6974
6975
|
displayIssues,
|
|
6975
6976
|
issueMessagesProps
|
|
@@ -6980,7 +6981,7 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6980
6981
|
forwardedRef
|
|
6981
6982
|
);
|
|
6982
6983
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6983
|
-
/* @__PURE__ */
|
|
6984
|
+
/* @__PURE__ */ jsxs(
|
|
6984
6985
|
Select,
|
|
6985
6986
|
{
|
|
6986
6987
|
multiple: true,
|
|
@@ -6996,10 +6997,7 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6996
6997
|
popoverIssues,
|
|
6997
6998
|
endAdornment
|
|
6998
6999
|
] }),
|
|
6999
|
-
onValueChange:
|
|
7000
|
-
inputProps.onChange,
|
|
7001
|
-
handleValueChange
|
|
7002
|
-
),
|
|
7000
|
+
onValueChange: handleValueChange,
|
|
7003
7001
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
7004
7002
|
onBlurToOutside: combineEventHandlers(
|
|
7005
7003
|
onBlurToOutside,
|
|
@@ -7007,7 +7005,19 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
7007
7005
|
),
|
|
7008
7006
|
...otherProps,
|
|
7009
7007
|
ref: combinedSelectRef,
|
|
7010
|
-
children:
|
|
7008
|
+
children: [
|
|
7009
|
+
unknownValues.map((v, i) => /* @__PURE__ */ jsx(
|
|
7010
|
+
Option,
|
|
7011
|
+
{
|
|
7012
|
+
value: -i - 1,
|
|
7013
|
+
color: "danger",
|
|
7014
|
+
keywords: v == null ? [] : [String(v)],
|
|
7015
|
+
children: /* @__PURE__ */ jsx(UnknownValue, { value: v, label: unknownValueLabel })
|
|
7016
|
+
},
|
|
7017
|
+
i
|
|
7018
|
+
)),
|
|
7019
|
+
optionNodes
|
|
7020
|
+
]
|
|
7011
7021
|
}
|
|
7012
7022
|
),
|
|
7013
7023
|
inlineIssues
|