@rankingcoach/vanguard 1.13.0 → 1.14.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.
Files changed (51) hide show
  1. package/dist/index-CsvContentValidator.js +30 -0
  2. package/dist/index-DateInput.js +4 -4
  3. package/dist/index-DateRange.js +1 -1
  4. package/dist/index-Document.types.js +3 -3
  5. package/dist/index-DocumentContentProcessor.js +42 -0
  6. package/dist/index-DocumentUpload.js +103 -109
  7. package/dist/index-InputRangeField.js +1 -1
  8. package/dist/index-LexicalToolkit2.js +1 -1
  9. package/dist/index-ModalService.js +3 -1
  10. package/dist/index-Month.js +2 -2
  11. package/dist/index-Select2.js +1 -1
  12. package/dist/index-SelectInput.js +478 -26
  13. package/dist/index-_virtual10.js +2 -5
  14. package/dist/index-_virtual11.js +5 -5
  15. package/dist/index-_virtual12.js +5 -3
  16. package/dist/index-_virtual6.js +1 -1
  17. package/dist/index-_virtual69.js +2 -2
  18. package/dist/index-_virtual70.js +4 -2
  19. package/dist/index-_virtual71.js +2 -4
  20. package/dist/index-_virtual72.js +4 -2
  21. package/dist/index-_virtual73.js +1 -1
  22. package/dist/index-_virtual74.js +1 -1
  23. package/dist/index-_virtual75.js +2 -4
  24. package/dist/index-_virtual76.js +2 -2
  25. package/dist/index-_virtual9.js +3 -2
  26. package/dist/index-accessibility.js +1 -1
  27. package/dist/index-cjs.js +1 -1
  28. package/dist/index-dist2.js +78 -20
  29. package/dist/index-dist3.js +20 -78
  30. package/dist/index-lib2.js +1 -1
  31. package/dist/index-lib3.js +1 -1
  32. package/dist/index-lib5.js +1 -1
  33. package/dist/index-video.es.js +2 -2
  34. package/dist/index.js +337 -335
  35. package/dist/types/core/Documents/Document.types.d.ts +2 -1
  36. package/dist/types/core/Documents/DocumentUpload/stories/WithCustomDimensions.story.d.ts +2 -0
  37. package/dist/types/core/Documents/DocumentUpload/stories/WithDocumentName.story.d.ts +2 -0
  38. package/dist/types/core/Documents/DocumentUpload/stories/_DocumentUpload.default.d.ts +2 -2
  39. package/dist/types/core/FileSelect/MediaItemProcessors/DocumentContentProcessor.d.ts +9 -0
  40. package/dist/types/core/FileSelect/MediaItemValidators/CsvContentValidator.d.ts +15 -0
  41. package/dist/types/core/FileSelect/index.d.ts +2 -1
  42. package/dist/types/core/FileSelect/stories/WithCsvValidator.story.d.ts +2 -0
  43. package/dist/types/core/FileSelect/stories/WithDocumentContentProcessor.story.d.ts +2 -0
  44. package/dist/types/core/Modal/stories/CloseConfirmModalViaHeader.story.d.ts +2 -0
  45. package/dist/types/core/Modal/stories/CloseViaHeaderButtonWithResponse.story.d.ts +2 -0
  46. package/dist/types/index.d.ts +2 -1
  47. package/dist/vanguard-asset-analysis.json +1 -1
  48. package/dist-wordpress/index.js +3 -1
  49. package/package.json +1 -1
  50. package/dist/index-SelectInput2.js +0 -484
  51. package/dist/types/core/FileSelect/SelectInput.d.ts +0 -11
