@mikezimm/fps-library-v2 1.1.101 → 1.1.102

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 (42) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/components/atoms/TextInput/FPSTextInput.d.ts +25 -0
  3. package/lib/components/atoms/TextInput/FPSTextInput.d.ts.map +1 -0
  4. package/lib/components/atoms/TextInput/FPSTextInput.js +105 -0
  5. package/lib/components/atoms/TextInput/FPSTextInput.js.map +1 -0
  6. package/lib/components/atoms/TextInput/countLineFeeds.d.ts +3 -0
  7. package/lib/components/atoms/TextInput/countLineFeeds.d.ts.map +1 -0
  8. package/lib/components/atoms/TextInput/countLineFeeds.js +6 -0
  9. package/lib/components/atoms/TextInput/countLineFeeds.js.map +1 -0
  10. package/lib/components/atoms/TextInput/formatJSONString.d.ts +2 -0
  11. package/lib/components/atoms/TextInput/formatJSONString.d.ts.map +1 -0
  12. package/lib/components/atoms/TextInput/formatJSONString.js +13 -0
  13. package/lib/components/atoms/TextInput/formatJSONString.js.map +1 -0
  14. package/lib/components/atoms/TextInput/formatStringLike.d.ts +3 -0
  15. package/lib/components/atoms/TextInput/formatStringLike.d.ts.map +1 -0
  16. package/lib/components/atoms/TextInput/formatStringLike.js +14 -0
  17. package/lib/components/atoms/TextInput/formatStringLike.js.map +1 -0
  18. package/lib/components/atoms/TextInput/formatXml.d.ts +2 -0
  19. package/lib/components/atoms/TextInput/formatXml.d.ts.map +1 -0
  20. package/lib/components/atoms/TextInput/formatXml.js +23 -0
  21. package/lib/components/atoms/TextInput/formatXml.js.map +1 -0
  22. package/lib/components/atoms/TextInput/isHTML.d.ts +2 -0
  23. package/lib/components/atoms/TextInput/isHTML.d.ts.map +1 -0
  24. package/lib/components/atoms/TextInput/isHTML.js +6 -0
  25. package/lib/components/atoms/TextInput/isHTML.js.map +1 -0
  26. package/lib/components/atoms/TextInput/isValidJSON2.d.ts +7 -0
  27. package/lib/components/atoms/TextInput/isValidJSON2.d.ts.map +1 -0
  28. package/lib/components/atoms/TextInput/isValidJSON2.js +26 -0
  29. package/lib/components/atoms/TextInput/isValidJSON2.js.map +1 -0
  30. package/lib/components/atoms/TextInput/isXML.d.ts +2 -0
  31. package/lib/components/atoms/TextInput/isXML.d.ts.map +1 -0
  32. package/lib/components/atoms/TextInput/isXML.js +6 -0
  33. package/lib/components/atoms/TextInput/isXML.js.map +1 -0
  34. package/lib/components/atoms/TextInput/tryToParse.d.ts +8 -0
  35. package/lib/components/atoms/TextInput/tryToParse.d.ts.map +1 -0
  36. package/lib/components/atoms/TextInput/tryToParse.js +21 -0
  37. package/lib/components/atoms/TextInput/tryToParse.js.map +1 -0
  38. package/lib/logic/Time/getDateFromNow.d.ts +10 -0
  39. package/lib/logic/Time/getDateFromNow.d.ts.map +1 -0
  40. package/lib/logic/Time/getDateFromNow.js +15 -0
  41. package/lib/logic/Time/getDateFromNow.js.map +1 -0
  42. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -27,11 +27,16 @@ npm run clean
27
27
  npm run build
28
28
  npm version major/minor/patch
29
29
  npm publish --access=public
30
- npm install @mikezimm/fps-library-v2@1.1.101
30
+ npm install @mikezimm/fps-library-v2@1.1.102
31
31
 
32
32
  # Changelog
33
33
  NOTE: TURN BACK ON STRICT NULL CHECKS - turned off for PropPaneCols
34
34
 
35
+ ## 1.1.102 - 2023-Nov 30: getDateFromNow, FPSTextInput
36
+ - import FPSTextInput from cucumber, and break into smaller files
37
+ - create getDateFromNow, NeverDate, DateIn1Weeks, DateIn2Weeks, DateIn4Weeks
38
+ DateIn1Year, DateIn2Year, DateIn3Year, DateIn5Year
39
+
35
40
  ## 1.1.101 - 2023-Nov 30: BannerSettings
