@norges-domstoler/dds-components 22.5.0 → 22.6.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/index.d.mts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +130 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -8825,8 +8825,12 @@ var File2 = (props) => {
|
|
|
8825
8825
|
file: stateFile,
|
|
8826
8826
|
removeFile,
|
|
8827
8827
|
isValid,
|
|
8828
|
+
uploadStatus,
|
|
8829
|
+
errorMessage,
|
|
8828
8830
|
disabled,
|
|
8829
|
-
readOnly
|
|
8831
|
+
readOnly,
|
|
8832
|
+
onRetry,
|
|
8833
|
+
fileId
|
|
8830
8834
|
} = props;
|
|
8831
8835
|
const [fileUrl, setFileUrl] = useState17();
|
|
8832
8836
|
useEffect24(() => {
|
|
@@ -8837,63 +8841,109 @@ var File2 = (props) => {
|
|
|
8837
8841
|
setFileUrl(url);
|
|
8838
8842
|
return () => URL.revokeObjectURL(url);
|
|
8839
8843
|
}
|
|
8840
|
-
}, [stateFile.file]);
|
|
8844
|
+
}, [stateFile.file, stateFile.url]);
|
|
8841
8845
|
const errorsList = stateFile.errors.map((e, errorIndex) => ({
|
|
8842
8846
|
id: derivativeIdGenerator(parentId, `file-${index}-error-${errorIndex}`),
|
|
8843
8847
|
message: e
|
|
8844
8848
|
}));
|
|
8849
|
+
if (errorMessage)
|
|
8850
|
+
errorsList.push({
|
|
8851
|
+
id: derivativeIdGenerator(
|
|
8852
|
+
parentId,
|
|
8853
|
+
`file-${index}-error-${errorsList.length}`
|
|
8854
|
+
),
|
|
8855
|
+
message: errorMessage
|
|
8856
|
+
});
|
|
8845
8857
|
const inactive = disabled || readOnly;
|
|
8858
|
+
let displayStatus;
|
|
8859
|
+
if (!isValid) displayStatus = "invalid";
|
|
8860
|
+
else if (uploadStatus) displayStatus = uploadStatus;
|
|
8861
|
+
else displayStatus = "valid";
|
|
8862
|
+
const isInvalid = displayStatus === "invalid";
|
|
8863
|
+
const hasError = displayStatus === "error" || isInvalid;
|
|
8864
|
+
const hasRetry = displayStatus === "error" && onRetry;
|
|
8865
|
+
let statusIndicator;
|
|
8866
|
+
switch (displayStatus) {
|
|
8867
|
+
case "uploading":
|
|
8868
|
+
statusIndicator = /* @__PURE__ */ jsx279(Spinner, { size: "var(--dds-size-icon-component)" });
|
|
8869
|
+
break;
|
|
8870
|
+
case "success":
|
|
8871
|
+
case "valid":
|
|
8872
|
+
statusIndicator = /* @__PURE__ */ jsx279(
|
|
8873
|
+
Icon,
|
|
8874
|
+
{
|
|
8875
|
+
icon: CheckCircledIcon,
|
|
8876
|
+
iconSize: "component",
|
|
8877
|
+
className: FileUploader_default[`file__icon--valid`]
|
|
8878
|
+
}
|
|
8879
|
+
);
|
|
8880
|
+
break;
|
|
8881
|
+
case "invalid":
|
|
8882
|
+
case "error":
|
|
8883
|
+
statusIndicator = /* @__PURE__ */ jsx279(
|
|
8884
|
+
Icon,
|
|
8885
|
+
{
|
|
8886
|
+
icon: ErrorIcon,
|
|
8887
|
+
iconSize: "component",
|
|
8888
|
+
className: FileUploader_default[`file__icon--invalid`]
|
|
8889
|
+
}
|
|
8890
|
+
);
|
|
8891
|
+
break;
|
|
8892
|
+
}
|
|
8846
8893
|
return /* @__PURE__ */ jsxs106("li", { children: [
|
|
8847
8894
|
/* @__PURE__ */ jsxs106(
|
|
8848
8895
|
Paper,
|
|
8849
8896
|
{
|
|
8850
|
-
display: "flex",
|
|
8851
|
-
alignItems: "center",
|
|
8852
|
-
justifyContent: "space-between",
|
|
8853
|
-
gap: "x0.75",
|
|
8854
8897
|
marginBlock: "x0.5 0",
|
|
8855
8898
|
padding: "x0.5 x1",
|
|
8856
|
-
border: disabled ? "border-subtle" :
|
|
8899
|
+
border: disabled ? "border-subtle" : !hasError ? "border-default" : "border-danger",
|
|
8857
8900
|
background: inactive ? "surface-field-disabled" : "surface-subtle",
|
|
8858
|
-
className: cn(
|
|
8901
|
+
className: cn(hasError && FileUploader_default["file--invalid"]),
|
|
8859
8902
|
children: [
|
|
8860
|
-
/* @__PURE__ */
|
|
8861
|
-
Typography,
|
|
8862
|
-
{
|
|
8863
|
-
as: "span",
|
|
8864
|
-
color: disabled ? "text-subtle" : readOnly ? "text-medium" : void 0,
|
|
8865
|
-
className: cn(FileUploader_default.file__name),
|
|
8866
|
-
children: fileUrl ? /* @__PURE__ */ jsx279(Link, { href: fileUrl, target: "_blank", children: stateFile.name }) : stateFile.name
|
|
8867
|
-
}
|
|
8868
|
-
),
|
|
8869
|
-
!inactive && /* @__PURE__ */ jsxs106(Fragment8, { children: [
|
|
8903
|
+
/* @__PURE__ */ jsxs106(HStack, { alignItems: "center", justifyContent: "space-between", gap: "x0.75", children: [
|
|
8870
8904
|
/* @__PURE__ */ jsx279(
|
|
8871
|
-
|
|
8905
|
+
Typography,
|
|
8872
8906
|
{
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
className: FileUploader_default
|
|
8907
|
+
as: "span",
|
|
8908
|
+
color: disabled ? "text-subtle" : readOnly ? "text-medium" : void 0,
|
|
8909
|
+
className: cn(FileUploader_default.file__name),
|
|
8910
|
+
children: fileUrl ? /* @__PURE__ */ jsx279(Link, { href: fileUrl, target: "_blank", children: stateFile.name }) : stateFile.name
|
|
8876
8911
|
}
|
|
8877
8912
|
),
|
|
8878
|
-
/* @__PURE__ */
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
"aria-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8913
|
+
!inactive && /* @__PURE__ */ jsxs106(Fragment8, { children: [
|
|
8914
|
+
statusIndicator,
|
|
8915
|
+
/* @__PURE__ */ jsx279(
|
|
8916
|
+
Button,
|
|
8917
|
+
{
|
|
8918
|
+
size: "xsmall",
|
|
8919
|
+
purpose: "tertiary",
|
|
8920
|
+
type: "button",
|
|
8921
|
+
onClick: removeFile,
|
|
8922
|
+
icon: CloseIcon,
|
|
8923
|
+
"aria-label": t(texts16.removeFile(stateFile.name)),
|
|
8924
|
+
htmlProps: {
|
|
8925
|
+
"aria-invalid": !isValid ? true : void 0,
|
|
8926
|
+
"aria-errormessage": !isValid ? t(texts16.invalidFile) : void 0,
|
|
8927
|
+
"aria-describedby": spaceSeparatedIdListGenerator(
|
|
8928
|
+
errorsList.map((e) => e.id)
|
|
8929
|
+
)
|
|
8930
|
+
}
|
|
8893
8931
|
}
|
|
8894
|
-
|
|
8895
|
-
)
|
|
8896
|
-
] })
|
|
8932
|
+
)
|
|
8933
|
+
] })
|
|
8934
|
+
] }),
|
|
8935
|
+
hasRetry && /* @__PURE__ */ jsx279(
|
|
8936
|
+
Box,
|
|
8937
|
+
{
|
|
8938
|
+
as: Button,
|
|
8939
|
+
marginBlock: "x0.75 0",
|
|
8940
|
+
size: "small",
|
|
8941
|
+
purpose: "secondary",
|
|
8942
|
+
onClick: () => onRetry(fileId),
|
|
8943
|
+
icon: RefreshIcon,
|
|
8944
|
+
children: t(texts16.tryAgain)
|
|
8945
|
+
}
|
|
8946
|
+
)
|
|
8897
8947
|
]
|
|
8898
8948
|
}
|
|
8899
8949
|
),
|
|
@@ -8914,6 +8964,14 @@ var texts16 = createTexts({
|
|
|
8914
8964
|
nn: "Ugyldig fil",
|
|
8915
8965
|
en: "Invalid file",
|
|
8916
8966
|
se: "F\xE1mohis fiila"
|
|
8967
|
+
},
|
|
8968
|
+
tryAgain: {
|
|
8969
|
+
nb: "Pr\xF8v igjen",
|
|
8970
|
+
no: "Pr\xF8v igjen",
|
|
8971
|
+
nn: "Pr\xF8v igjen",
|
|
8972
|
+
en: "Try again",
|
|
8973
|
+
// TODO: oversettelse
|
|
8974
|
+
se: "Pr\xF8v igjen"
|
|
8917
8975
|
}
|
|
8918
8976
|
});
|
|
8919
8977
|
|
|
@@ -9274,6 +9332,9 @@ var FileUploader = (props) => {
|
|
|
9274
9332
|
hideFileList,
|
|
9275
9333
|
className,
|
|
9276
9334
|
afterLabelContent,
|
|
9335
|
+
fileStatusMap,
|
|
9336
|
+
deriveId,
|
|
9337
|
+
onRetry,
|
|
9277
9338
|
...rest
|
|
9278
9339
|
} = props;
|
|
9279
9340
|
const { t } = useTranslation();
|
|
@@ -9309,19 +9370,35 @@ var FileUploader = (props) => {
|
|
|
9309
9370
|
const inputId = derivativeIdGenerator(uniqueId, "input");
|
|
9310
9371
|
const fileListId = derivativeIdGenerator(uniqueId, "file-list");
|
|
9311
9372
|
const fileListNameId = derivativeIdGenerator(uniqueId, "file-list-name");
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
{
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
|
|
9373
|
+
function toPublicFile(sf) {
|
|
9374
|
+
if (sf.file) return sf.file;
|
|
9375
|
+
if (sf.url) return { name: sf.name, url: sf.url };
|
|
9376
|
+
return null;
|
|
9377
|
+
}
|
|
9378
|
+
const fileListElements = stateFiles.map((stateFile, index) => {
|
|
9379
|
+
var _a, _b, _c;
|
|
9380
|
+
const pf = toPublicFile(stateFile);
|
|
9381
|
+
const id2 = deriveId ? pf ? deriveId(pf) : stateFile.name : (_a = stateFile.url) != null ? _a : stateFile.name;
|
|
9382
|
+
const uploadStatus = (_b = fileStatusMap == null ? void 0 : fileStatusMap.get(id2)) == null ? void 0 : _b.uploadStatus;
|
|
9383
|
+
const errorMessage2 = (_c = fileStatusMap == null ? void 0 : fileStatusMap.get(id2)) == null ? void 0 : _c.errorMessage;
|
|
9384
|
+
return /* @__PURE__ */ jsx280(
|
|
9385
|
+
File2,
|
|
9386
|
+
{
|
|
9387
|
+
parentId: uniqueId,
|
|
9388
|
+
index,
|
|
9389
|
+
file: stateFile,
|
|
9390
|
+
isValid: stateFile.errors.length === 0,
|
|
9391
|
+
removeFile: () => removeFile(stateFile),
|
|
9392
|
+
disabled,
|
|
9393
|
+
readOnly,
|
|
9394
|
+
uploadStatus,
|
|
9395
|
+
errorMessage: errorMessage2,
|
|
9396
|
+
fileId: id2,
|
|
9397
|
+
onRetry
|
|
9398
|
+
},
|
|
9399
|
+
stateFile.name
|
|
9400
|
+
);
|
|
9401
|
+
});
|
|
9325
9402
|
const rootErrorsList = rootErrors.map((e, index) => ({
|
|
9326
9403
|
id: derivativeIdGenerator(uniqueId, `error-${index}`),
|
|
9327
9404
|
message: e
|