@purpurds/field-helper-text 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE.txt +31 -0
- package/dist/field-helper-text.cjs.js +6 -0
- package/dist/field-helper-text.cjs.js.map +1 -0
- package/dist/field-helper-text.d.ts +10 -0
- package/dist/field-helper-text.d.ts.map +1 -0
- package/dist/field-helper-text.es.js +65 -0
- package/dist/field-helper-text.es.js.map +1 -0
- package/dist/field-helper-text.system.js +6 -0
- package/dist/field-helper-text.system.js.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +60 -0
- package/readme.mdx +58 -0
- package/src/field-helper-text.module.scss +11 -0
- package/src/field-helper-text.stories.tsx +57 -0
- package/src/field-helper-text.test.tsx +31 -0
- package/src/field-helper-text.tsx +37 -0
- package/src/global.d.ts +4 -0
package/dist/LICENSE.txt
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Name: classnames
|
|
2
|
+
Version: 2.5.1
|
|
3
|
+
License: MIT
|
|
4
|
+
Private: false
|
|
5
|
+
Description: A simple utility for conditionally joining classNames together
|
|
6
|
+
Repository: git+https://github.com/JedWatson/classnames.git
|
|
7
|
+
Author: Jed Watson
|
|
8
|
+
License Copyright:
|
|
9
|
+
===
|
|
10
|
+
|
|
11
|
+
The MIT License (MIT)
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2018 Jed Watson
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime");function f(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var a={exports:{}};/*!
|
|
2
|
+
Copyright (c) 2018 Jed Watson.
|
|
3
|
+
Licensed under the MIT License (MIT), see
|
|
4
|
+
http://jedwatson.github.io/classnames
|
|
5
|
+
*/(function(r){(function(){var l={}.hasOwnProperty;function s(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=o(e,i(n)))}return e}function i(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return s.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)l.call(e,n)&&e[n]&&(t=o(t,n));return t}function o(e,t){return t?e?e+" "+t:e+t:e}r.exports?(s.default=s,r.exports=s):window.classNames=s})()})(a);var d=a.exports;const y=f(d),p={"purpur-field-helper-text":"_purpur-field-helper-text_139ly_1","purpur-field-helper-text--disabled":"_purpur-field-helper-text--disabled_139ly_9"},u="purpur-field-helper-text",m=({["data-testid"]:r,children:l,className:s,disabled:i,id:o,...e})=>{const t=y([s,p[u],{[p[`${u}--disabled`]]:i}]);return c.jsx("span",{id:o,className:t,"data-testid":r,...e,children:l})};exports.FieldHelperText=m;
|
|
6
|
+
//# sourceMappingURL=field-helper-text.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-helper-text.cjs.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js","../src/field-helper-text.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { ReactNode } from \"react\";\nimport c from \"classnames\";\n\nimport styles from \"./field-helper-text.module.scss\";\n\nexport type FieldHelperTextProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n className?: string;\n disabled?: boolean;\n id: string;\n};\n\nconst rootClassName = \"purpur-field-helper-text\";\n\nexport const FieldHelperText = ({\n [\"data-testid\"]: dataTestId,\n children,\n className,\n disabled,\n id,\n ...props\n}: FieldHelperTextProps) => {\n const classes = c([\n className,\n styles[rootClassName],\n {\n [styles[`${rootClassName}--disabled`]]: disabled,\n },\n ]);\n\n return (\n <span id={id} className={classes} data-testid={dataTestId} {...props}>\n {children}\n </span>\n );\n};\n"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","rootClassName","FieldHelperText","dataTestId","children","className","disabled","id","props","c","styles","jsx"],"mappings":";;;;gBAOC,UAAY,CAGZ,IAAIA,EAAS,CAAE,EAAC,eAEhB,SAASC,GAAc,CAGtB,QAFIC,EAAU,GAELC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CAC1C,IAAIC,EAAM,UAAUD,CAAC,EACjBC,IACHF,EAAUG,EAAYH,EAASI,EAAWF,CAAG,CAAC,EAE/C,CAED,OAAOF,CACP,CAED,SAASI,EAAYF,EAAK,CACzB,GAAI,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,SAC7C,OAAOA,EAGR,GAAI,OAAOA,GAAQ,SAClB,MAAO,GAGR,GAAI,MAAM,QAAQA,CAAG,EACpB,OAAOH,EAAW,MAAM,KAAMG,CAAG,EAGlC,GAAIA,EAAI,WAAa,OAAO,UAAU,UAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe,EAClG,OAAOA,EAAI,WAGZ,IAAIF,EAAU,GAEd,QAASK,KAAOH,EACXJ,EAAO,KAAKI,EAAKG,CAAG,GAAKH,EAAIG,CAAG,IACnCL,EAAUG,EAAYH,EAASK,CAAG,GAIpC,OAAOL,CACP,CAED,SAASG,EAAaG,EAAOC,EAAU,CACtC,OAAKA,EAIDD,EACIA,EAAQ,IAAMC,EAGfD,EAAQC,EAPPD,CAQR,CAEoCE,EAAO,SAC3CT,EAAW,QAAUA,EACrBS,EAAA,QAAiBT,GAOjB,OAAO,WAAaA,CAEtB,6LC/DMU,EAAgB,2BAETC,EAAkB,CAAC,CAC9B,CAAC,eAAgBC,EACjB,SAAAC,EACA,UAAAC,EACA,SAAAC,EACA,GAAAC,EACA,GAAGC,CACL,IAA4B,CAC1B,MAAMhB,EAAUiB,EAAE,CAChBJ,EACAK,EAAOT,CAAa,EACpB,CACE,CAACS,EAAO,GAAGT,CAAa,YAAY,CAAC,EAAGK,CAC1C,CAAA,CACD,EAGC,OAAAK,MAAC,QAAK,GAAAJ,EAAQ,UAAWf,EAAS,cAAaW,EAAa,GAAGK,EAC5D,SAAAJ,CACH,CAAA,CAEJ","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export type FieldHelperTextProps = {
|
|
3
|
+
["data-testid"]?: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const FieldHelperText: ({ ["data-testid"]: dataTestId, children, className, disabled, id, ...props }: FieldHelperTextProps) => React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=field-helper-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-helper-text.d.ts","sourceRoot":"","sources":["../src/field-helper-text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKzC,MAAM,MAAM,oBAAoB,GAAG;IACjC,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAIF,eAAO,MAAM,eAAe,iFAOzB,oBAAoB,sBActB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
function c(r) {
|
|
3
|
+
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
4
|
+
}
|
|
5
|
+
var a = { exports: {} };
|
|
6
|
+
/*!
|
|
7
|
+
Copyright (c) 2018 Jed Watson.
|
|
8
|
+
Licensed under the MIT License (MIT), see
|
|
9
|
+
http://jedwatson.github.io/classnames
|
|
10
|
+
*/
|
|
11
|
+
(function(r) {
|
|
12
|
+
(function() {
|
|
13
|
+
var p = {}.hasOwnProperty;
|
|
14
|
+
function s() {
|
|
15
|
+
for (var t = "", e = 0; e < arguments.length; e++) {
|
|
16
|
+
var n = arguments[e];
|
|
17
|
+
n && (t = o(t, l(n)));
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
}
|
|
21
|
+
function l(t) {
|
|
22
|
+
if (typeof t == "string" || typeof t == "number")
|
|
23
|
+
return t;
|
|
24
|
+
if (typeof t != "object")
|
|
25
|
+
return "";
|
|
26
|
+
if (Array.isArray(t))
|
|
27
|
+
return s.apply(null, t);
|
|
28
|
+
if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]"))
|
|
29
|
+
return t.toString();
|
|
30
|
+
var e = "";
|
|
31
|
+
for (var n in t)
|
|
32
|
+
p.call(t, n) && t[n] && (e = o(e, n));
|
|
33
|
+
return e;
|
|
34
|
+
}
|
|
35
|
+
function o(t, e) {
|
|
36
|
+
return e ? t ? t + " " + e : t + e : t;
|
|
37
|
+
}
|
|
38
|
+
r.exports ? (s.default = s, r.exports = s) : window.classNames = s;
|
|
39
|
+
})();
|
|
40
|
+
})(a);
|
|
41
|
+
var d = a.exports;
|
|
42
|
+
const m = /* @__PURE__ */ c(d), i = {
|
|
43
|
+
"purpur-field-helper-text": "_purpur-field-helper-text_139ly_1",
|
|
44
|
+
"purpur-field-helper-text--disabled": "_purpur-field-helper-text--disabled_139ly_9"
|
|
45
|
+
}, u = "purpur-field-helper-text", x = ({
|
|
46
|
+
["data-testid"]: r,
|
|
47
|
+
children: p,
|
|
48
|
+
className: s,
|
|
49
|
+
disabled: l,
|
|
50
|
+
id: o,
|
|
51
|
+
...t
|
|
52
|
+
}) => {
|
|
53
|
+
const e = m([
|
|
54
|
+
s,
|
|
55
|
+
i[u],
|
|
56
|
+
{
|
|
57
|
+
[i[`${u}--disabled`]]: l
|
|
58
|
+
}
|
|
59
|
+
]);
|
|
60
|
+
return /* @__PURE__ */ f("span", { id: o, className: e, "data-testid": r, ...t, children: p });
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
x as FieldHelperText
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=field-helper-text.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-helper-text.es.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js","../src/field-helper-text.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { ReactNode } from \"react\";\nimport c from \"classnames\";\n\nimport styles from \"./field-helper-text.module.scss\";\n\nexport type FieldHelperTextProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n className?: string;\n disabled?: boolean;\n id: string;\n};\n\nconst rootClassName = \"purpur-field-helper-text\";\n\nexport const FieldHelperText = ({\n [\"data-testid\"]: dataTestId,\n children,\n className,\n disabled,\n id,\n ...props\n}: FieldHelperTextProps) => {\n const classes = c([\n className,\n styles[rootClassName],\n {\n [styles[`${rootClassName}--disabled`]]: disabled,\n },\n ]);\n\n return (\n <span id={id} className={classes} data-testid={dataTestId} {...props}>\n {children}\n </span>\n );\n};\n"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","rootClassName","FieldHelperText","dataTestId","children","className","disabled","id","props","c","styles","jsx"],"mappings":";;;;;;;;;;;AAOA,GAAC,WAAY;AAGZ,QAAIA,IAAS,CAAE,EAAC;AAEhB,aAASC,IAAc;AAGtB,eAFIC,IAAU,IAELC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AAC1C,YAAIC,IAAM,UAAUD,CAAC;AACrB,QAAIC,MACHF,IAAUG,EAAYH,GAASI,EAAWF,CAAG,CAAC;AAAA,MAE/C;AAED,aAAOF;AAAA,IACP;AAED,aAASI,EAAYF,GAAK;AACzB,UAAI,OAAOA,KAAQ,YAAY,OAAOA,KAAQ;AAC7C,eAAOA;AAGR,UAAI,OAAOA,KAAQ;AAClB,eAAO;AAGR,UAAI,MAAM,QAAQA,CAAG;AACpB,eAAOH,EAAW,MAAM,MAAMG,CAAG;AAGlC,UAAIA,EAAI,aAAa,OAAO,UAAU,YAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe;AAClG,eAAOA,EAAI;AAGZ,UAAIF,IAAU;AAEd,eAASK,KAAOH;AACf,QAAIJ,EAAO,KAAKI,GAAKG,CAAG,KAAKH,EAAIG,CAAG,MACnCL,IAAUG,EAAYH,GAASK,CAAG;AAIpC,aAAOL;AAAA,IACP;AAED,aAASG,EAAaG,GAAOC,GAAU;AACtC,aAAKA,IAIDD,IACIA,IAAQ,MAAMC,IAGfD,IAAQC,IAPPD;AAAA,IAQR;AAED,IAAqCE,EAAO,WAC3CT,EAAW,UAAUA,GACrBS,EAAA,UAAiBT,KAOjB,OAAO,aAAaA;AAAA,EAEtB;;;;;;GC/DMU,IAAgB,4BAETC,IAAkB,CAAC;AAAA,EAC9B,CAAC,gBAAgBC;AAAA,EACjB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,IAAAC;AAAA,EACA,GAAGC;AACL,MAA4B;AAC1B,QAAMhB,IAAUiB,EAAE;AAAA,IAChBJ;AAAA,IACAK,EAAOT,CAAa;AAAA,IACpB;AAAA,MACE,CAACS,EAAO,GAAGT,CAAa,YAAY,CAAC,GAAGK;AAAA,IAC1C;AAAA,EAAA,CACD;AAGC,SAAA,gBAAAK,EAAC,UAAK,IAAAJ,GAAQ,WAAWf,GAAS,eAAaW,GAAa,GAAGK,GAC5D,UAAAJ,EACH,CAAA;AAEJ;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
System.register(["react"],function(d,x){"use strict";var a;return{setters:[o=>{a=o.default}],execute:function(){function o(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var p={exports:{}};/*!
|
|
2
|
+
Copyright (c) 2018 Jed Watson.
|
|
3
|
+
Licensed under the MIT License (MIT), see
|
|
4
|
+
http://jedwatson.github.io/classnames
|
|
5
|
+
*/(function(r){(function(){var u={}.hasOwnProperty;function s(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=l(e,i(n)))}return e}function i(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return s.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)u.call(e,n)&&e[n]&&(t=l(t,n));return t}function l(e,t){return t?e?e+" "+t:e+t:e}r.exports?(s.default=s,r.exports=s):window.classNames=s})()})(p);var m=p.exports;const y=o(m),c={"purpur-field-helper-text":"_purpur-field-helper-text_139ly_1","purpur-field-helper-text--disabled":"_purpur-field-helper-text--disabled_139ly_9"},f="purpur-field-helper-text",h=d("FieldHelperText",({["data-testid"]:r,children:u,className:s,disabled:i,id:l,...e})=>{const t=y([s,c[f],{[c[`${f}--disabled`]]:i}]);return a.createElement("span",{id:l,className:t,"data-testid":r,...e},u)})}}});
|
|
6
|
+
//# sourceMappingURL=field-helper-text.system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-helper-text.system.js","sources":["../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js","../src/field-helper-text.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { ReactNode } from \"react\";\nimport c from \"classnames\";\n\nimport styles from \"./field-helper-text.module.scss\";\n\nexport type FieldHelperTextProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n className?: string;\n disabled?: boolean;\n id: string;\n};\n\nconst rootClassName = \"purpur-field-helper-text\";\n\nexport const FieldHelperText = ({\n [\"data-testid\"]: dataTestId,\n children,\n className,\n disabled,\n id,\n ...props\n}: FieldHelperTextProps) => {\n const classes = c([\n className,\n styles[rootClassName],\n {\n [styles[`${rootClassName}--disabled`]]: disabled,\n },\n ]);\n\n return (\n <span id={id} className={classes} data-testid={dataTestId} {...props}>\n {children}\n </span>\n );\n};\n"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","rootClassName","FieldHelperText","dataTestId","children","className","disabled","id","props","c","styles","React"],"mappings":";;;;gBAOC,UAAY,CAGZ,IAAIA,EAAS,CAAE,EAAC,eAEhB,SAASC,GAAc,CAGtB,QAFIC,EAAU,GAELC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CAC1C,IAAIC,EAAM,UAAUD,CAAC,EACjBC,IACHF,EAAUG,EAAYH,EAASI,EAAWF,CAAG,CAAC,EAE/C,CAED,OAAOF,CACP,CAED,SAASI,EAAYF,EAAK,CACzB,GAAI,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,SAC7C,OAAOA,EAGR,GAAI,OAAOA,GAAQ,SAClB,MAAO,GAGR,GAAI,MAAM,QAAQA,CAAG,EACpB,OAAOH,EAAW,MAAM,KAAMG,CAAG,EAGlC,GAAIA,EAAI,WAAa,OAAO,UAAU,UAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe,EAClG,OAAOA,EAAI,WAGZ,IAAIF,EAAU,GAEd,QAASK,KAAOH,EACXJ,EAAO,KAAKI,EAAKG,CAAG,GAAKH,EAAIG,CAAG,IACnCL,EAAUG,EAAYH,EAASK,CAAG,GAIpC,OAAOL,CACP,CAED,SAASG,EAAaG,EAAOC,EAAU,CACtC,OAAKA,EAIDD,EACIA,EAAQ,IAAMC,EAGfD,EAAQC,EAPPD,CAQR,CAEoCE,EAAO,SAC3CT,EAAW,QAAUA,EACrBS,EAAA,QAAiBT,GAOjB,OAAO,WAAaA,CAEtB,6LC/DMU,EAAgB,2BAETC,sBAAkB,CAAC,CAC9B,CAAC,eAAgBC,EACjB,SAAAC,EACA,UAAAC,EACA,SAAAC,EACA,GAAAC,EACA,GAAGC,CACL,IAA4B,CAC1B,MAAMhB,EAAUiB,EAAE,CAChBJ,EACAK,EAAOT,CAAa,EACpB,CACE,CAACS,EAAO,GAAGT,CAAa,YAAY,CAAC,EAAGK,CAC1C,CAAA,CACD,EAGC,OAAAK,EAAA,cAAC,QAAK,GAAAJ,EAAQ,UAAWf,EAAS,cAAaW,EAAa,GAAGK,CAAA,EAC5DJ,CACH,CAEJ,CAAA","x_google_ignoreList":[0]}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._purpur-field-helper-text_139ly_1{font-family:var(--purpur-typography-family-default),Helvetica,Arial,"Lucida Grande",sans-serif;font-weight:var(--purpur-typography-weight-normal);font-size:var(--purpur-typography-scale-75);line-height:var(--purpur-typography-line-height-loose);color:var(--purpur-color-text-medium);display:block}._purpur-field-helper-text--disabled_139ly_9{color:var(--purpur-color-text-weak)}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@purpurds/field-helper-text",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"main": "./dist/field-helper-text.cjs.js",
|
|
6
|
+
"types": "./dist/field-helper-text.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/field-helper-text.cjs.js",
|
|
10
|
+
"systemjs": "./dist/field-helper-text.system.js",
|
|
11
|
+
"types": "./dist/field-helper-text.d.ts",
|
|
12
|
+
"default": "./dist/field-helper-text.es.js"
|
|
13
|
+
},
|
|
14
|
+
"./styles": "./dist/styles.css"
|
|
15
|
+
},
|
|
16
|
+
"source": "src/field-helper-text.tsx",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"classnames": "~2.5.0",
|
|
19
|
+
"@purpurds/paragraph": "3.0.0",
|
|
20
|
+
"@purpurds/tokens": "3.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@rushstack/eslint-patch": "~1.7.0",
|
|
24
|
+
"@storybook/blocks": "~7.6.0",
|
|
25
|
+
"@storybook/react": "~7.6.0",
|
|
26
|
+
"@telia/base-rig": "~8.2.0",
|
|
27
|
+
"@telia/react-rig": "~3.2.0",
|
|
28
|
+
"@testing-library/dom": "~9.3.3",
|
|
29
|
+
"@testing-library/jest-dom": "~6.3.0",
|
|
30
|
+
"@testing-library/react": "~14.1.2",
|
|
31
|
+
"@types/node": "18",
|
|
32
|
+
"@types/react-dom": "~18.2.17",
|
|
33
|
+
"@types/react": "~18.2.42",
|
|
34
|
+
"eslint-plugin-testing-library": "~6.2.0",
|
|
35
|
+
"eslint": "~8.56.0",
|
|
36
|
+
"jsdom": "~22.1.0",
|
|
37
|
+
"lint-staged": "~10.5.3",
|
|
38
|
+
"prettier": "~2.8.8",
|
|
39
|
+
"react-dom": "~18.2.0",
|
|
40
|
+
"react": "~18.2.0",
|
|
41
|
+
"typescript": "~5.2.2",
|
|
42
|
+
"vite": "~5.0.6",
|
|
43
|
+
"vitest": "~1.2.0",
|
|
44
|
+
"@purpurds/component-rig": "1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build:dev": "vite",
|
|
48
|
+
"build:watch": "vite build --watch",
|
|
49
|
+
"build": "rm -rf dist && vite build && vite build --mode systemjs",
|
|
50
|
+
"ci:build": "rushx build",
|
|
51
|
+
"coverage": "vitest run --coverage",
|
|
52
|
+
"lint:fix": "eslint . --fix",
|
|
53
|
+
"lint": "lint-staged --no-stash 2>&1",
|
|
54
|
+
"sbdev": "rush sbdev",
|
|
55
|
+
"test:unit": "vitest run --passWithNoTests",
|
|
56
|
+
"test:watch": "vitest --watch",
|
|
57
|
+
"test": "rushx test:unit",
|
|
58
|
+
"typecheck": "tsc -p ./tsconfig.json"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/readme.mdx
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Meta, Stories, ArgTypes, Primary, Subtitle } from "@storybook/blocks";
|
|
2
|
+
|
|
3
|
+
import * as FieldHelperTextStories from "./src/field-helper-text.stories";
|
|
4
|
+
import packageInfo from "./package.json";
|
|
5
|
+
|
|
6
|
+
<Meta name="Docs" title="Components/FieldHelperText" of={FieldHelperTextStories} />
|
|
7
|
+
|
|
8
|
+
# FieldHelperText
|
|
9
|
+
|
|
10
|
+
<Subtitle>Version {packageInfo.version}</Subtitle>
|
|
11
|
+
|
|
12
|
+
This is an internal component used for form fields.
|
|
13
|
+
|
|
14
|
+
### Showcase
|
|
15
|
+
|
|
16
|
+
<Primary />
|
|
17
|
+
|
|
18
|
+
### Properties
|
|
19
|
+
|
|
20
|
+
<ArgTypes />
|
|
21
|
+
|
|
22
|
+
### Installation
|
|
23
|
+
|
|
24
|
+
#### Via NPM
|
|
25
|
+
|
|
26
|
+
Add the dependency to your consumer app like `"@purpurds/field-helper-text": "x.y.z"`
|
|
27
|
+
|
|
28
|
+
#### From outside the monorepo (build-time)
|
|
29
|
+
|
|
30
|
+
To install this package, you need to setup access to the artifactory. [Click here to go to the guide on how to do that](https://github.com/telia-company/jfrog-documentation/blob/main/doc/JFrog/JFrog_Onboarding.md#getting-access-to-artifactory-and-other-jfrog-applications).
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
In MyApp.tsx
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import "@purpurds/tokens/index.css";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
and
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import "@purpurds/field-helper-text/styles.css";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
In MyComponent.tsx
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { FieldHelperText } from "@purpurds/field-helper-text";
|
|
50
|
+
|
|
51
|
+
export const MyComponent = () => {
|
|
52
|
+
return (
|
|
53
|
+
<div>
|
|
54
|
+
<FieldHelperText {...someProps}>Some content</FieldHelperText>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
|
|
3
|
+
import { FieldHelperText } from "./field-helper-text";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof FieldHelperText> = {
|
|
6
|
+
title: "Components/FieldHelperText",
|
|
7
|
+
component: FieldHelperText,
|
|
8
|
+
parameters: {
|
|
9
|
+
design: [
|
|
10
|
+
{
|
|
11
|
+
name: "Checkbox",
|
|
12
|
+
type: "figma",
|
|
13
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1274%3A614&mode=design&t=5WYoIWv1It545kCs-1",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "Date picker",
|
|
17
|
+
type: "figma",
|
|
18
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=33657%3A20978&mode=design&t=5WYoIWv1It545kCs-1",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "Search input",
|
|
22
|
+
type: "figma",
|
|
23
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=25720-16573&mode=design&t=5WYoIWv1It545kCs-0",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "Select",
|
|
27
|
+
type: "figma",
|
|
28
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=2649%3A1994&mode=design&t=I7q1i4D0IFuULtpT-1",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "Textarea",
|
|
32
|
+
type: "figma",
|
|
33
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1565%3A1896&mode=design&t=5WYoIWv1It545kCs-1",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "Text input",
|
|
37
|
+
type: "figma",
|
|
38
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1528%3A1886&mode=design&t=5WYoIWv1It545kCs-1",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
argTypes: {
|
|
43
|
+
disabled: {
|
|
44
|
+
control: { type: "boolean" },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default meta;
|
|
50
|
+
type Story = StoryObj<typeof FieldHelperText>;
|
|
51
|
+
|
|
52
|
+
export const Showcase: Story = {
|
|
53
|
+
args: {
|
|
54
|
+
children: "Helper text",
|
|
55
|
+
id: "FieldHelperText",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as matchers from "@testing-library/jest-dom/matchers";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { FieldHelperText } from "./field-helper-text";
|
|
7
|
+
|
|
8
|
+
expect.extend(matchers);
|
|
9
|
+
|
|
10
|
+
describe("FieldHelperText", () => {
|
|
11
|
+
it("standard", () => {
|
|
12
|
+
render(
|
|
13
|
+
<FieldHelperText id="field-helper-text1" data-testid="field-helper-text1">
|
|
14
|
+
Some helper text
|
|
15
|
+
</FieldHelperText>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(screen.getByTestId("field-helper-text1")).toHaveTextContent("Some helper text");
|
|
19
|
+
});
|
|
20
|
+
it("disabled", () => {
|
|
21
|
+
render(
|
|
22
|
+
<FieldHelperText id="field-helper-text2" data-testid="field-helper-text2" disabled>
|
|
23
|
+
Some helper text
|
|
24
|
+
</FieldHelperText>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(screen.getByTestId("field-helper-text2")).toHaveClass(
|
|
28
|
+
"purpur-field-helper-text--disabled"
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import c from "classnames";
|
|
3
|
+
|
|
4
|
+
import styles from "./field-helper-text.module.scss";
|
|
5
|
+
|
|
6
|
+
export type FieldHelperTextProps = {
|
|
7
|
+
["data-testid"]?: string;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const rootClassName = "purpur-field-helper-text";
|
|
15
|
+
|
|
16
|
+
export const FieldHelperText = ({
|
|
17
|
+
["data-testid"]: dataTestId,
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
disabled,
|
|
21
|
+
id,
|
|
22
|
+
...props
|
|
23
|
+
}: FieldHelperTextProps) => {
|
|
24
|
+
const classes = c([
|
|
25
|
+
className,
|
|
26
|
+
styles[rootClassName],
|
|
27
|
+
{
|
|
28
|
+
[styles[`${rootClassName}--disabled`]]: disabled,
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<span id={id} className={classes} data-testid={dataTestId} {...props}>
|
|
34
|
+
{children}
|
|
35
|
+
</span>
|
|
36
|
+
);
|
|
37
|
+
};
|
package/src/global.d.ts
ADDED