36
41
  - "@mikezimm/fps-styles": "^1.0.54" for bannerSettings.css
37
42
  - tweak getCertElement
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Credit where credit is due...
3
+ * I created this component with the VERY helpful Bing Chat and some iterations.
4
+ * Great Help and shout out to Bing Chat!
5
+ */
6
+ import * as React from 'react';
7
+ export type ITextBackground = 'transparent' | 'yellow' | 'red';
8
+ export type ITextValidationType = 'json' | 'html' | 'xml' | 'spo' | 'spo-page' | 'number' | 'text';
9
+ export interface IFPSTextInput {
10
+ title?: string;
11
+ titleStyles?: React.CSSProperties;
12
+ placeholder?: string;
13
+ onTextChange?: (text: string) => void;
14
+ defaultValue?: string;
15
+ reactCSS?: React.CSSProperties;
16
+ className?: string;
17
+ description?: string;
18
+ validationType?: ITextValidationType;
19
+ required?: boolean;
20
+ multiLine?: boolean;
21
+ maxLines?: number;
22
+ }
23
+ declare const FPSTextInput: React.FC<IFPSTextInput>;
24
+ export default FPSTextInput;
25
+ //# sourceMappingURL=FPSTextInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FPSTextInput.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/FPSTextInput.tsx"],"names":[],"mappings":"AACA;;;;GAIG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,QAAQ,GAAG,KAAK,CAAC;AAuC/D,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAE;AAEpG,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAYD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA4CzC,CAAA;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Credit where credit is due...
3
+ * I created this component with the VERY helpful Bing Chat and some iterations.
4
+ * Great Help and shout out to Bing Chat!
5
+ */
6
+ import { Icon } from '@fluentui/react';
7
+ import * as React from 'react';
8
+ import { useState, useEffect } from 'react';
9
+ import { isXML } from './isXML';
10
+ import { countLineFeeds } from './countLineFeeds';
11
+ import { formatStringLike } from './formatStringLike';
12
+ function determineBGColor(text, format) {
13
+ let bgColor = 'transparent';
14
+ if (typeof text !== 'string')
15
+ return 'red';
16
+ if (text === null || text === undefined)
17
+ bgColor = 'transparent';
18
+ if (format === 'text') {
19
+ if (!text.trim())
20
+ bgColor = 'yellow';
21
+ }
22
+ else if (format === 'number') {
23
+ const regex = /^[0-9]+$/;
24
+ if (regex.test(text) !== true)
25
+ bgColor = 'yellow';
26
+ }
27
+ else if (format === 'json') {
28
+ if (isValidJSON(text) === false) {
29
+ bgColor = 'yellow';
30
+ }
31
+ }
32
+ else if (format === 'html' || format === 'xml') {
33
+ if (isXML(text) === false) {
34
+ bgColor = 'yellow';
35
+ }
36
+ }
37
+ else if (format === 'spo' || format === 'spo-page') {
38
+ const textLC = text.toLocaleLowerCase();
39
+ if (textLC.indexOf('/sites/') !== 0 && textLC.indexOf(window.location.origin) !== 0)
40
+ bgColor = 'yellow';
41
+ if (format === 'spo-page' && bgColor === 'transparent' && textLC.indexOf('.aspx') < 0)
42
+ bgColor = 'yellow';
43
+ }
44
+ return bgColor;
45
+ }
46
+ function getCodeIconName(format) {
47
+ let iconName = '';
48
+ if (format === 'json') {
49
+ iconName = 'Code';
50
+ }
51
+ else if (format === 'xml') {
52
+ iconName = 'Embed';
53
+ }
54
+ else if (format === 'html') {
55
+ iconName = 'FileCode';
56
+ }
57
+ return iconName;
58
+ }
59
+ // Eventually replace this with isValidJSON2?
60
+ function isValidJSON(str) {
61
+ try {
62
+ JSON.parse(str);
63
+ return true;
64
+ }
65
+ catch (e) {
66
+ return false;
67
+ }
68
+ }
69
+ const FPSTextInput = (props) => {
70
+ const { title, description, placeholder, onTextChange, defaultValue, validationType, multiLine, maxLines = 25 } = props;
71
+ const [text, setText] = useState(typeof defaultValue === 'string' ? formatStringLike(defaultValue, validationType) : ''); // Use the defaultValue prop as the initial state
72
+ useEffect(() => {
73
+ // https://ultimatecourses.com/blog/using-async-await-inside-react-use-effect-hook
74
+ setText(defaultValue);
75
+ }, [defaultValue]);
76
+ const handleTextChange = (event) => {
77
+ const newValue = event.target.value;
78
+ setText(newValue);
79
+ if (onTextChange) {
80
+ onTextChange(newValue);
81
+ }
82
+ };
83
+ // const background = validationType === 'json' && isValidJSON( text ) === false ? 'yellow' : 'transparent' ;
84
+ const background = determineBGColor(text, validationType);
85
+ const totalLines = countLineFeeds(text) + 7;
86
+ const height = multiLine === true ? `${totalLines > maxLines ? maxLines : totalLines}em` : '2em';
87
+ const titleStyles = { fontSize: 'larger', fontWeight: '600', ...props.titleStyles };
88
+ const descStyles = { fontSize: 'smaller', };
89
+ const iconName = getCodeIconName(validationType);
90
+ const ReFormatIcon = !iconName ? undefined :
91
+ React.createElement("span", { style: { fontSize: 'larger', fontWeight: 600, padding: '5px', marginLeft: '3em', cursor: 'pointer' }, onClick: () => setText(formatStringLike(text, validationType)), title: `Reformat string as ${validationType}` },
92
+ React.createElement(Icon, { iconName: iconName }));
93
+ return (React.createElement("div", { style: { width: '100%', ...props.reactCSS }, className: props.className },
94
+ title && React.createElement("div", { style: titleStyles },
95
+ title,
96
+ " ",
97
+ ReFormatIcon,
98
+ " "),
99
+ multiLine === true ?
100
+ React.createElement("textarea", { style: { width: '100%', height: height, background: background, transition: 'all 0.4s ease' }, value: text, onChange: handleTextChange, placeholder: placeholder }) :
101
+ React.createElement("input", { type: 'text', style: { width: '100%', height: height, background: background, transition: 'all 0.4s ease', padding: '5px 10px', borderWidth: '1px' }, value: text, onChange: handleTextChange, placeholder: placeholder }),
102
+ description && React.createElement("div", { style: descStyles }, description)));
103
+ };
104
+ export default FPSTextInput;
105
+ //# sourceMappingURL=FPSTextInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FPSTextInput.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/FPSTextInput.tsx"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD,SAAS,gBAAgB,CAAE,IAAY,EAAG,MAA2B;IACnE,IAAI,OAAO,GAAoB,aAAa,CAAC;IAC7C,IAAK,OAAO,IAAI,KAAK,QAAQ;QAAG,OAAO,KAAK,CAAC;IAC7C,IAAK,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS;QAAG,OAAO,GAAG,aAAa,CAAC;IACnE,IAAK,MAAM,KAAK,MAAM,EAAG;QACvB,IAAK,CAAC,IAAI,CAAC,IAAI,EAAE;YAAG,OAAO,GAAG,QAAQ,CAAC;KAExC;SAAM,IAAK,MAAM,KAAK,QAAQ,EAAG;QAChC,MAAM,KAAK,GAAG,UAAU,CAAC;QACzB,IAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI;YAAG,OAAO,GAAG,QAAQ,CAAC;KAErD;SAAM,IAAK,MAAM,KAAK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,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,GAAI;QAIhO,WAAW,IAAI,6BAAK,KAAK,EAAG,UAAU,IAAI,WAAW,CAAO,CAC1D,CACP,CAAC;AACJ,CAAC,CAAA;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const lineFeedRegex: RegExp;
2
+ export declare function countLineFeeds(str: string): number;
3
+ //# sourceMappingURL=countLineFeeds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countLineFeeds.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/countLineFeeds.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,QAAQ,CAAC;AAEnC,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGlD"}
@@ -0,0 +1,6 @@
1
+ export const lineFeedRegex = /\n/g;
2
+ export function countLineFeeds(str) {
3
+ const lineFeedCount = (str.match(lineFeedRegex) || []).length;
4
+ return lineFeedCount;
5
+ }
6
+ //# sourceMappingURL=countLineFeeds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countLineFeeds.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/countLineFeeds.tsx"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAEnC,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IAC9D,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function formatJSONString(jsonString: string): string;
2
+ //# sourceMappingURL=formatJSONString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatJSONString.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/formatJSONString.tsx"],"names":[],"mappings":"AACA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAU3D"}
@@ -0,0 +1,13 @@
1
+ export function formatJSONString(jsonString) {
2
+ try {
3
+ // const jsonObject = JSON.parse( jsonString.replace( lineFeedRegex, '' ) );
4
+ // return [ true, jsonString ];
5
+ const jsonObject = JSON.parse(jsonString);
6
+ return JSON.stringify(jsonObject, null, 2);
7
+ }
8
+ catch (e) {
9
+ console.log('Invalid JSON string:', e);
10
+ return jsonString;
11
+ }
12
+ }
13
+ //# sourceMappingURL=formatJSONString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatJSONString.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/formatJSONString.tsx"],"names":[],"mappings":"AACA,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,IAAI;QACF,4EAA4E;QAC5E,+BAA+B;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;KAC5C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;QACvC,OAAO,UAAU,CAAC;KACnB;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ITextValidationType } from './FPSTextInput';
2
+ export declare function formatStringLike(str: string, format: ITextValidationType): string;
3
+ //# sourceMappingURL=formatStringLike.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatStringLike.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/formatStringLike.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAQjF"}
@@ -0,0 +1,14 @@
1
+ import { formatXml } from './formatXml';
2
+ import { formatJSONString } from './formatJSONString';
3
+ import { lineFeedRegex } from './countLineFeeds';
4
+ export function formatStringLike(str, format) {
5
+ let result = str;
6
+ if (format === 'json') {
7
+ result = formatJSONString(str.replace(lineFeedRegex, ''));
8
+ }
9
+ else if (format === 'html' || format === 'xml') {
10
+ result = formatXml(str.replace(lineFeedRegex, ''));
11
+ }
12
+ return result;
13
+ }
14
+ //# sourceMappingURL=formatStringLike.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatStringLike.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/formatStringLike.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAIjD,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,MAA2B;IACvE,IAAI,MAAM,GAAW,GAAG,CAAC;IACzB,IAAI,MAAM,KAAK,MAAM,EAAE;QACrB,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3D;SAAM,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,EAAE;QAChD,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;KACpD;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function formatXml(sourceXml: string): string;
2
+ //# sourceMappingURL=formatXml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatXml.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/formatXml.tsx"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAqBnD"}
@@ -0,0 +1,23 @@
1
+ // This for function: https://stackoverflow.com/a/47317538
2
+ export function formatXml(sourceXml) {
3
+ const xmlDoc = new DOMParser().parseFromString(sourceXml, 'application/xml');
4
+ const xsltDoc = new DOMParser().parseFromString([
5
+ // describes how we want to modify the XML - indent everything
6
+ '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',
7
+ ' <xsl:strip-space elements="*"/>',
8
+ ' <xsl:template match="para[content-style][not(text())]">',
9
+ ' <xsl:value-of select="normalize-space(.)"/>',
10
+ ' </xsl:template>',
11
+ ' <xsl:template match="node()|@*">',
12
+ ' <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>',
13
+ ' </xsl:template>',
14
+ ' <xsl:output indent="yes"/>',
15
+ '</xsl:stylesheet>',
16
+ ].join('\n'), 'application/xml');
17
+ const xsltProcessor = new XSLTProcessor();
18
+ xsltProcessor.importStylesheet(xsltDoc);
19
+ const resultDoc = xsltProcessor.transformToDocument(xmlDoc);
20
+ const resultXml = new XMLSerializer().serializeToString(resultDoc);
21
+ return resultXml;
22
+ }
23
+ //# sourceMappingURL=formatXml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatXml.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/formatXml.tsx"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,MAAM,UAAU,SAAS,CAAC,SAAiB;IACzC,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC;QAC9C,8DAA8D;QAC9D,mEAAmE;QACnE,mCAAmC;QACnC,2DAA2D;QAC3D,iDAAiD;QACjD,mBAAmB;QACnB,oCAAoC;QACpC,oEAAoE;QACpE,mBAAmB;QACnB,8BAA8B;QAC9B,mBAAmB;KACpB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC,CAAC;IAEjC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;IAC1C,aAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACnE,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function isHTML(str: string): boolean;
2
+ //# sourceMappingURL=isHTML.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isHTML.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/isHTML.tsx"],"names":[],"mappings":"AACA,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAI3C"}
@@ -0,0 +1,6 @@
1
+ export function isHTML(str) {
2
+ const parser = new DOMParser();
3
+ const doc = parser.parseFromString(str, "text/html");
4
+ return doc.body.innerHTML !== "";
5
+ }
6
+ //# sourceMappingURL=isHTML.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isHTML.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/isHTML.tsx"],"names":[],"mappings":"AACA,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACrD,OAAO,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Verify this works in FPSTextInput... there may have been a reason not to use it.
3
+ * @param jsonString
4
+ * @returns
5
+ */
6
+ export declare function isValidJSON2(jsonString: string): boolean;
7
+ //# sourceMappingURL=isValidJSON2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidJSON2.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/isValidJSON2.tsx"],"names":[],"mappings":"AACA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CASxD"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Verify this works in FPSTextInput... there may have been a reason not to use it.
3
+ * @param jsonString
4
+ * @returns
5
+ */
6
+ export function isValidJSON2(jsonString) {
7
+ try {
8
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
+ const jsonObject = JSON.parse(jsonString);
10
+ return true;
11
+ }
12
+ catch (e) {
13
+ console.log('Invalid JSON string:', e);
14
+ return false;
15
+ }
16
+ }
17
+ // TextInput was using this before.
18
+ // function isValidJSON(str: string): boolean {
19
+ // try {
20
+ // JSON.parse(str);
21
+ // return true;
22
+ // } catch (e) {
23
+ // return false;
24
+ // }
25
+ // }
26
+ //# sourceMappingURL=isValidJSON2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidJSON2.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/isValidJSON2.tsx"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,IAAI;QACF,6DAA6D;QAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;QACvC,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AACD,mCAAmC;AACnC,+CAA+C;AAC/C,UAAU;AACV,uBAAuB;AACvB,mBAAmB;AACnB,kBAAkB;AAClB,oBAAoB;AACpB,MAAM;AACN,IAAI"}
@@ -0,0 +1,2 @@
1
+ export declare function isXML(str: string): boolean;
2
+ //# sourceMappingURL=isXML.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isXML.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/isXML.tsx"],"names":[],"mappings":"AACA,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAI1C"}
@@ -0,0 +1,6 @@
1
+ export function isXML(str) {
2
+ const parser = new DOMParser();
3
+ const doc = parser.parseFromString(str, "text/xml");
4
+ return doc.getElementsByTagName("parsererror").length === 0;
5
+ }
6
+ //# sourceMappingURL=isXML.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isXML.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/isXML.tsx"],"names":[],"mappings":"AACA,MAAM,UAAU,KAAK,CAAC,GAAW;IAC/B,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACpD,OAAO,GAAG,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * COPIED TO Items Ninja, RTF Fixer
3
+ * @param str
4
+ * @param defaultObj
5
+ * @returns
6
+ */
7
+ export declare function tryToParse(str: string, defaultObj: any): [any, boolean];
8
+ //# sourceMappingURL=tryToParse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tryToParse.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/tryToParse.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAGH,wBAAgB,UAAU,CAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAK,CAAE,GAAG,EAAE,OAAO,CAAE,CAc5E"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * COPIED TO Items Ninja, RTF Fixer
3
+ * @param str
4
+ * @param defaultObj
5
+ * @returns
6
+ */
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ export function tryToParse(str, defaultObj) {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ let results = [null, false];
11
+ try {
12
+ const obj = JSON.parse(str);
13
+ results = [obj, true];
14
+ }
15
+ catch (e) {
16
+ console.log('tryToParse String not an object', str);
17
+ results = [defaultObj, false];
18
+ }
19
+ return results;
20
+ }
21
+ //# sourceMappingURL=tryToParse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tryToParse.js","sourceRoot":"","sources":["../../../../src/components/atoms/TextInput/tryToParse.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,8DAA8D;AAC9D,MAAM,UAAU,UAAU,CAAE,GAAW,EAAE,UAAe;IAEtD,8DAA8D;IAC9D,IAAI,OAAO,GAAoB,CAAE,IAAI,EAAE,KAAK,CAAE,CAAC;IAC/C,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAE,GAAG,CAAE,CAAC;QAC9B,OAAO,GAAG,CAAE,GAAG,EAAE,IAAI,CAAE,CAAC;KACzB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAE,iCAAiC,EAAE,GAAG,CAAE,CAAC;QACtD,OAAO,GAAG,CAAE,UAAU,EAAE,KAAK,CAAE,CAAC;KACjC;IAED,OAAO,OAAO,CAAC;AAEjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare function getDateFromNow(x: number): Date;
2
+ export declare const NeverDate: Date;
3
+ export declare const DateIn1Weeks: Date;
4
+ export declare const DateIn2Weeks: Date;
5
+ export declare const DateIn4Weeks: Date;
6
+ export declare const DateIn1Year: Date;
7
+ export declare const DateIn2Year: Date;
8
+ export declare const DateIn3Year: Date;
9
+ export declare const DateIn5Year: Date;
10
+ //# sourceMappingURL=getDateFromNow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDateFromNow.d.ts","sourceRoot":"","sources":["../../../src/logic/Time/getDateFromNow.ts"],"names":[],"mappings":"AACA,wBAAgB,cAAc,CAAE,CAAC,EAAE,MAAM,GAAI,IAAI,CAKhD;AAED,eAAO,MAAM,SAAS,MAA+B,CAAC;AAEtD,eAAO,MAAM,YAAY,MAAsB,CAAC;AAChD,eAAO,MAAM,YAAY,MAAuB,CAAC;AACjD,eAAO,MAAM,YAAY,MAAuB,CAAC;AACjD,eAAO,MAAM,WAAW,MAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,MAA4B,CAAC;AACrD,eAAO,MAAM,WAAW,MAA4B,CAAC;AACrD,eAAO,MAAM,WAAW,MAA4B,CAAC"}
@@ -0,0 +1,15 @@
1
+ export function getDateFromNow(x) {
2
+ const today = new Date();
3
+ const futureDate = new Date(today);
4
+ futureDate.setDate(today.getDate() + x);
5
+ return futureDate;
6
+ }
7
+ export const NeverDate = new Date(2079, 12 - 1, 31);
8
+ export const DateIn1Weeks = getDateFromNow(7);
9
+ export const DateIn2Weeks = getDateFromNow(14);
10
+ export const DateIn4Weeks = getDateFromNow(28);
11
+ export const DateIn1Year = getDateFromNow(365);
12
+ export const DateIn2Year = getDateFromNow(365 * 2);
13
+ export const DateIn3Year = getDateFromNow(365 * 3);
14
+ export const DateIn5Year = getDateFromNow(365 * 5);
15
+ //# sourceMappingURL=getDateFromNow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDateFromNow.js","sourceRoot":"","sources":["../../../src/logic/Time/getDateFromNow.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,cAAc,CAAE,CAAS;IACvC,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;IACzB,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAE,IAAI,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAE,CAAC;AAEtD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAE,CAAC,CAAE,CAAC;AAChD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAE,EAAE,CAAE,CAAC;AACjD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAE,EAAE,CAAE,CAAC;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAE,GAAG,CAAE,CAAC;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAE,GAAG,GAAG,CAAC,CAAE,CAAC;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAE,GAAG,GAAG,CAAC,CAAE,CAAC;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAE,GAAG,GAAG,CAAC,CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikezimm/fps-library-v2",
3
- "version": "1.1.101",
3
+ "version": "1.1.102",
4
4
  "description": "Library of reusable typescript/javascript functions, interfaces and constants",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -42,7 +42,7 @@
42
42
  "@fluentui/react": "^7.199.1",
43
43
  "@microsoft/sp-property-pane": "^1.17.3",
44
44
  "@mikezimm/fps-pnp2": "^1.0.55",
45
- "@mikezimm/fps-styles": "^1.0.54",
45
+ "@mikezimm/fps-styles": "^1.0.55",
46
46
  "@pnp/spfx-controls-react": "3.12.0",
47
47
  "@pnp/spfx-property-controls": "3.6.0",
48
48
  "react": "17.0.1",