@ostack.tech/ui-kform 0.13.2 → 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 +196 -181
- package/dist/ostack-ui-kform.js.map +1 -1
- package/dist/types/components/CheckboxControl/CheckboxControl.d.ts +1 -1
- package/dist/types/components/CheckboxGroupControl/CheckboxGroupControl.d.ts +3 -1
- package/dist/types/components/DateControl/DateControl.d.ts +1 -1
- package/dist/types/components/DateRangeControl/DateRangeControl.d.ts +1 -1
- package/dist/types/components/FileControl/FileControl.d.ts +1 -1
- package/dist/types/components/FormPages/FormPagesSelect.d.ts +2 -3
- package/dist/types/components/NumericControl/NumericControl.d.ts +1 -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/TextControl/TextControl.d.ts +2 -2
- 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 +8 -8
- 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
|
@@ -1519,14 +1519,14 @@ function useFormLoader({
|
|
|
1519
1519
|
if (message != null) {
|
|
1520
1520
|
addToast(message, { severity: "success" });
|
|
1521
1521
|
}
|
|
1522
|
-
} catch (
|
|
1523
|
-
if (
|
|
1522
|
+
} catch (error) {
|
|
1523
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
1524
1524
|
return;
|
|
1525
1525
|
}
|
|
1526
1526
|
if (process.env.NODE_ENV !== "production") {
|
|
1527
|
-
console.error(
|
|
1527
|
+
console.error(error);
|
|
1528
1528
|
}
|
|
1529
|
-
const message = typeof errorMessage2 === "function" ? errorMessage2(file,
|
|
1529
|
+
const message = typeof errorMessage2 === "function" ? errorMessage2(file, error) : errorMessage2;
|
|
1530
1530
|
if (message != null) {
|
|
1531
1531
|
addToast(message, { severity: "danger" });
|
|
1532
1532
|
}
|
|
@@ -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();
|
|
@@ -6370,11 +6385,19 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6370
6385
|
preventAutoFocus,
|
|
6371
6386
|
apiRef
|
|
6372
6387
|
});
|
|
6388
|
+
const { onChange: inputOnChange } = inputProps;
|
|
6373
6389
|
const handleValueChange = useCallback(
|
|
6374
|
-
(formattedValue2) =>
|
|
6375
|
-
parseSelectionValueFromOptionIndex(
|
|
6376
|
-
|
|
6377
|
-
|
|
6390
|
+
(formattedValue2) => {
|
|
6391
|
+
const newValue = parseSelectionValueFromOptionIndex(
|
|
6392
|
+
formattedValue2 ?? "",
|
|
6393
|
+
schema,
|
|
6394
|
+
options,
|
|
6395
|
+
isUnknown ? [value] : []
|
|
6396
|
+
);
|
|
6397
|
+
inputOnChange(newValue);
|
|
6398
|
+
setValue(newValue);
|
|
6399
|
+
},
|
|
6400
|
+
[inputOnChange, isUnknown, options, schema, value]
|
|
6378
6401
|
);
|
|
6379
6402
|
const clearedValue = nullable ? null : schema.initialValue;
|
|
6380
6403
|
const clearedIdx = useMemo(
|
|
@@ -6383,9 +6406,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6383
6406
|
);
|
|
6384
6407
|
const clearedFormattedValue = clearedIdx === -1 ? "" : clearedIdx.toString();
|
|
6385
6408
|
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6386
|
-
issuesToDisplay: {
|
|
6387
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
6388
|
-
},
|
|
6409
|
+
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
6389
6410
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
6390
6411
|
displayIssues,
|
|
6391
6412
|
issueMessagesProps
|
|
@@ -6396,7 +6417,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6396
6417
|
forwardedRef
|
|
6397
6418
|
);
|
|
6398
6419
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6399
|
-
/* @__PURE__ */
|
|
6420
|
+
/* @__PURE__ */ jsxs(
|
|
6400
6421
|
RadioGroup,
|
|
6401
6422
|
{
|
|
6402
6423
|
value: formattedValue,
|
|
@@ -6408,10 +6429,7 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6408
6429
|
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
6409
6430
|
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
6410
6431
|
showClearButton: showClearButton === "auto" ? formattedValue !== clearedFormattedValue : showClearButton,
|
|
6411
|
-
onValueChange:
|
|
6412
|
-
inputProps.onChange,
|
|
6413
|
-
handleValueChange
|
|
6414
|
-
),
|
|
6432
|
+
onValueChange: handleValueChange,
|
|
6415
6433
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
6416
6434
|
onBlurToOutside: combineEventHandlers(
|
|
6417
6435
|
onBlurToOutside,
|
|
@@ -6419,7 +6437,10 @@ const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
|
6419
6437
|
),
|
|
6420
6438
|
...otherProps,
|
|
6421
6439
|
ref: combinedRadioGroupRef,
|
|
6422
|
-
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
|
+
]
|
|
6423
6444
|
}
|
|
6424
6445
|
),
|
|
6425
6446
|
inlineIssues,
|
|
@@ -6511,14 +6532,14 @@ function useFormSaver({
|
|
|
6511
6532
|
addToast(message, { severity: "success" });
|
|
6512
6533
|
}
|
|
6513
6534
|
}
|
|
6514
|
-
} catch (
|
|
6515
|
-
if (
|
|
6535
|
+
} catch (error) {
|
|
6536
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
6516
6537
|
return;
|
|
6517
6538
|
}
|
|
6518
6539
|
if (process.env.NODE_ENV !== "production") {
|
|
6519
|
-
console.error(
|
|
6540
|
+
console.error(error);
|
|
6520
6541
|
}
|
|
6521
|
-
const message = typeof errorMessage2 == "function" ? errorMessage2(fileHandle,
|
|
6542
|
+
const message = typeof errorMessage2 == "function" ? errorMessage2(fileHandle, error) : errorMessage2;
|
|
6522
6543
|
if (message != null) {
|
|
6523
6544
|
addToast(message, { severity: "danger" });
|
|
6524
6545
|
}
|
|
@@ -6693,6 +6714,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6693
6714
|
issueMessages,
|
|
6694
6715
|
issuesPanelLabel,
|
|
6695
6716
|
displayIssues = true,
|
|
6717
|
+
unknownValueLabel,
|
|
6696
6718
|
preventAutoFocus,
|
|
6697
6719
|
apiRef,
|
|
6698
6720
|
issueMessagesProps,
|
|
@@ -6715,6 +6737,8 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6715
6737
|
onBlurToOutside,
|
|
6716
6738
|
...otherProps
|
|
6717
6739
|
}, forwardedRef) {
|
|
6740
|
+
const [locale7] = useLocale();
|
|
6741
|
+
unknownValueLabel ??= locale7.SelectControl.unknownValueLabel;
|
|
6718
6742
|
const options = useMemo(
|
|
6719
6743
|
() => groupedOptions.reduce((options2, optionOrGroup) => {
|
|
6720
6744
|
if ("options" in optionOrGroup) {
|
|
@@ -6727,34 +6751,17 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6727
6751
|
[groupedOptions]
|
|
6728
6752
|
);
|
|
6729
6753
|
const [value, setValue] = useState();
|
|
6754
|
+
const isUnknown = useMemo(
|
|
6755
|
+
() => isUnknownValue(value, options),
|
|
6756
|
+
[options, value]
|
|
6757
|
+
);
|
|
6730
6758
|
const formattedValue = useMemo(
|
|
6731
6759
|
() => formatSelectionValueAsOptionIndex(value, options),
|
|
6732
6760
|
[options, value]
|
|
6733
6761
|
);
|
|
6734
6762
|
const controller = useInput(path, {
|
|
6735
6763
|
enabled: !useFormIsLoading(),
|
|
6736
|
-
|
|
6737
|
-
(formattedValue2, state) => parseSelectionValueFromOptionIndex(
|
|
6738
|
-
formattedValue2,
|
|
6739
|
-
state.schema,
|
|
6740
|
-
options
|
|
6741
|
-
),
|
|
6742
|
-
[options]
|
|
6743
|
-
),
|
|
6744
|
-
format: useCallback(
|
|
6745
|
-
(value2) => formatSelectionValueAsOptionIndex(value2, options),
|
|
6746
|
-
[options]
|
|
6747
|
-
),
|
|
6748
|
-
setFormattedValue: useCallback(
|
|
6749
|
-
(formattedValue2, state) => setValue(
|
|
6750
|
-
parseSelectionValueFromOptionIndex(
|
|
6751
|
-
formattedValue2,
|
|
6752
|
-
state.schema,
|
|
6753
|
-
options
|
|
6754
|
-
)
|
|
6755
|
-
),
|
|
6756
|
-
[options]
|
|
6757
|
-
),
|
|
6764
|
+
setFormattedValue: setValue,
|
|
6758
6765
|
formManager,
|
|
6759
6766
|
onInitialized,
|
|
6760
6767
|
onFormManagerEvent,
|
|
@@ -6764,7 +6771,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6764
6771
|
onDirtyStatusChange,
|
|
6765
6772
|
onTouchedStatusChange
|
|
6766
6773
|
});
|
|
6767
|
-
const {
|
|
6774
|
+
const { useSchema, usePath, inputProps } = controller;
|
|
6768
6775
|
const schema = useSchema();
|
|
6769
6776
|
const absolutePath = usePath();
|
|
6770
6777
|
const { nullable, restrictions } = schema.typeInfo;
|
|
@@ -6784,15 +6791,19 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6784
6791
|
preventAutoFocus,
|
|
6785
6792
|
apiRef
|
|
6786
6793
|
});
|
|
6794
|
+
const { onChange: inputOnChange } = inputProps;
|
|
6787
6795
|
const handleValueChange = useCallback(
|
|
6788
|
-
(formattedValue2) =>
|
|
6789
|
-
parseSelectionValueFromOptionIndex(
|
|
6796
|
+
(formattedValue2) => {
|
|
6797
|
+
const newValue = parseSelectionValueFromOptionIndex(
|
|
6790
6798
|
formattedValue2,
|
|
6791
|
-
|
|
6792
|
-
options
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6799
|
+
schema,
|
|
6800
|
+
options,
|
|
6801
|
+
isUnknown ? [value] : []
|
|
6802
|
+
);
|
|
6803
|
+
inputOnChange(newValue);
|
|
6804
|
+
setValue(newValue);
|
|
6805
|
+
},
|
|
6806
|
+
[inputOnChange, isUnknown, options, schema, value]
|
|
6796
6807
|
);
|
|
6797
6808
|
showClearButton ??= nullable ? "auto" : false;
|
|
6798
6809
|
const clearedValue = nullable ? null : schema.initialValue;
|
|
@@ -6806,9 +6817,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6806
6817
|
[groupedOptions]
|
|
6807
6818
|
);
|
|
6808
6819
|
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6809
|
-
issuesToDisplay: {
|
|
6810
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
6811
|
-
},
|
|
6820
|
+
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
6812
6821
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
6813
6822
|
displayIssues,
|
|
6814
6823
|
issueMessagesProps
|
|
@@ -6819,7 +6828,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6819
6828
|
forwardedRef
|
|
6820
6829
|
);
|
|
6821
6830
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6822
|
-
/* @__PURE__ */
|
|
6831
|
+
/* @__PURE__ */ jsxs(
|
|
6823
6832
|
Select,
|
|
6824
6833
|
{
|
|
6825
6834
|
value: formattedValue,
|
|
@@ -6835,10 +6844,7 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6835
6844
|
popoverIssues,
|
|
6836
6845
|
endAdornment
|
|
6837
6846
|
] }),
|
|
6838
|
-
onValueChange:
|
|
6839
|
-
inputProps.onChange,
|
|
6840
|
-
handleValueChange
|
|
6841
|
-
),
|
|
6847
|
+
onValueChange: handleValueChange,
|
|
6842
6848
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
6843
6849
|
onBlurToOutside: combineEventHandlers(
|
|
6844
6850
|
onBlurToOutside,
|
|
@@ -6846,7 +6852,10 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6846
6852
|
),
|
|
6847
6853
|
...otherProps,
|
|
6848
6854
|
ref: combinedSelectRef,
|
|
6849
|
-
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
|
+
]
|
|
6850
6859
|
}
|
|
6851
6860
|
),
|
|
6852
6861
|
inlineIssues
|
|
@@ -6854,10 +6863,11 @@ const SelectControl = forwardRef(function SelectControl2({
|
|
|
6854
6863
|
});
|
|
6855
6864
|
const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
6856
6865
|
path,
|
|
6866
|
+
options: groupedOptions,
|
|
6857
6867
|
issueMessages,
|
|
6858
6868
|
issuesPanelLabel,
|
|
6859
6869
|
displayIssues = true,
|
|
6860
|
-
|
|
6870
|
+
unknownValueLabel,
|
|
6861
6871
|
preventAutoFocus,
|
|
6862
6872
|
apiRef,
|
|
6863
6873
|
issueMessagesProps,
|
|
@@ -6879,6 +6889,8 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6879
6889
|
onBlurToOutside,
|
|
6880
6890
|
...otherProps
|
|
6881
6891
|
}, forwardedRef) {
|
|
6892
|
+
const [locale7] = useLocale();
|
|
6893
|
+
unknownValueLabel ??= locale7.SelectMultipleControl.unknownValueLabel;
|
|
6882
6894
|
const options = useMemo(
|
|
6883
6895
|
() => groupedOptions.reduce((options2, optionOrGroup) => {
|
|
6884
6896
|
if ("options" in optionOrGroup) {
|
|
@@ -6891,34 +6903,25 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6891
6903
|
[groupedOptions]
|
|
6892
6904
|
);
|
|
6893
6905
|
const [arrayValue, setArrayValue] = useState(null);
|
|
6894
|
-
const
|
|
6895
|
-
() =>
|
|
6906
|
+
const unknownValues = useMemo(
|
|
6907
|
+
() => getUnknownValues(arrayValue, options),
|
|
6896
6908
|
[options, arrayValue]
|
|
6897
6909
|
);
|
|
6910
|
+
const formattedValue = useMemo(
|
|
6911
|
+
() => formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),
|
|
6912
|
+
[options, unknownValues, arrayValue]
|
|
6913
|
+
);
|
|
6898
6914
|
const controller = useListableInput(path, {
|
|
6899
6915
|
enabled: !useFormIsLoading(),
|
|
6900
6916
|
parseToArray: useCallback(
|
|
6901
|
-
(formattedValue2
|
|
6902
|
-
|
|
6903
|
-
state.schema,
|
|
6904
|
-
options
|
|
6905
|
-
),
|
|
6906
|
-
[options]
|
|
6917
|
+
(formattedValue2) => formattedValue2 && [...formattedValue2],
|
|
6918
|
+
[]
|
|
6907
6919
|
),
|
|
6908
6920
|
formatFromArray: useCallback(
|
|
6909
|
-
(arrayValue2) =>
|
|
6910
|
-
[
|
|
6911
|
-
),
|
|
6912
|
-
setFormattedValue: useCallback(
|
|
6913
|
-
(formattedValue2, state) => setArrayValue(
|
|
6914
|
-
parseSelectionValuesFromOptionIndices(
|
|
6915
|
-
formattedValue2,
|
|
6916
|
-
state.schema,
|
|
6917
|
-
options
|
|
6918
|
-
)
|
|
6919
|
-
),
|
|
6920
|
-
[options]
|
|
6921
|
+
(arrayValue2) => arrayValue2 && [...arrayValue2],
|
|
6922
|
+
[]
|
|
6921
6923
|
),
|
|
6924
|
+
setFormattedValue: setArrayValue,
|
|
6922
6925
|
formManager,
|
|
6923
6926
|
onInitialized,
|
|
6924
6927
|
onFormManagerEvent,
|
|
@@ -6928,8 +6931,9 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6928
6931
|
onDirtyStatusChange,
|
|
6929
6932
|
onTouchedStatusChange
|
|
6930
6933
|
});
|
|
6931
|
-
const {
|
|
6932
|
-
const
|
|
6934
|
+
const { useSchema, usePath, inputProps } = controller;
|
|
6935
|
+
const schema = useSchema();
|
|
6936
|
+
const { restrictions } = schema.typeInfo;
|
|
6933
6937
|
const absolutePath = usePath();
|
|
6934
6938
|
const {
|
|
6935
6939
|
displayLoading,
|
|
@@ -6947,24 +6951,26 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6947
6951
|
preventAutoFocus,
|
|
6948
6952
|
apiRef
|
|
6949
6953
|
});
|
|
6954
|
+
const { onChange: inputOnChange } = inputProps;
|
|
6950
6955
|
const handleValueChange = useCallback(
|
|
6951
|
-
(formattedValue2) =>
|
|
6952
|
-
parseSelectionValuesFromOptionIndices(
|
|
6956
|
+
(formattedValue2) => {
|
|
6957
|
+
const newValue = parseSelectionValuesFromOptionIndices(
|
|
6953
6958
|
formattedValue2,
|
|
6954
|
-
|
|
6955
|
-
options
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
+
schema,
|
|
6960
|
+
options,
|
|
6961
|
+
unknownValues
|
|
6962
|
+
);
|
|
6963
|
+
inputOnChange(newValue);
|
|
6964
|
+
setArrayValue(newValue);
|
|
6965
|
+
},
|
|
6966
|
+
[inputOnChange, options, schema, unknownValues]
|
|
6959
6967
|
);
|
|
6960
6968
|
const optionNodes = useMemo(
|
|
6961
6969
|
() => optionObjectsToNodes(groupedOptions),
|
|
6962
6970
|
[groupedOptions]
|
|
6963
6971
|
);
|
|
6964
6972
|
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6965
|
-
issuesToDisplay: {
|
|
6966
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
6967
|
-
},
|
|
6973
|
+
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
6968
6974
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
6969
6975
|
displayIssues,
|
|
6970
6976
|
issueMessagesProps
|
|
@@ -6975,7 +6981,7 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6975
6981
|
forwardedRef
|
|
6976
6982
|
);
|
|
6977
6983
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6978
|
-
/* @__PURE__ */
|
|
6984
|
+
/* @__PURE__ */ jsxs(
|
|
6979
6985
|
Select,
|
|
6980
6986
|
{
|
|
6981
6987
|
multiple: true,
|
|
@@ -6991,10 +6997,7 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
6991
6997
|
popoverIssues,
|
|
6992
6998
|
endAdornment
|
|
6993
6999
|
] }),
|
|
6994
|
-
onValueChange:
|
|
6995
|
-
inputProps.onChange,
|
|
6996
|
-
handleValueChange
|
|
6997
|
-
),
|
|
7000
|
+
onValueChange: handleValueChange,
|
|
6998
7001
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
6999
7002
|
onBlurToOutside: combineEventHandlers(
|
|
7000
7003
|
onBlurToOutside,
|
|
@@ -7002,7 +7005,19 @@ const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
|
7002
7005
|
),
|
|
7003
7006
|
...otherProps,
|
|
7004
7007
|
ref: combinedSelectRef,
|
|
7005
|
-
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
|
+
]
|
|
7006
7021
|
}
|
|
7007
7022
|
),
|
|
7008
7023
|
inlineIssues
|