ag-common 0.0.419 → 0.0.421

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 (178) hide show
  1. package/dist/api/helpers/api.js +35 -34
  2. package/dist/api/helpers/aws.js +13 -9
  3. package/dist/api/helpers/cloudfront.js +24 -7
  4. package/dist/api/helpers/dynamo.js +134 -85
  5. package/dist/api/helpers/dynamoInfra.js +19 -14
  6. package/dist/api/helpers/enforceDynamoProvisionCap.js +18 -14
  7. package/dist/api/helpers/index.js +30 -14
  8. package/dist/api/helpers/openApiHelpers.js +37 -34
  9. package/dist/api/helpers/s3.js +126 -81
  10. package/dist/api/helpers/ses.js +28 -9
  11. package/dist/api/helpers/sqs.js +26 -9
  12. package/dist/api/helpers/ssm.js +14 -8
  13. package/dist/api/helpers/sts.js +34 -16
  14. package/dist/api/helpers/validateOpenApi.js +103 -92
  15. package/dist/api/helpers/validations.js +46 -29
  16. package/dist/api/index.js +18 -2
  17. package/dist/api/openapi-prefix.js +38 -25
  18. package/dist/api/types/aws.js +2 -1
  19. package/dist/api/types/index.js +17 -1
  20. package/dist/common/const.js +5 -2
  21. package/dist/common/helpers/array.js +19 -8
  22. package/dist/common/helpers/async.js +28 -10
  23. package/dist/common/helpers/binary.js +10 -5
  24. package/dist/common/helpers/date.js +25 -14
  25. package/dist/common/helpers/email.js +11 -5
  26. package/dist/common/helpers/func.js +7 -3
  27. package/dist/common/helpers/generator.js +24 -9
  28. package/dist/common/helpers/groupBy.js +9 -3
  29. package/dist/common/helpers/hashCode.js +9 -3
  30. package/dist/common/helpers/i18n.js +17 -9
  31. package/dist/common/helpers/index.js +34 -18
  32. package/dist/common/helpers/log.js +28 -16
  33. package/dist/common/helpers/math.js +21 -9
  34. package/dist/common/helpers/memo.js +7 -3
  35. package/dist/common/helpers/object.js +35 -20
  36. package/dist/common/helpers/random.js +10 -4
  37. package/dist/common/helpers/secondsInNearest.js +7 -2
  38. package/dist/common/helpers/sleep.js +5 -1
  39. package/dist/common/helpers/string/base64.js +7 -2
  40. package/dist/common/helpers/string/chunk.js +5 -1
  41. package/dist/common/helpers/string/contains.js +7 -2
  42. package/dist/common/helpers/string/getExtendedStringSegment.js +9 -5
  43. package/dist/common/helpers/string/index.js +26 -10
  44. package/dist/common/helpers/string/json.js +5 -1
  45. package/dist/common/helpers/string/object.js +5 -1
  46. package/dist/common/helpers/string/surround.js +5 -1
  47. package/dist/common/helpers/string/trim.js +7 -2
  48. package/dist/common/helpers/string/truncate.js +5 -1
  49. package/dist/common/helpers/string/url.js +9 -4
  50. package/dist/common/index.js +18 -2
  51. package/dist/index.js +19 -3
  52. package/dist/ui/components/BorderGradient/index.js +25 -18
  53. package/dist/ui/components/Button/index.js +25 -17
  54. package/dist/ui/components/Chevron/index.js +16 -9
  55. package/dist/ui/components/Close/index.js +13 -6
  56. package/dist/ui/components/Confirm/Dialog.js +25 -9
  57. package/dist/ui/components/Confirm/Modal.js +27 -20
  58. package/dist/ui/components/Confirm/index.js +19 -3
  59. package/dist/ui/components/Confirm/types.js +2 -1
  60. package/dist/ui/components/DropdownList/Base.js +64 -33
  61. package/dist/ui/components/DropdownList/Dialog.js +24 -8
  62. package/dist/ui/components/DropdownList/index.js +18 -2
  63. package/dist/ui/components/DropdownList/types.js +2 -1
  64. package/dist/ui/components/FlexColumn/index.js +14 -4
  65. package/dist/ui/components/FlexRow/index.js +14 -4
  66. package/dist/ui/components/HeadersRaw/index.js +27 -20
  67. package/dist/ui/components/HorizontalScrollBar/index.js +34 -6
  68. package/dist/ui/components/Icon/index.js +16 -9
  69. package/dist/ui/components/Image/index.js +28 -10
  70. package/dist/ui/components/InfiniteScroll/index.js +50 -18
  71. package/dist/ui/components/KebabDots/index.js +13 -6
  72. package/dist/ui/components/Loader/index.js +39 -9
  73. package/dist/ui/components/Modal/Dialog.js +23 -7
  74. package/dist/ui/components/Modal/Modal.js +49 -19
  75. package/dist/ui/components/Modal/index.js +19 -3
  76. package/dist/ui/components/Modal/types.js +2 -1
  77. package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +34 -26
  78. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +19 -12
  79. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +11 -6
  80. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +15 -8
  81. package/dist/ui/components/OpenApiCodeBlock/curl/index.js +21 -14
  82. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +15 -8
  83. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +8 -3
  84. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +34 -27
  85. package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +18 -11
  86. package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +17 -7
  87. package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +15 -6
  88. package/dist/ui/components/OpenApiCodeBlock/index.js +18 -2
  89. package/dist/ui/components/OpenApiCodeBlock/types.js +2 -1
  90. package/dist/ui/components/PieChart/index.js +18 -11
  91. package/dist/ui/components/ProgressBar/index.js +45 -15
  92. package/dist/ui/components/Prompt/Dialog.js +23 -7
  93. package/dist/ui/components/Prompt/Modal.js +55 -25
  94. package/dist/ui/components/Prompt/index.js +18 -2
  95. package/dist/ui/components/RowOrColumn/index.js +17 -7
  96. package/dist/ui/components/Search/AutoHideSearchBox.js +56 -24
  97. package/dist/ui/components/Search/Base.js +52 -21
  98. package/dist/ui/components/Search/Dialog.js +26 -10
  99. package/dist/ui/components/Search/Inline.js +10 -3
  100. package/dist/ui/components/Search/Modal.js +17 -10
  101. package/dist/ui/components/Search/SearchBox.js +58 -26
  102. package/dist/ui/components/Search/index.js +23 -7
  103. package/dist/ui/components/Search/types.js +2 -1
  104. package/dist/ui/components/Sidebar/index.js +25 -18
  105. package/dist/ui/components/SparkLine/index.js +27 -17
  106. package/dist/ui/components/Table/index.js +22 -15
  107. package/dist/ui/components/TextEdit/CheckboxEdit.js +51 -21
  108. package/dist/ui/components/TextEdit/ColourEdit.js +44 -17
  109. package/dist/ui/components/TextEdit/LengthBox.js +12 -5
  110. package/dist/ui/components/TextEdit/ListboxEdit.js +42 -15
  111. package/dist/ui/components/TextEdit/RadioGroup.js +43 -13
  112. package/dist/ui/components/TextEdit/TextEdit.js +78 -48
  113. package/dist/ui/components/TextEdit/common.js +17 -11
  114. package/dist/ui/components/TextEdit/index.js +22 -6
  115. package/dist/ui/components/TextEdit/types.js +2 -1
  116. package/dist/ui/components/TextWithButton/index.js +40 -10
  117. package/dist/ui/components/TimelineChart/index.js +24 -14
  118. package/dist/ui/components/Toast/Cross.js +16 -9
  119. package/dist/ui/components/Toast/Tick.js +11 -4
  120. package/dist/ui/components/Toast/Warning.js +15 -8
  121. package/dist/ui/components/Toast/base.js +65 -33
  122. package/dist/ui/components/Toast/index.js +18 -2
  123. package/dist/ui/components/Toast/types.js +2 -1
  124. package/dist/ui/components/UserImage/index.js +48 -17
  125. package/dist/ui/components/index.js +46 -30
  126. package/dist/ui/helpers/axiosHelper.js +39 -25
  127. package/dist/ui/helpers/browserHelpers.js +22 -7
  128. package/dist/ui/helpers/callOpenApi/cached.js +37 -18
  129. package/dist/ui/helpers/callOpenApi/direct.js +59 -46
  130. package/dist/ui/helpers/callOpenApi/helpers.js +40 -25
  131. package/dist/ui/helpers/callOpenApi/hook.js +36 -47
  132. package/dist/ui/helpers/callOpenApi/index.js +21 -5
  133. package/dist/ui/helpers/callOpenApi/types.js +2 -1
  134. package/dist/ui/helpers/cognito.js +2 -1
  135. package/dist/ui/helpers/cookie/const.js +5 -2
  136. package/dist/ui/helpers/cookie/get.js +14 -13
  137. package/dist/ui/helpers/cookie/index.js +21 -5
  138. package/dist/ui/helpers/cookie/raw.js +16 -9
  139. package/dist/ui/helpers/cookie/set.js +15 -10
  140. package/dist/ui/helpers/cookie/use.js +16 -23
  141. package/dist/ui/helpers/date.js +15 -10
  142. package/dist/ui/helpers/debounce.js +10 -5
  143. package/dist/ui/helpers/dom.js +13 -6
  144. package/dist/ui/helpers/extractAttributes.js +7 -2
  145. package/dist/ui/helpers/index.js +41 -25
  146. package/dist/ui/helpers/jwt.js +2 -1
  147. package/dist/ui/helpers/plural.js +5 -1
  148. package/dist/ui/helpers/routes.js +24 -17
  149. package/dist/ui/helpers/serviceWorker.js +23 -8
  150. package/dist/ui/helpers/useContextMenu.js +14 -9
  151. package/dist/ui/helpers/useElementAttribute.js +7 -3
  152. package/dist/ui/helpers/useGranularHook.js +10 -5
  153. package/dist/ui/helpers/useInterval.js +12 -8
  154. package/dist/ui/helpers/useLocalStorage.js +32 -24
  155. package/dist/ui/helpers/useLockBodyScroll.js +7 -3
  156. package/dist/ui/helpers/useOnClickOutside.js +12 -7
  157. package/dist/ui/helpers/useOnScroll.js +21 -15
  158. package/dist/ui/helpers/useOverloadPageSearch.js +7 -3
  159. package/dist/ui/helpers/useQueryString.js +20 -14
  160. package/dist/ui/helpers/useResize.js +19 -17
  161. package/dist/ui/helpers/useTimeout.js +9 -5
  162. package/dist/ui/icons/ChevronRight.js +9 -3
  163. package/dist/ui/icons/CrossIcon.js +12 -5
  164. package/dist/ui/icons/Door.js +10 -4
  165. package/dist/ui/icons/HorizontalDots.js +9 -3
  166. package/dist/ui/icons/Magnify.js +10 -3
  167. package/dist/ui/icons/Pencil.js +12 -5
  168. package/dist/ui/icons/Save.js +11 -4
  169. package/dist/ui/icons/Undo.js +12 -5
  170. package/dist/ui/icons/UserOutline.js +9 -3
  171. package/dist/ui/icons/index.js +25 -9
  172. package/dist/ui/index.js +20 -4
  173. package/dist/ui/styles/colours.js +12 -7
  174. package/dist/ui/styles/common.js +22 -14
  175. package/dist/ui/styles/index.js +20 -4
  176. package/dist/ui/styles/media.js +10 -7
  177. package/dist/ui/styles/standaloneStyles.js +16 -10
  178. package/package.json +2 -2