@@ -0,0 +1,30 @@
1
+ var l = Object.defineProperty;
2
+ var d = (s, e, r) => e in s ? l(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
3
+ var t = (s, e, r) => d(s, typeof e != "symbol" ? e + "" : e, r);
4
+ import { ContentType as p } from "./index-Document.types.js";
5
+ import { MediaItemValidator as u } from "./index-MediaItemValidator.js";
6
+ class x extends u {
7
+ constructor({
8
+ requiredHeaders: r
9
+ }) {
10
+ super();
11
+ t(this, "applicableFileTypes", [p.TEXT_CSV]);
12
+ t(this, "requiredHeaders");
13
+ t(this, "validate", (r) => Promise.all(r.map((i) => this.validateMediaItem(i))));
14
+ t(this, "validateMediaItem", async (r) => {
15
+ r.isInvalid = r.isInvalid ?? !1, r.validationErrors = r.validationErrors ?? [];
16
+ const {
17
+ file: i
18
+ } = r;
19
+ if (!i) return r;
20
+ const o = ((await i.text()).split(/\r?\n/)[0] ?? "").split(",").map((a) => a.trim().toLowerCase()), n = this.requiredHeaders.filter((a) => !o.includes(a.toLowerCase()));
21
+ return n.length > 0 && (r.isInvalid = !0, r.validationErrors.push({
22
+ text: `The CSV is missing required columns: <b>${n.join(", ")}</b>.`
23
+ })), r;
24
+ });
25
+ this.requiredHeaders = r;
26
+ }
27
+ }
28
+ export {
29
+ x as CsvContentValidator
30
+ };
@@ -1,10 +1,10 @@
1
- import { __exports as p } from "./index-_virtual72.js";
1
+ import { __exports as p } from "./index-_virtual71.js";
2
2
  import k from "react";
3
3
  import { __require as K } from "./index-prop-types.js";
4
4
  import { __require as L } from "./index-classnames2.js";
5
- import U from "./index-_virtual73.js";
6
- import z from "./index-_virtual74.js";
7
- import A from "./index-_virtual75.js";
5
+ import U from "./index-_virtual72.js";
6
+ import z from "./index-_virtual73.js";
7
+ import A from "./index-_virtual74.js";
8
8
  import V from "./index-_virtual55.js";
9
9
  var q;
10
10
  function te() {
@@ -6,7 +6,7 @@ import { classNames as f } from "./index-classNames.js";
6
6
  import { datesAreDifferent as r } from "./index-date-helpers.js";
7
7
  import c from "./index-moment.js";
8
8
  import { useState as g, useEffect as d } from "react";
9
- import { d as p } from "./index-_virtual12.js";
9
+ import { d as p } from "./index-_virtual9.js";
10
10
  import { ComponentContainer as u } from "./index-ComponentContainer.js";
11
11
  const w = (a) => {
12
12
  const {
@@ -1,7 +1,7 @@
1
- const N = "image/*", i = "image/jpeg", P = "image/jpg", O = "image/png", I = "video/quicktime", T = "video/mp4", A = "unknown", g = "application/pdf";
1
+ const N = "image/*", i = "image/jpeg", P = "image/jpg", O = "image/png", I = "video/quicktime", T = "video/mp4", A = "unknown", c = "application/pdf";
2
2
  var _;
3
3
  (function(E) {
4
- E.FILE_ANY = "*", E.IMAGE_ANY = "image/*", E.IMAGE_JPEG = "image/jpeg", E.IMAGE_JPG = "image/jpg", E.IMAGE_PNG = "image/png", E.VIDEO_ANY = "video/*", E.VIDEO_MOV = "video/quicktime", E.VIDEO_MP4 = "video/mp4", E.UNKNOWN = "unknown", E.APPLICATION_PDF = "application/pdf";
4
+ E.FILE_ANY = "*", E.IMAGE_ANY = "image/*", E.IMAGE_JPEG = "image/jpeg", E.IMAGE_JPG = "image/jpg", E.IMAGE_PNG = "image/png", E.VIDEO_ANY = "video/*", E.VIDEO_MOV = "video/quicktime", E.VIDEO_MP4 = "video/mp4", E.UNKNOWN = "unknown", E.APPLICATION_PDF = "application/pdf", E.TEXT_CSV = "text/csv";
5
5
  })(_ || (_ = {}));
6
6
  export {
7
7
  N as CONTENT_TYPE_IMAGE_ANY,
@@ -11,6 +11,6 @@ export {
11
11
  A as CONTENT_TYPE_UNKNOWN,
12
12
  I as CONTENT_TYPE_VIDEO_MOV,
13
13
  T as CONTENT_TYPE_VIDEO_MP4,
14
- g as CONTENY_TYPE_APPLICATION_PDF,
14
+ c as CONTENY_TYPE_APPLICATION_PDF,
15
15
  _ as ContentType
16
16
  };
@@ -0,0 +1,42 @@
1
+ var p = Object.defineProperty;
2
+ var l = (s, e, t) => e in s ? p(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var r = (s, e, t) => l(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ContentType as d } from "./index-Document.types.js";
5
+ import { MediaItemProcessor as m } from "./index-MediaItemProcessor.js";
6
+ class P extends m {
7
+ constructor() {
8
+ super(...arguments);
9
+ r(this, "applicableFileTypes", [d.APPLICATION_PDF]);
10
+ r(this, "process", (t) => new Promise(async (i) => {
11
+ const n = [];
12
+ for (const o of t) {
13
+ const {
14
+ file: a
15
+ } = o;
16
+ if (!a || o.fileType && !this.applicableFileTypes.includes(o.fileType)) {
17
+ n.push(o);
18
+ continue;
19
+ }
20
+ const c = await this.readFileAsDataURL(a);
21
+ n.push({
22
+ ...o,
23
+ mediaItemContent: {
24
+ base64EncodedContent: c,
25
+ objectType: "DocumentContent"
26
+ }
27
+ });
28
+ }
29
+ i(n);
30
+ }));
31
+ r(this, "readFileAsDataURL", (t) => new Promise((i) => {
32
+ const n = new FileReader();
33
+ n.onload = (o) => {
34
+ var a;
35
+ i((a = o.target) == null ? void 0 : a.result);
36
+ }, n.readAsDataURL(t);
37
+ }));
38
+ }
39
+ }
40
+ export {
41
+ P as DocumentContentProcessor
42
+ };
@@ -1,146 +1,140 @@
1
- import { jsxs as s, jsx as o } from "react/jsx-runtime";
2
- import { translationService as _ } from "./index-translation.service.js";
3
- import { Button as T, ButtonSizes as g, ButtonTypes as N } from "./index-Button.js";
4
- import { ComponentContainer as c } from "./index-ComponentContainer.js";
5
- import { Icon as k, IconSize as M } from "./index-Icon.js";
6
- import { IconNames as v } from "./index-IconNames.js";
7
- import { Render as D } from "./index-Render.js";
8
- import { snackbarService as E } from "./index-SnackBarService.js";
9
- import { Text as I, FontWeights as S, TextTypes as w } from "./index-Text.js";
10
- import G from "./index-compressor.esm.js";
11
- import { useState as F, useRef as A } from "react";
12
- import { CONTENY_TYPE_APPLICATION_PDF as B, CONTENT_TYPE_IMAGE_PNG as O, CONTENT_TYPE_IMAGE_JPG as Y, CONTENT_TYPE_IMAGE_JPEG as W } from "./index-Document.types.js";
13
- import { DocumentDisplay as j } from "./index-DocumentDisplay.js";
14
- import m from "./index-DocumentUpload.module.scss.js";
15
- import L from "./index-Collapse2.js";
16
- const H = [B, O, Y, W], ce = (t) => {
1
+ import { jsxs as l, jsx as o } from "react/jsx-runtime";
2
+ import { translationService as F } from "./index-translation.service.js";
3
+ import { Button as S, ButtonSizes as y, ButtonTypes as g } from "./index-Button.js";
4
+ import { ComponentContainer as m } from "./index-ComponentContainer.js";
5
+ import { ContentType as n } from "./index-Document.types.js";
6
+ import { DocumentContentProcessor as U } from "./index-DocumentContentProcessor.js";
7
+ import { ImageContentProcessor as B } from "./index-ImageContentProcessor.js";
8
+ import { ImageCompressorTransformer as R } from "./index-ImageCompressorTransformer.js";
9
+ import { FileSizeValidator as A } from "./index-FileSizeValidator.js";
10
+ import { MediaItemSelectInput as O } from "./index-MediaItemSelectInput.js";
11
+ import { Icon as W, IconSize as _ } from "./index-Icon.js";
12
+ import { IconNames as V } from "./index-IconNames.js";
13
+ import { Render as T } from "./index-Render.js";
14
+ import { snackbarService as j } from "./index-SnackBarService.js";
15
+ import { Text as D, FontWeights as P, TextTypes as H } from "./index-Text.js";
16
+ import { useState as x } from "react";
17
+ import s from "./index-DocumentUpload.module.scss.js";
18
+ import J from "./index-Collapse2.js";
19
+ import { DocumentDisplay as q } from "./index-DocumentDisplay.js";
20
+ const L = new R({
21
+ compressorOptions: {
22
+ maxWidth: 3e3,
23
+ maxHeight: 3e3,
24
+ quality: 0.8,
25
+ convertSize: 5242880
26
+ }
27
+ }), K = new U(), Q = new B({}), X = new A({
28
+ maxSize: 5242880
29
+ }), Se = (t) => {
17
30
  const {
18
- testId: z = "DocumentUpload",
19
- onDocumentSelected: U,
20
- onDocumentRemoved: b,
21
- width: p = "192px",
22
- height: d = "154px",
23
- documentName: n
24
- } = t, [e, f] = F(), r = A(null), x = n ? _.get("Upload %documentName%", {
25
- documentName: n
26
- }).value : "Upload document", P = (h) => {
27
- const i = h.target.files && h.target.files[0];
28
- if (i) {
29
- const a = new FileReader();
30
- if (a.onload = (l) => {
31
- var C;
32
- const y = {
33
- srcIsBase64: !0,
34
- fileSrc: (C = l.target) == null ? void 0 : C.result,
35
- fileName: i.name,
36
- fileMimeType: i.type,
37
- documentName: n
38
- };
39
- f(y), U(y);
40
- }, i.type == "application/pdf") {
41
- if (i.size > 5242880) {
42
- E.openErrorSnackbar("File size must be between 10kb and 5MB.");
43
- return;
44
- }
45
- a.readAsDataURL(i);
46
- return;
47
- }
48
- new G(i, {
49
- maxWidth: 3e3,
50
- maxHeight: 3e3,
51
- quality: 0.8,
52
- convertSize: 5242880,
53
- success: (l) => {
54
- if (l.size > 5242880) {
55
- E.openErrorSnackbar("File size must be between 10kb and 5MB.");
56
- return;
57
- }
58
- a.readAsDataURL(l);
59
- }
60
- });
31
+ testId: N = "DocumentUpload",
32
+ onDocumentSelected: k,
33
+ onDocumentRemoved: v,
34
+ width: a = "192px",
35
+ height: c = "154px",
36
+ documentName: r
37
+ } = t, [e, p] = x(), [w, d] = x(!1), z = r ? F.get("Upload %documentName%", {
38
+ documentName: r
39
+ }).value : "Upload document", M = (G) => {
40
+ var C, I;
41
+ const i = G[0];
42
+ if (!i) return;
43
+ if (i.isInvalid) {
44
+ j.openErrorSnackbar("File size must be between 10kb and 5MB.");
45
+ return;
61
46
  }
62
- }, R = () => {
63
- f(void 0), b(), r.current && (r.current.value = "");
64
- }, u = () => {
65
- r.current && r.current.click();
47
+ const h = (C = i.mediaItemContent) == null ? void 0 : C.base64EncodedContent;
48
+ if (!h) return;
49
+ const E = ((I = i.file) == null ? void 0 : I.name) ?? "document", u = {
50
+ srcIsBase64: !0,
51
+ fileSrc: h,
52
+ fileName: E,
53
+ fileMimeType: i.fileType,
54
+ documentName: r
55
+ };
56
+ p(u), k(u);
57
+ }, b = () => {
58
+ p(void 0), v();
59
+ }, f = () => {
60
+ d(!0);
66
61
  };
67
- return s(c, {
68
- testId: z,
69
- className: m.container,
70
- children: [o(I, {
71
- type: w.textHelp,
72
- fontWeight: S.medium,
73
- children: n
74
- }), o(L, {
62
+ return l(m, {
63
+ testId: N,
64
+ className: s.container,
65
+ children: [o(D, {
66
+ type: H.textHelp,
67
+ fontWeight: P.medium,
68
+ children: r
69
+ }), o(J, {
75
70
  in: !!(e != null && e.fileSrc),
76
- children: o(q, {
77
- onRemove: R,
78
- onChange: u
71
+ children: o(Z, {
72
+ onRemove: b,
73
+ onChange: f
79
74
  })
80
- }), o(D, {
75
+ }), o(T, {
81
76
  if: !(e != null && e.fileSrc) || !(e != null && e.fileMimeType),
82
77
  children: o("div", {
83
78
  style: {
84
- width: p,
85
- height: d
79
+ width: a,
80
+ height: c
86
81
  },
87
- children: o(J, {
88
- text: x,
89
- onClick: u
82
+ children: o(Y, {
83
+ text: z,
84
+ onClick: f
90
85
  })
91
86
  })
92
- }), o(D, {
87
+ }), o(T, {
93
88
  if: !!(e != null && e.fileSrc) && !!(e != null && e.fileMimeType),
94
- children: o(j, {
89
+ children: o(q, {
95
90
  fileName: (e == null ? void 0 : e.fileName) ?? "file",
96
91
  fileSrc: (e == null ? void 0 : e.fileSrc) ?? "",
97
92
  fileMimeType: e == null ? void 0 : e.fileMimeType,
98
- width: p,
99
- height: d,
93
+ width: a,
94
+ height: c,
100
95
  showDownload: !1
101
96
  })
102
- }), o("input", {
103
- ref: r,
104
- id: "uploadInput",
105
- type: "file",
106
- accept: H.join(","),
107
- style: {
108
- display: "none"
109
- },
110
- onChange: P
97
+ }), o(O, {
98
+ isOpen: w,
99
+ openCallback: () => d(!1),
100
+ accept: [n.APPLICATION_PDF, n.IMAGE_PNG, n.IMAGE_JPG, n.IMAGE_JPEG],
101
+ mediaItemTransformers: [L],
102
+ mediaItemProcessors: [K, Q],
103
+ mediaItemValidators: [X],
104
+ onFilesSelected: M
111
105
  })]
112
106
  });
113
- }, J = (t) => s(c, {
107
+ }, Y = (t) => l(m, {
114
108
  testId: "UploadDocumentPlaceholder",
115
109
  onClick: t.onClick,
116
- className: m.button,
117
- children: [o(k, {
118
- type: M.large,
110
+ className: s.button,
111
+ children: [o(W, {
112
+ type: _.large,
119
113
  hasCircle: !0,
120
114
  color: "--n000",
121
115
  fillColor: "--p500",
122
116
  circleSize: 40,
123
- children: v.add
124
- }), o(I, {
125
- fontWeight: S.bold,
117
+ children: V.add
118
+ }), o(D, {
119
+ fontWeight: P.bold,
126
120
  color: "--p500",
127
121
  children: t.text
128
122
  })]
129
- }), q = (t) => s(c, {
123
+ }), Z = (t) => l(m, {
130
124
  testId: "UploadDocumentEditGroup",
131
- className: m.editGroup,
132
- children: [o(T, {
125
+ className: s.editGroup,
126
+ children: [o(S, {
133
127
  onClick: t.onRemove,
134
- type: N.secondary,
135
- size: g.small,
128
+ type: g.secondary,
129
+ size: y.small,
136
130
  children: "Remove"
137
- }), o(T, {
131
+ }), o(S, {
138
132
  onClick: t.onChange,
139
- type: N.secondary,
140
- size: g.small,
133
+ type: g.secondary,
134
+ size: y.small,
141
135
  children: "Change"
142
136
  })]
143
137
  });
144
138
  export {
145
- ce as DocumentUpload
139
+ Se as DocumentUpload
146
140
  };
@@ -1,4 +1,4 @@
1
- import { __exports as p } from "./index-_virtual69.js";
1
+ import { __exports as p } from "./index-_virtual76.js";
2
2
  import E from "react";
3
3
  import { __require as W } from "./index-prop-types.js";
4
4
  var R;
@@ -1,4 +1,4 @@
1
- import { __require as i } from "./index-dist3.js";
1
+ import { __require as i } from "./index-dist2.js";
2
2
  var r, e;
3
3
  function t() {
4
4
  return e || (e = 1, r = i()), r;
@@ -260,7 +260,9 @@ class Q {
260
260
  const a = {
261
261
  ...e
262
262
  }, s = (m) => {
263
- a.props.close && a.props.close(m), this.closeEv(l, m);
263
+ a.props.close && a.props.close(m ?? {
264
+ isOk: !1
265
+ }), this.closeEv(l, m);
264
266
  };
265
267
  o != null && o.wrapInModal && (e = n(K, {
266
268
  close: s,
@@ -1,10 +1,10 @@
1
- import { __exports as y } from "./index-_virtual70.js";
1
+ import { __exports as y } from "./index-_virtual69.js";
2
2
  import de from "react";
3
3
  import { __require as me } from "./index-prop-types.js";
4
4
  import { __require as he } from "./index-DayCell.js";
5
5
  import ye from "./index-_virtual54.js";
6
6
  import ve from "./index-_virtual37.js";
7
- import Oe from "./index-_virtual71.js";
7
+ import Oe from "./index-_virtual70.js";
8
8
  import _e from "./index-_virtual68.js";
9
9
  import De from "./index-_virtual51.js";
10
10
  import ge from "./index-_virtual41.js";
@@ -3,7 +3,7 @@ import I from "./index-objectWithoutPropertiesLoose.js";
3
3
  import * as u from "react";
4
4
  import e from "./index-_virtual16.js";
5
5
  import { clsx as z } from "./index-clsx.js";
6
- import B from "./index-SelectInput2.js";
6
+ import B from "./index-SelectInput.js";
7
7
  import G from "./index-formControlState.js";
8
8
  import H from "./index-useFormControl.js";
9
9
  import J from "./index-ArrowDropDown.js";