@oslokommune/punkt-react 16.26.3 → 16.26.5
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/punkt-react.js
CHANGED
|
@@ -5692,20 +5692,20 @@ var vi = r({ tail: 5 }), yi = ({ children: e, tail: t }) => {
|
|
|
5692
5692
|
}, Bi = {
|
|
5693
5693
|
filename: Oi,
|
|
5694
5694
|
thumbnail: ki
|
|
5695
|
-
}, Vi = a(({ value: e, defaultValue: t, id: n, multiple: r = !1, uploadStrategy: i = "form", addCommentsEnabled: a = !1, renameFilesEnabled: o = !1, truncateTail: c = 4, onFilesChanged: f, onFileUploadRequested: g, extraOperations: y = [], itemRenderer: b = Bi.filename, fullwidth: x = !1, allowedFormats: S, formatErrorMessage: C, maxFileSize: w, sizeErrorMessage: T, onFileValidation: E, onFileValidate: D, errorMessage: O, hasError: k = !1, disabled: A = !1, label: ee, helptext: M,
|
|
5696
|
-
let
|
|
5697
|
-
d(
|
|
5698
|
-
let
|
|
5695
|
+
}, Vi = a(({ value: e, defaultValue: t, id: n, multiple: r = !1, uploadStrategy: i = "form", addCommentsEnabled: a = !1, renameFilesEnabled: o = !1, truncateTail: c = 4, onFilesChanged: f, onFileUploadRequested: g, extraOperations: y = [], itemRenderer: b = Bi.filename, fullwidth: x = !1, allowedFormats: S, formatErrorMessage: C, maxFileSize: w, sizeErrorMessage: T, onFileValidation: E, onFileValidate: D, errorMessage: O, hasError: k = !1, disabled: A = !1, label: ee, helptext: M, helptextDropdown: te, helptextDropdownButton: ne, optionalTag: re, optionalText: ie, requiredTag: ae, requiredText: oe, tagText: se, required: N = !1, enableImagePreview: ce = !1, "aria-describedby": le, "aria-invalid": ue, ...P }, F) => {
|
|
5696
|
+
let I = u(), de = n ?? `pkt-fileupload-${I}`, R = m(null);
|
|
5697
|
+
d(F, () => R.current, []);
|
|
5698
|
+
let z = "transfers" in P ? P.transfers : void 0, [B, V] = h(null), [H, fe] = h("");
|
|
5699
5699
|
l(() => {
|
|
5700
|
-
if (!
|
|
5701
|
-
let e = setTimeout(() =>
|
|
5700
|
+
if (!H) return;
|
|
5701
|
+
let e = setTimeout(() => fe(""), 1500);
|
|
5702
5702
|
return () => clearTimeout(e);
|
|
5703
|
-
}, [
|
|
5704
|
-
let
|
|
5705
|
-
|
|
5706
|
-
M ? `${
|
|
5707
|
-
|
|
5708
|
-
].filter(Boolean).join(" ") || void 0,
|
|
5703
|
+
}, [H]);
|
|
5704
|
+
let U = B ?? O ?? null, W = k || !!B || !!(O && O.trim()), pe = U ? `${de}-error` : void 0, G = [
|
|
5705
|
+
le,
|
|
5706
|
+
M ? `${de}-helptext` : void 0,
|
|
5707
|
+
pe
|
|
5708
|
+
].filter(Boolean).join(" ") || void 0, K = W || ue === !0 || ue === "true", me = s((e) => {
|
|
5709
5709
|
let t = Dr(e, {
|
|
5710
5710
|
allowedFormats: S,
|
|
5711
5711
|
maxFileSize: w,
|
|
@@ -5731,140 +5731,145 @@ var vi = r({ tail: 5 }), yi = ({ children: e, tail: t }) => {
|
|
|
5731
5731
|
D
|
|
5732
5732
|
]);
|
|
5733
5733
|
e !== void 0 && t !== void 0 && console.warn("PktFileupload: Både value og defaultValue er angitt. Komponenten kan være enten 'controlled' eller 'uncontrolled', ikke begge deler. Bruk kun én av dem. Se https://react.dev/reference/react-dom/components/input#controlling-an-input-with-a-state-variable"), e !== void 0 && f === void 0 && console.warn("PktFileupload: value-prop er angitt uten onFilesChanged-callback. Når en komponent er 'controlled', må endringer håndteres via en callback. Vennligst legg til onFilesChanged-callback for å håndtere endringer i fil-listen. Se https://react.dev/reference/react-dom/components/input#controlling-an-input-with-a-state-variable");
|
|
5734
|
-
let
|
|
5735
|
-
oi(
|
|
5734
|
+
let q = e !== void 0, [J, Y] = h(() => t ?? []), X = q ? e : J;
|
|
5735
|
+
oi(R, {
|
|
5736
5736
|
uploadStrategy: i,
|
|
5737
|
-
required:
|
|
5738
|
-
currentFileCount:
|
|
5739
|
-
onMissingFiles: s(() =>
|
|
5737
|
+
required: N,
|
|
5738
|
+
currentFileCount: X.length,
|
|
5739
|
+
onMissingFiles: s(() => V(yr.requiredMissing), [])
|
|
5740
5740
|
});
|
|
5741
|
-
let
|
|
5741
|
+
let Z = typeof b == "string" ? Bi[b] : b, he = b === "thumbnail", ge = typeof P.accept == "string" ? P.accept.trim() : void 0, _e = p(() => Tr(ge, S) || void 0, [ge, S]), ve = o && !he, ye = a && !he, be = s((e) => {
|
|
5742
5742
|
for (let t of e) {
|
|
5743
|
-
let e =
|
|
5743
|
+
let e = me(t.file);
|
|
5744
5744
|
if (e) {
|
|
5745
|
-
|
|
5745
|
+
V(e);
|
|
5746
5746
|
return;
|
|
5747
5747
|
}
|
|
5748
5748
|
}
|
|
5749
|
-
|
|
5750
|
-
let t = r ? [...
|
|
5751
|
-
|
|
5749
|
+
V(null);
|
|
5750
|
+
let t = r ? [...X, ...e] : [e[0]], n = r ? e : [e[0]];
|
|
5751
|
+
fe(n.length === 1 ? yr.srFileAdded(n[0].attributes.targetFilename) : yr.srFilesAdded(n.length)), q || Y(t), f?.(t), i === "custom" && g && e.forEach((e) => {
|
|
5752
5752
|
g?.(e);
|
|
5753
5753
|
});
|
|
5754
5754
|
}, [
|
|
5755
5755
|
f,
|
|
5756
|
-
|
|
5756
|
+
X,
|
|
5757
5757
|
r,
|
|
5758
5758
|
i,
|
|
5759
5759
|
g,
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
]),
|
|
5763
|
-
let n =
|
|
5760
|
+
me,
|
|
5761
|
+
q
|
|
5762
|
+
]), xe = s((e, t) => {
|
|
5763
|
+
let n = X.map((n) => n.fileId === e ? {
|
|
5764
5764
|
...n,
|
|
5765
5765
|
...t
|
|
5766
5766
|
} : n);
|
|
5767
|
-
|
|
5767
|
+
q || Y(n), f?.(n);
|
|
5768
5768
|
}, [
|
|
5769
5769
|
f,
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
]),
|
|
5773
|
-
let t =
|
|
5774
|
-
|
|
5770
|
+
X,
|
|
5771
|
+
q
|
|
5772
|
+
]), Se = s((e) => {
|
|
5773
|
+
let t = X.filter((t) => t.fileId !== e);
|
|
5774
|
+
q || Y(t), f?.(t), "onTransferCancelled" in P && P.onTransferCancelled && P.onTransferCancelled?.(e);
|
|
5775
5775
|
}, [
|
|
5776
5776
|
f,
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
]), { buildAttributeAccessors:
|
|
5777
|
+
X,
|
|
5778
|
+
P,
|
|
5779
|
+
q
|
|
5780
|
+
]), { buildAttributeAccessors: Ce } = ri(X, xe), we = p(() => {
|
|
5781
5781
|
let e = [];
|
|
5782
|
-
return
|
|
5782
|
+
return ve && e.push(ni), ye && e.push(Zr), e.push(...y), e.push(Qr(Se)), e;
|
|
5783
5783
|
}, [
|
|
5784
|
-
|
|
5785
|
-
|
|
5784
|
+
ve,
|
|
5785
|
+
ye,
|
|
5786
5786
|
y,
|
|
5787
|
-
|
|
5788
|
-
]), { totalCount:
|
|
5787
|
+
Se
|
|
5788
|
+
]), { totalCount: Te, uploadedCount: Ee, failedCount: De } = p(() => Fr(X, z), [X, z]), Oe = yr.fileLabel(Te), Q = /* @__PURE__ */ _("div", {
|
|
5789
5789
|
className: (0, j.default)("pkt-fileupload", {
|
|
5790
5790
|
"pkt-fileupload--full-width": x,
|
|
5791
|
-
"pkt-fileupload--error":
|
|
5791
|
+
"pkt-fileupload--error": W,
|
|
5792
5792
|
"pkt-fileupload--disabled": A
|
|
5793
5793
|
}),
|
|
5794
5794
|
"aria-disabled": A,
|
|
5795
5795
|
...A ? { inert: !0 } : {},
|
|
5796
5796
|
children: /* @__PURE__ */ v(Vr.Provider, {
|
|
5797
5797
|
value: {
|
|
5798
|
-
name:
|
|
5798
|
+
name: P.name || "",
|
|
5799
5799
|
multiple: !!r,
|
|
5800
|
-
id:
|
|
5800
|
+
id: de
|
|
5801
5801
|
},
|
|
5802
5802
|
children: [
|
|
5803
5803
|
/* @__PURE__ */ _("div", {
|
|
5804
5804
|
className: "pkt-sr-only",
|
|
5805
5805
|
"aria-live": "polite",
|
|
5806
5806
|
"aria-atomic": "true",
|
|
5807
|
-
children:
|
|
5807
|
+
children: H || (Te > 0 && Ee > 0 ? yr.srFilesUploadedOfTotal(Ee, Te, Oe) : "")
|
|
5808
5808
|
}),
|
|
5809
5809
|
/* @__PURE__ */ _("div", {
|
|
5810
5810
|
className: "pkt-sr-only",
|
|
5811
5811
|
"aria-live": "assertive",
|
|
5812
5812
|
"aria-atomic": "true",
|
|
5813
|
-
children:
|
|
5813
|
+
children: Te > 0 && De > 0 && yr.srFilesFailedOfTotal(De, Te, Oe)
|
|
5814
5814
|
}),
|
|
5815
5815
|
/* @__PURE__ */ _(Hr, {
|
|
5816
|
-
id:
|
|
5817
|
-
name:
|
|
5818
|
-
value:
|
|
5819
|
-
onFilesAdded:
|
|
5816
|
+
id: de,
|
|
5817
|
+
name: P.name || "",
|
|
5818
|
+
value: X,
|
|
5819
|
+
onFilesAdded: be,
|
|
5820
5820
|
multiple: r,
|
|
5821
5821
|
uploadStrategy: i,
|
|
5822
|
-
ref:
|
|
5823
|
-
accept:
|
|
5824
|
-
isThumbnailView:
|
|
5822
|
+
ref: R,
|
|
5823
|
+
accept: he ? Ir : _e,
|
|
5824
|
+
isThumbnailView: he,
|
|
5825
5825
|
disabled: A,
|
|
5826
|
-
required:
|
|
5827
|
-
"aria-required":
|
|
5828
|
-
"aria-invalid":
|
|
5829
|
-
"aria-describedby":
|
|
5826
|
+
required: N && i === "form",
|
|
5827
|
+
"aria-required": N ? "true" : void 0,
|
|
5828
|
+
"aria-invalid": K ? "true" : void 0,
|
|
5829
|
+
"aria-describedby": G,
|
|
5830
5830
|
hasVisibleLabel: !!ee
|
|
5831
5831
|
}),
|
|
5832
|
-
|
|
5832
|
+
W && U && /* @__PURE__ */ _(L, {
|
|
5833
5833
|
skin: "error",
|
|
5834
5834
|
"aria-live": "assertive",
|
|
5835
5835
|
role: "alert",
|
|
5836
5836
|
compact: !0,
|
|
5837
|
-
id:
|
|
5837
|
+
id: pe,
|
|
5838
5838
|
className: "pkt-fileupload__error-alert",
|
|
5839
|
-
children:
|
|
5839
|
+
children: U
|
|
5840
5840
|
}),
|
|
5841
|
-
|
|
5842
|
-
files:
|
|
5843
|
-
cancelTransfer:
|
|
5841
|
+
X.length > 0 && /* @__PURE__ */ _(zi, {
|
|
5842
|
+
files: X,
|
|
5843
|
+
cancelTransfer: Se,
|
|
5844
5844
|
truncateTail: c,
|
|
5845
|
-
transfers:
|
|
5845
|
+
transfers: z,
|
|
5846
5846
|
uploadStrategy: i,
|
|
5847
|
-
ItemRenderer:
|
|
5848
|
-
enableImagePreview:
|
|
5847
|
+
ItemRenderer: Z,
|
|
5848
|
+
enableImagePreview: he && ce,
|
|
5849
5849
|
disabled: A,
|
|
5850
|
-
inputName:
|
|
5851
|
-
buildAttributeAccessors:
|
|
5852
|
-
queueItemOperations:
|
|
5850
|
+
inputName: P.name || "",
|
|
5851
|
+
buildAttributeAccessors: Ce,
|
|
5852
|
+
queueItemOperations: we
|
|
5853
5853
|
})
|
|
5854
5854
|
]
|
|
5855
5855
|
})
|
|
5856
5856
|
});
|
|
5857
5857
|
return ee ? /* @__PURE__ */ _(Sn, {
|
|
5858
|
-
forId:
|
|
5858
|
+
forId: de,
|
|
5859
5859
|
label: ee,
|
|
5860
5860
|
helptext: M,
|
|
5861
|
+
helptextDropdown: te,
|
|
5862
|
+
helptextDropdownButton: ne,
|
|
5861
5863
|
disabled: A,
|
|
5862
|
-
hasError:
|
|
5863
|
-
optionalTag:
|
|
5864
|
-
|
|
5864
|
+
hasError: W,
|
|
5865
|
+
optionalTag: re,
|
|
5866
|
+
optionalText: ie,
|
|
5867
|
+
requiredTag: ae,
|
|
5868
|
+
requiredText: oe,
|
|
5869
|
+
tagText: se,
|
|
5865
5870
|
className: (0, j.default)("pkt-fileupload-wrapper", { "pkt-fileupload-wrapper--full-width": x }),
|
|
5866
|
-
children:
|
|
5867
|
-
}) :
|
|
5871
|
+
children: Q
|
|
5872
|
+
}) : Q;
|
|
5868
5873
|
});
|
|
5869
5874
|
Vi.displayName = "PktFileUpload";
|
|
5870
5875
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "16.26.
|
|
3
|
+
"version": "16.26.5",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
102
102
|
},
|
|
103
103
|
"license": "MIT",
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "0a1e6fef1813b2de00696cbdd075f060fdc1e22c"
|
|
105
105
|
}
|
|
@@ -61,11 +61,10 @@ export { formatFileSize, parseFileSize } from 'shared-utils/fileupload'
|
|
|
61
61
|
/**
|
|
62
62
|
* Shared props for `PktFileUpload` (both `form` and `custom` strategies).
|
|
63
63
|
*/
|
|
64
|
-
interface IBaseFileUploadProps
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
> {
|
|
64
|
+
interface IBaseFileUploadProps extends Omit<
|
|
65
|
+
InputHTMLAttributes<HTMLInputElement>,
|
|
66
|
+
'checked' | 'size' | 'type' | 'value' | 'onChange' | 'width' | 'defaultValue'
|
|
67
|
+
> {
|
|
69
68
|
/** Called with the next file list when files are added/removed/updated. */
|
|
70
69
|
onFilesChanged?: (files: TFileItemList) => void
|
|
71
70
|
/** Allow selecting/dropping multiple files. */
|
|
@@ -120,10 +119,20 @@ interface IBaseFileUploadProps
|
|
|
120
119
|
label?: string
|
|
121
120
|
/** Help text under the label. */
|
|
122
121
|
helptext?: string | ReactNode
|
|
123
|
-
/**
|
|
122
|
+
/** Expandable help text (dropdown). */
|
|
123
|
+
helptextDropdown?: string | ReactNode
|
|
124
|
+
/** Button label for expandable help text. */
|
|
125
|
+
helptextDropdownButton?: string
|
|
126
|
+
/** Shows an "optional" tag. */
|
|
124
127
|
optionalTag?: boolean
|
|
125
|
-
/**
|
|
128
|
+
/** Label text for the optional tag. */
|
|
129
|
+
optionalText?: string
|
|
130
|
+
/** Shows a "required" tag. */
|
|
126
131
|
requiredTag?: boolean
|
|
132
|
+
/** Label text for the required tag. */
|
|
133
|
+
requiredText?: string
|
|
134
|
+
/** Extra tag next to the label. */
|
|
135
|
+
tagText?: string | null
|
|
127
136
|
/** Marks the upload as required. Native validation is used in `form`; submit validation in `custom`. */
|
|
128
137
|
required?: boolean
|
|
129
138
|
/** Enable image preview modal (only applies to thumbnail renderer). */
|
|
@@ -131,8 +140,7 @@ interface IBaseFileUploadProps
|
|
|
131
140
|
}
|
|
132
141
|
|
|
133
142
|
interface IFileInputFileUploadProps
|
|
134
|
-
extends IBaseFileUploadProps,
|
|
135
|
-
Omit<HTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'defaultValue'> {
|
|
143
|
+
extends IBaseFileUploadProps, Omit<HTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'defaultValue'> {
|
|
136
144
|
uploadStrategy?: 'form'
|
|
137
145
|
onFileUploadRequested?: never
|
|
138
146
|
}
|
|
@@ -174,8 +182,13 @@ export const PktFileUpload: FC<IPktFileUpload> = forwardRef<HTMLInputElement, IP
|
|
|
174
182
|
disabled = false,
|
|
175
183
|
label,
|
|
176
184
|
helptext,
|
|
185
|
+
helptextDropdown,
|
|
186
|
+
helptextDropdownButton,
|
|
177
187
|
optionalTag,
|
|
188
|
+
optionalText,
|
|
178
189
|
requiredTag,
|
|
190
|
+
requiredText,
|
|
191
|
+
tagText,
|
|
179
192
|
required = false,
|
|
180
193
|
enableImagePreview = false,
|
|
181
194
|
['aria-describedby']: ariaDescribedByProp,
|
|
@@ -412,10 +425,15 @@ export const PktFileUpload: FC<IPktFileUpload> = forwardRef<HTMLInputElement, IP
|
|
|
412
425
|
forId={id}
|
|
413
426
|
label={label}
|
|
414
427
|
helptext={helptext}
|
|
428
|
+
helptextDropdown={helptextDropdown}
|
|
429
|
+
helptextDropdownButton={helptextDropdownButton}
|
|
415
430
|
disabled={disabled}
|
|
416
431
|
hasError={hasError}
|
|
417
432
|
optionalTag={optionalTag}
|
|
433
|
+
optionalText={optionalText}
|
|
418
434
|
requiredTag={requiredTag}
|
|
435
|
+
requiredText={requiredText}
|
|
436
|
+
tagText={tagText}
|
|
419
437
|
className={classNames('pkt-fileupload-wrapper', { 'pkt-fileupload-wrapper--full-width': fullwidth })}
|
|
420
438
|
>
|
|
421
439
|
{fileUploadContent}
|