@@ -1,11 +1,15 @@
1
- import { hashCode } from './hashCode';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memo = void 0;
4
+ const hashCode_1 = require("./hashCode");
2
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
6
  const memoData = {};
4
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
- export function memo(func, ...args) {
6
- const hc = hashCode(JSON.stringify(args));
8
+ function memo(func, ...args) {
9
+ const hc = (0, hashCode_1.hashCode)(JSON.stringify(args));
7
10
  if (!memoData[hc]) {
8
11
  memoData[hc] = func(...args);
9
12
  }
10
13
  return memoData[hc];
11
14
  }
15
+ exports.memo = memo;
@@ -1,5 +1,8 @@
1
- import { trim } from '.';
2
- export const tryJsonParse = (str, defaultValue) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObject = exports.castStringlyObject = exports.removeUndefValuesFromObject = exports.castObject = exports.objectToString = exports.paramsToObject = exports.objectAlphaSort = exports.objectToArray = exports.getObjectKeysAsNumber = exports.objectKeysToLowerCase = exports.isJson = exports.tryJsonParse = void 0;
4
+ const _1 = require(".");
5
+ const tryJsonParse = (str, defaultValue) => {
3
6
  if (!str) {
4
7
  return null;
5
8
  }
@@ -10,7 +13,8 @@ export const tryJsonParse = (str, defaultValue) => {
10
13
  return defaultValue;
11
14
  }
12
15
  };
13
- export function isJson(str) {
16
+ exports.tryJsonParse = tryJsonParse;
17
+ function isJson(str) {
14
18
  try {
15
19
  JSON.parse(typeof str === 'string' ? str : JSON.stringify(str));
16
20
  }
@@ -19,7 +23,8 @@ export function isJson(str) {
19
23
  }
20
24
  return true;
21
25
  }
22
- export const objectKeysToLowerCase = (origObj) => {
26
+ exports.isJson = isJson;
27
+ const objectKeysToLowerCase = (origObj) => {
23
28
  if (!origObj || Object.keys(origObj).length === 0) {
24
29
  return {};
25
30
  }
@@ -27,15 +32,17 @@ export const objectKeysToLowerCase = (origObj) => {
27
32
  const val = origObj[key];
28
33
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
34
  const newVal = typeof val === 'object'
30
- ? objectKeysToLowerCase(val)
35
+ ? (0, exports.objectKeysToLowerCase)(val)
31
36
  : val;
32
37
  // eslint-disable-next-line no-param-reassign
33
38
  newObj[key.toLowerCase()] = newVal;
34
39
  return newObj;
35
40
  }, {});
36
41
  };
37
- export const getObjectKeysAsNumber = (o) => Object.keys(o).map((o2) => parseInt(o2, 10));
38
- export function objectToArray(obj) {
42
+ exports.objectKeysToLowerCase = objectKeysToLowerCase;
43
+ const getObjectKeysAsNumber = (o) => Object.keys(o).map((o2) => parseInt(o2, 10));
44
+ exports.getObjectKeysAsNumber = getObjectKeysAsNumber;
45
+ function objectToArray(obj) {
39
46
  if (!obj) {
40
47
  return [];
41
48
  }
@@ -45,6 +52,7 @@ export function objectToArray(obj) {
45
52
  });
46
53
  return ret;
47
54
  }
55
+ exports.objectToArray = objectToArray;
48
56
  /**
49
57
  * Recursively alphabetically sort an object
50
58
  * @param object
@@ -52,7 +60,7 @@ export function objectToArray(obj) {
52
60
  * @returns
53
61
  */
54
62
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- export const objectAlphaSort = (object, depthLeft = -1) => {
63
+ const objectAlphaSort = (object, depthLeft = -1) => {
56
64
  if (depthLeft === 0) {
57
65
  return object;
58
66
  }
@@ -61,30 +69,32 @@ export const objectAlphaSort = (object, depthLeft = -1) => {
61
69
  .sort((a, b) => (a.toLowerCase() < b.toLowerCase() ? -1 : 1))
62
70
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
71
  .reduce((result, key) => {
64
- result[key] = objectAlphaSort(object[key], depthLeft - 1);
72
+ result[key] = (0, exports.objectAlphaSort)(object[key], depthLeft - 1);
65
73
  return result;
66
74
  }, {}));
67
75
  }
68
76
  else if (Array.isArray(object)) {
69
- return object.map((obj) => objectAlphaSort(obj, depthLeft - 1));
77
+ return object.map((obj) => (0, exports.objectAlphaSort)(obj, depthLeft - 1));
70
78
  }
71
79
  else {
72
80
  return object;
73
81
  }
74
82
  };
83
+ exports.objectAlphaSort = objectAlphaSort;
75
84
  /**
76
85
  * Convert a random object type to a record<string,string>
77
86
  * @param entries Could be URLSearchParams
78
87
  * @returns
79
88
  */
80
89
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
- export function paramsToObject(entries) {
90
+ function paramsToObject(entries) {
82
91
  const result = {};
83
92
  for (const [key, value] of entries) {
84
93
  result[key] = value;
85
94
  }
86
95
  return result;
87
96
  }
97
+ exports.paramsToObject = paramsToObject;
88
98
  /**
89
99
  * stringify an object of key values. Could be used to stringify a querystring url
90
100
  * @param obj
@@ -92,7 +102,7 @@ export function paramsToObject(entries) {
92
102
  * @param joinKeys
93
103
  * @returns
94
104
  */
95
- export function objectToString(obj, joinKeyValue, joinKeys) {
105
+ function objectToString(obj, joinKeyValue, joinKeys) {
96
106
  let ret = '';
97
107
  if (!obj || Object.keys(obj).length === 0) {
98
108
  return ret;
@@ -100,47 +110,52 @@ export function objectToString(obj, joinKeyValue, joinKeys) {
100
110
  Object.entries(obj).forEach(([key, value]) => {
101
111
  ret += `${joinKeys}${key}${joinKeyValue}${value}`;
102
112
  });
103
- ret = trim(ret, joinKeyValue);
113
+ ret = (0, _1.trim)(ret, joinKeyValue);
104
114
  return ret;
105
115
  }
116
+ exports.objectToString = objectToString;
106
117
  /**
107
118
  * run func over values in object. can be used to cast value type string[]|string to string
108
119
  * @param orig
109
120
  * @param castF
110
121
  * @returns
111
122
  */
112
- export const castObject = (orig, castF) => {
123
+ const castObject = (orig, castF) => {
113
124
  const ret = {};
114
125
  Object.entries(orig).forEach(([k, v]) => {
115
126
  ret[k] = castF(v);
116
127
  });
117
128
  return ret;
118
129
  };
130
+ exports.castObject = castObject;
119
131
  /** remove key values from an object where the value is null or undefined or other specific passed in values */
120
- export const removeUndefValuesFromObject = (orig,
132
+ const removeUndefValuesFromObject = (orig,
121
133
  /** other than null or undefined */
122
134
  ...additionalRemoves) => {
123
135
  const ret = {};
124
136
  Object.entries(orig).forEach(([k, v]) => {
125
- if (v !== null && v !== undefined && !additionalRemoves?.includes(v)) {
137
+ if (v !== null && v !== undefined && !(additionalRemoves === null || additionalRemoves === void 0 ? void 0 : additionalRemoves.includes(v))) {
126
138
  ret[k] = v;
127
139
  }
128
140
  });
129
141
  return ret;
130
142
  };
143
+ exports.removeUndefValuesFromObject = removeUndefValuesFromObject;
131
144
  /**
132
145
  * cast Record<string,string[]|string> to Record<string,string>. can be used for querystring params
133
146
  * @param orig
134
147
  * @returns
135
148
  */
136
- export const castStringlyObject = (orig) => {
137
- const noundef = removeUndefValuesFromObject(orig);
138
- return castObject(noundef, (s) => {
149
+ const castStringlyObject = (orig) => {
150
+ const noundef = (0, exports.removeUndefValuesFromObject)(orig);
151
+ return (0, exports.castObject)(noundef, (s) => {
139
152
  if (Array.isArray(s)) {
140
153
  return s.join(',');
141
154
  }
142
155
  return s;
143
156
  });
144
157
  };
158
+ exports.castStringlyObject = castStringlyObject;
145
159
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
- export const isObject = (o) => o && typeof o === 'object' && !Array.isArray(o);
160
+ const isObject = (o) => o && typeof o === 'object' && !Array.isArray(o);
161
+ exports.isObject = isObject;
@@ -1,21 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shuffle = exports.randomDecimal = exports.random = void 0;
1
4
  /** random number up to max. seed defaults to now.getTime() */
2
- export function random(max, seed) {
5
+ function random(max, seed) {
3
6
  seed = seed || new Date().getTime();
4
7
  const ret = (seed * 9301 + 49297) % 233280;
5
8
  const rnd = ret / 233280;
6
9
  return Math.ceil(rnd * max);
7
10
  }
11
+ exports.random = random;
8
12
  /** between 0 and 1. seed defaults to now.getTime() */
9
- export const randomDecimal = function (seed) {
13
+ const randomDecimal = function (seed) {
10
14
  seed = seed || new Date().getTime();
11
15
  const x = Math.sin((seed += 1)) * 10000;
12
16
  return x - Math.floor(x);
13
17
  };
14
- export function shuffle(array, seed) {
18
+ exports.randomDecimal = randomDecimal;
19
+ function shuffle(array, seed) {
15
20
  let currentIndex = array.length;
16
21
  let temporaryValue;
17
22
  let randomIndex;
18
- const r = randomDecimal(seed);
23
+ const r = (0, exports.randomDecimal)(seed);
19
24
  // While there remain elements to shuffle...
20
25
  while (currentIndex !== 0) {
21
26
  // Pick a remaining element...
@@ -28,3 +33,4 @@ export function shuffle(array, seed) {
28
33
  }
29
34
  return array;
30
35
  }
36
+ exports.shuffle = shuffle;
@@ -1,6 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.secondsInNearest = void 0;
1
4
  const toFixed = (num, fixed) => {
5
+ var _a, _b;
2
6
  const re = new RegExp(`^-?\\d+(?:.\\d{0,${fixed || -1}})?`);
3
- const x = num?.toString()?.match(re)?.[0];
7
+ const x = (_b = (_a = num === null || num === void 0 ? void 0 : num.toString()) === null || _a === void 0 ? void 0 : _a.match(re)) === null || _b === void 0 ? void 0 : _b[0];
4
8
  if (!x) {
5
9
  return num;
6
10
  }
@@ -10,7 +14,7 @@ const toFixed = (num, fixed) => {
10
14
  * @param seconds total seconds > 0
11
15
  * @param precision optional precision of number
12
16
  */
13
- export const secondsInNearest = ({ seconds, precision = 2, }) => {
17
+ const secondsInNearest = ({ seconds, precision = 2, }) => {
14
18
  if (seconds <= 0) {
15
19
  return 'Now';
16
20
  }
@@ -32,3 +36,4 @@ export const secondsInNearest = ({ seconds, precision = 2, }) => {
32
36
  const v = toFixed(days, precision);
33
37
  return `${v} ${v === 1 ? 'day' : 'days'}`;
34
38
  };
39
+ exports.secondsInNearest = secondsInNearest;
@@ -1,3 +1,7 @@
1
- export const sleep = (ms) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = void 0;
4
+ const sleep = (ms) => {
2
5
  return new Promise((resolve) => setTimeout(resolve, ms));
3
6
  };
7
+ exports.sleep = sleep;
@@ -1,2 +1,7 @@
1
- export const toBase64 = (str) => Buffer.from(str).toString('base64');
2
- export const fromBase64 = (str) => Buffer.from(decodeURIComponent(str), 'base64').toString();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromBase64 = exports.toBase64 = void 0;
4
+ const toBase64 = (str) => Buffer.from(str).toString('base64');
5
+ exports.toBase64 = toBase64;
6
+ const fromBase64 = (str) => Buffer.from(decodeURIComponent(str), 'base64').toString();
7
+ exports.fromBase64 = fromBase64;
@@ -1 +1,5 @@
1
- export const chunkString = (str, length) => str.match(new RegExp(`.{1,${length}}`, 'g'));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chunkString = void 0;
4
+ const chunkString = (str, length) => str.match(new RegExp(`.{1,${length}}`, 'g'));
5
+ exports.chunkString = chunkString;
@@ -1,10 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.containsInsensitive = exports.containsInsensitiveIndex = void 0;
1
4
  /**
2
5
  * returns >-1 if found
3
6
  * @param str
4
7
  * @param args
5
8
  * @returns
6
9
  */
7
- export function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
10
+ function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
8
11
  if (!str || !args) {
9
12
  return -1;
10
13
  }
@@ -19,10 +22,12 @@ export function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
19
22
  }
20
23
  return !fromLast ? finds[0] : finds[finds.length - 1];
21
24
  }
25
+ exports.containsInsensitiveIndex = containsInsensitiveIndex;
22
26
  /**
23
27
  * returns true if text is found
24
28
  * @param str
25
29
  * @param args
26
30
  * @returns
27
31
  */
28
- export const containsInsensitive = (str, ...args) => containsInsensitiveIndex({ str }, ...args) !== -1;
32
+ const containsInsensitive = (str, ...args) => containsInsensitiveIndex({ str }, ...args) !== -1;
33
+ exports.containsInsensitive = containsInsensitive;
@@ -1,21 +1,24 @@
1
- import { containsInsensitiveIndex } from './contains';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getExtendedStringSegment = void 0;
4
+ const contains_1 = require("./contains");
2
5
  /**
3
6
  * will return a piece of text around a found term, and the index it was found
4
7
  * @param hay
5
8
  * @param needle
6
9
  * @returns
7
10
  */
8
- export const getExtendedStringSegment = (hay, needle, blocksOnEitherSide = 5,
11
+ const getExtendedStringSegment = (hay, needle, blocksOnEitherSide = 5,
9
12
  /** can override this if space bounded words are required */
10
13
  gapChars = ['\n', '\r\n']) => {
11
- const fi = containsInsensitiveIndex({ str: hay }, needle);
14
+ const fi = (0, contains_1.containsInsensitiveIndex)({ str: hay }, needle);
12
15
  if (fi === -1) {
13
16
  return undefined;
14
17
  }
15
18
  let start = fi;
16
19
  //we want to extend the partial content back to -(gap) gapChars
17
20
  for (let a = 0; a <= blocksOnEitherSide; a += 1) {
18
- const newstartI = containsInsensitiveIndex({ str: hay.substring(0, start), fromLast: true }, ...gapChars);
21
+ const newstartI = (0, contains_1.containsInsensitiveIndex)({ str: hay.substring(0, start), fromLast: true }, ...gapChars);
19
22
  if (newstartI !== -1) {
20
23
  start = newstartI;
21
24
  }
@@ -23,7 +26,7 @@ gapChars = ['\n', '\r\n']) => {
23
26
  //and forward
24
27
  let end = fi + needle.length;
25
28
  for (let a = 0; a <= blocksOnEitherSide; a += 1) {
26
- const newEndI = containsInsensitiveIndex({ str: hay.substring(end) }, ...gapChars);
29
+ const newEndI = (0, contains_1.containsInsensitiveIndex)({ str: hay.substring(end) }, ...gapChars);
27
30
  if (newEndI !== -1) {
28
31
  end += newEndI + 1;
29
32
  }
@@ -38,3 +41,4 @@ gapChars = ['\n', '\r\n']) => {
38
41
  innerEnd: innerStart + needle.length,
39
42
  };
40
43
  };
44
+ exports.getExtendedStringSegment = getExtendedStringSegment;
@@ -1,10 +1,26 @@
1
- export * from './base64';
2
- export * from './chunk';
3
- export * from './contains';
4
- export * from './getExtendedStringSegment';
5
- export * from './json';
6
- export * from './object';
7
- export * from './surround';
8
- export * from './trim';
9
- export * from './truncate';
10
- export * from './url';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./base64"), exports);
18
+ __exportStar(require("./chunk"), exports);
19
+ __exportStar(require("./contains"), exports);
20
+ __exportStar(require("./getExtendedStringSegment"), exports);
21
+ __exportStar(require("./json"), exports);
22
+ __exportStar(require("./object"), exports);
23
+ __exportStar(require("./surround"), exports);
24
+ __exportStar(require("./trim"), exports);
25
+ __exportStar(require("./truncate"), exports);
26
+ __exportStar(require("./url"), exports);
@@ -1,10 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.safeStringify = void 0;
1
4
  /**
2
5
  * safely handles circular references
3
6
  * @param obj
4
7
  * @param indent
5
8
  * @returns
6
9
  */
7
- export const safeStringify = (obj, indent = 2) => {
10
+ const safeStringify = (obj, indent = 2) => {
8
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
12
  let cache = [];
10
13
  const retVal = JSON.stringify(obj, (_key, value) => typeof value === 'object' && value !== null
@@ -15,3 +18,4 @@ export const safeStringify = (obj, indent = 2) => {
15
18
  cache = null;
16
19
  return retVal;
17
20
  };
21
+ exports.safeStringify = safeStringify;
@@ -1,10 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringToObject = void 0;
1
4
  /**
2
5
  * object to string - can be used for querystring a=b&c=d etc
3
6
  * @param raw eg a=b&c=d
4
7
  * @param splitKeyValue eg =
5
8
  * @param splitKeys eg &
6
9
  */
7
- export function stringToObject(raw, splitKeyValue, splitKeys) {
10
+ function stringToObject(raw, splitKeyValue, splitKeys) {
8
11
  const ret = {};
9
12
  if (!stringToObject) {
10
13
  return ret;
@@ -17,3 +20,4 @@ export function stringToObject(raw, splitKeyValue, splitKeys) {
17
20
  });
18
21
  return ret;
19
22
  }
23
+ exports.stringToObject = stringToObject;
@@ -1,6 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.surround = void 0;
1
4
  /** surround a substring of text with a value */
2
- export const surround = ({ text, start, end, surround, }) => [
5
+ const surround = ({ text, start, end, surround, }) => [
3
6
  surround(text.slice(0, start), false),
4
7
  surround(text.slice(start, end), true),
5
8
  surround(text.slice(end), false),
6
9
  ];
10
+ exports.surround = surround;
@@ -1,4 +1,7 @@
1
- export function trimSide(str, fromStart = true, ...params) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trim = exports.trimSide = void 0;
4
+ function trimSide(str, fromStart = true, ...params) {
2
5
  const pstr = params.join('');
3
6
  if (!str) {
4
7
  return str;
@@ -9,7 +12,8 @@ export function trimSide(str, fromStart = true, ...params) {
9
12
  }
10
13
  return ret;
11
14
  }
12
- export function trim(str, ...params) {
15
+ exports.trimSide = trimSide;
16
+ function trim(str, ...params) {
13
17
  if (!str) {
14
18
  return '';
15
19
  }
@@ -17,3 +21,4 @@ export function trim(str, ...params) {
17
21
  str = trimSide(str, false, ...params);
18
22
  return str;
19
23
  }
24
+ exports.trim = trim;
@@ -1,6 +1,10 @@
1
- export function truncate(str, n, ellip) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.truncate = void 0;
4
+ function truncate(str, n, ellip) {
2
5
  if (!str) {
3
6
  return undefined;
4
7
  }
5
8
  return str.length > n ? str.substr(0, n - 1) + ellip : str;
6
9
  }
10
+ exports.truncate = truncate;
@@ -1,8 +1,11 @@
1
- import { trim } from './trim';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidUrl = exports.niceUrl = void 0;
4
+ const trim_1 = require("./trim");
2
5
  /**
3
6
  * removes protocol, and trailing slashes
4
7
  */
5
- export const niceUrl = (siteUrl) => {
8
+ const niceUrl = (siteUrl) => {
6
9
  if (!siteUrl) {
7
10
  return undefined;
8
11
  }
@@ -11,10 +14,11 @@ export const niceUrl = (siteUrl) => {
11
14
  .replace('sc-domain:', '')
12
15
  .replace('https://', '')
13
16
  .replace('http://', '');
14
- niceSiteUrl = trim(niceSiteUrl, '/');
17
+ niceSiteUrl = (0, trim_1.trim)(niceSiteUrl, '/');
15
18
  return { siteUrl, niceSiteUrl };
16
19
  };
17
- export function isValidUrl(raw) {
20
+ exports.niceUrl = niceUrl;
21
+ function isValidUrl(raw) {
18
22
  let url;
19
23
  try {
20
24
  url = new URL(raw);
@@ -24,3 +28,4 @@ export function isValidUrl(raw) {
24
28
  }
25
29
  return url.protocol === 'http:' || url.protocol === 'https:';
26
30
  }
31
+ exports.isValidUrl = isValidUrl;
@@ -1,2 +1,18 @@
1
- export * from './const';
2
- export * from './helpers';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./const"), exports);
18
+ __exportStar(require("./helpers"), exports);
package/dist/index.js CHANGED
@@ -1,3 +1,19 @@
1
- export * from './api';
2
- export * from './common';
3
- export * from './ui';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api"), exports);
18
+ __exportStar(require("./common"), exports);
19
+ __exportStar(require("./ui"), exports);
@@ -1,9 +1,15 @@
1
- import { css } from '@emotion/react';
2
- import styled from '@emotion/styled';
3
- import React from 'react';
4
- import { removeUndefValuesFromObject } from '../../../common/helpers/object';
5
- import { colours } from '../../styles/colours';
6
- const BGcss = css `
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BorderGradient = void 0;
7
+ const react_1 = require("@emotion/react");
8
+ const styled_1 = __importDefault(require("@emotion/styled"));
9
+ const react_2 = __importDefault(require("react"));
10
+ const object_1 = require("../../../common/helpers/object");
11
+ const colours_1 = require("../../styles/colours");
12
+ const BGcss = (0, react_1.css) `
7
13
  display: flex;
8
14
  border: 0;
9
15
  padding: 3px;
@@ -18,13 +24,13 @@ const BGcss = css `
18
24
  }
19
25
  }
20
26
  `;
21
- const BGLink = styled.div `
27
+ const BGLink = styled_1.default.div `
22
28
  ${BGcss};
23
29
  `;
24
- const BGALink = styled.a `
30
+ const BGALink = styled_1.default.a `
25
31
  ${BGcss};
26
32
  `;
27
- const Padding = styled.div `
33
+ const Padding = styled_1.default.div `
28
34
  justify-content: center;
29
35
  align-items: center;
30
36
  display: flex;
@@ -32,14 +38,14 @@ const Padding = styled.div `
32
38
  border: 0;
33
39
  flex-grow: 1;
34
40
  `;
35
- const FeatureBoxFill = styled(Padding) `
41
+ const FeatureBoxFill = (0, styled_1.default)(Padding) `
36
42
  background-image: linear-gradient(to bottom right, var(--left), var(--right));
37
- color: ${colours.mainLight};
43
+ color: ${colours_1.colours.mainLight};
38
44
  flex-grow: 1;
39
45
  `;
40
- export const BorderGradient = ({ left = colours.orange, right = colours.orangeRed, children, radius = '2rem', fill = false, padding = '2rem', className, onClick, href, target, rel, noGrow = false, disabled = false, canClick = false, }) => {
46
+ const BorderGradient = ({ left = colours_1.colours.orange, right = colours_1.colours.orangeRed, children, radius = '2rem', fill = false, padding = '2rem', className, onClick, href, target, rel, noGrow = false, disabled = false, canClick = false, }) => {
41
47
  const CCND = canClick && !disabled;
42
- const style = removeUndefValuesFromObject({
48
+ const style = (0, object_1.removeUndefValuesFromObject)({
43
49
  flexGrow: noGrow ? 0 : 1,
44
50
  '--left': left,
45
51
  '--right': right,
@@ -57,11 +63,12 @@ export const BorderGradient = ({ left = colours.orange, right = colours.orangeRe
57
63
  style,
58
64
  'data-ccnd': CCND,
59
65
  };
60
- const child = (React.createElement(React.Fragment, null,
61
- !fill && React.createElement(Padding, { style: { padding } }, children),
62
- fill && React.createElement(FeatureBoxFill, { style: { padding } }, children)));
66
+ const child = (react_2.default.createElement(react_2.default.Fragment, null,
67
+ !fill && react_2.default.createElement(Padding, { style: { padding } }, children),
68
+ fill && react_2.default.createElement(FeatureBoxFill, { style: { padding } }, children)));
63
69
  if (href) {
64
- return React.createElement(BGALink, { ...props }, child);
70
+ return react_2.default.createElement(BGALink, Object.assign({}, props), child);
65
71
  }
66
- return React.createElement(BGLink, { ...props }, child);
72
+ return react_2.default.createElement(BGLink, Object.assign({}, props), child);
67
73
  };
74
+ exports.BorderGradient = BorderGradient;