groovinads-ui 1.0.7 → 1.0.9

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.
Binary file
@@ -0,0 +1,141 @@
1
+ <img src="assets/groovinads-logo.png" alt="Groovinads logo" width="200">
2
+
3
+ ---
4
+
5
+ # Groovinads UI
6
+ Groovinads UI is a React component library that provides ready-to-use UI elements based on the Groovinads UI kit. This library is designed to facilitate the implementation of common UI elements in Groovinads applications.
7
+
8
+ ## Included Components (v 1.0.9)
9
+
10
+ The library includes the following components:
11
+
12
+ - **Buttons**: For user actions.
13
+ - **Checkbox**: For multiple option selections.
14
+ - **Input**: For user data entry.
15
+ - **Radio**: For exclusive selections.
16
+ - **Switch**: For toggle states.
17
+ - **Textarea**: For multiline text input.
18
+
19
+ ## Requirements
20
+ - The component styles must be included from: `https://ui.groovinads.com/styles.min.css`.
21
+ - **npm** (v18 or higher).
22
+ - [Font Awesome](https://fontawesome.com/) icons must be included in the project.
23
+
24
+ ## Installation
25
+
26
+ To use the Groovinads UI library in your project, run the following command:
27
+
28
+ ```bash
29
+ yarn add groovinads-ui
30
+ ```
31
+
32
+ ## Usage
33
+ Here are examples of how to use the components included in the Groovinads UI library:
34
+
35
+ ### Button
36
+ ```jsx
37
+ <Button
38
+ variant={'primary | secondary | tertiary | outline'}
39
+ size={'xs | md | lg'}
40
+ onClick={function}
41
+ icon?={FontAwesome Icon string}
42
+ iconPosition={'start | end'}
43
+ className={string}
44
+ processing={boolean}
45
+ >
46
+ children
47
+ </Button>
48
+ ```
49
+
50
+ | Prop name | Description | Options | Default values | Type |
51
+ |--------------|--------------|--------------|--------------|--------------|
52
+ | ```variant``` | Fila 1, Col 2 | ``` primary ``` ``` secondary ``` ``` terciary ``` ``` outline ```| ``` primary ```| String |
53
+
54
+
55
+
56
+ ### Checkbox
57
+ ```jsx
58
+ <Checkbox
59
+ className={string}
60
+ id={string}
61
+ name={id}
62
+ status={boolean}
63
+ setStatus={function}
64
+ >
65
+ children
66
+ </Checkbox>
67
+ ```
68
+ ### Input
69
+ ```jsx
70
+ <Input
71
+ className={string}
72
+ disabled={boolean}
73
+ helpText={string}
74
+ icon={string}
75
+ label={string}
76
+ name={string}
77
+ onChange={function}
78
+ prefix={string}
79
+ requiredText={string}
80
+ showError={boolean}
81
+ setShowError={function}
82
+ size={'xs | md | xl'}
83
+ suffix={string}
84
+ type={'color | date | datetime-local | email | file | image | month | number | password | tel | text | time | url | week'}
85
+ value={string | number}
86
+ />
87
+ ```
88
+
89
+ ### Radio
90
+ ```jsx
91
+ <Radio
92
+ className={string}
93
+ id={string}
94
+ name={string}
95
+ setStatus={function}
96
+ status={boolean}
97
+ >
98
+ children
99
+ </Radio>
100
+ ```
101
+
102
+ ### Switch
103
+ ```jsx
104
+ <Switch
105
+ className={string}
106
+ icon={boolean}
107
+ id={string}
108
+ name={string}
109
+ size={'xs | md | xl'}
110
+ setStatus={function}
111
+ status={boolean}
112
+ switchPosition={'start | end'}
113
+ >
114
+ children
115
+ </Switch>
116
+ ```
117
+
118
+ ### Textarea
119
+ ```jsx
120
+ <Textarea
121
+ className={string}
122
+ helpText={string}
123
+ label={string}
124
+ name={string}
125
+ onChange={function}
126
+ requiredText={string}
127
+ showError={boolean}
128
+ setShowError={function}
129
+ size={'xs | md | xl'}
130
+ />
131
+ ```
132
+
133
+ ## Customization
134
+ Currently, the components are not customizable.
135
+
136
+ ## Contributions
137
+ This library is for internal use by Groovinads and is not open to external contributions.
138
+
139
+ ---
140
+
141
+ For more information or support, contact the [Groovinads development team](mailto:helpdesk@groovinads.com).
Binary file
package/dist/index.es.js CHANGED
@@ -1 +1,14 @@
1
- import e from"react";const n=({variant:n,size:t,onClick:a,children:l,icon:r,iconPosition:s,className:i,style:c,processing:m})=>{let o=`btn ${i}`;"default"!==n&&(o+=` btn-${n}`),"md"!==t&&(o+=` btn-${t}`),"default"!==c&&(o+=` btn-${c}`),m&&(o+=" btn-processing");const d=m?e.createElement(e.Fragment,null,e.createElement("i",{className:"fa-solid fa-spinner-third fa-spin","aria-hidden":"true"}),l&&e.createElement("span",null,l,"…")):r?"end"===s?e.createElement(e.Fragment,null,l&&e.createElement("span",null,l),e.createElement("i",{className:`fa-solid ${r}`,"aria-hidden":"true"})):e.createElement(e.Fragment,null,e.createElement("i",{className:`fa-solid ${r}`,"aria-hidden":"true"}),l&&e.createElement("span",null,l)):l&&e.createElement("span",null,l);return e.createElement("button",{className:o,onClick:a},d)};n.propTypes={},n.defaultProps={variant:"primary",size:"md",onClick:null,icon:null,iconPosition:"start",className:"",style:"default",processing:!1};export{n as Button};
1
+ import e,{useCallback as t,useEffect as r}from"react";function n(e,t){return e(t={exports:{}},t.exports),t.exports
2
+ /** @license React v16.13.1
3
+ * react-is.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */}var o="function"==typeof Symbol&&Symbol.for,a=o?Symbol.for("react.element"):60103,i=o?Symbol.for("react.portal"):60106,s=o?Symbol.for("react.fragment"):60107,c=o?Symbol.for("react.strict_mode"):60108,l=o?Symbol.for("react.profiler"):60114,u=o?Symbol.for("react.provider"):60109,f=o?Symbol.for("react.context"):60110,p=o?Symbol.for("react.async_mode"):60111,m=o?Symbol.for("react.concurrent_mode"):60111,d=o?Symbol.for("react.forward_ref"):60112,y=o?Symbol.for("react.suspense"):60113,b=o?Symbol.for("react.suspense_list"):60120,g=o?Symbol.for("react.memo"):60115,h=o?Symbol.for("react.lazy"):60116,v=o?Symbol.for("react.block"):60121,E=o?Symbol.for("react.fundamental"):60117,x=o?Symbol.for("react.responder"):60118,S=o?Symbol.for("react.scope"):60119;function w(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case a:switch(e=e.type){case p:case m:case s:case l:case c:case y:return e;default:switch(e=e&&e.$$typeof){case f:case d:case h:case g:case u:return e;default:return t}}case i:return t}}}function O(e){return w(e)===m}var N={AsyncMode:p,ConcurrentMode:m,ContextConsumer:f,ContextProvider:u,Element:a,ForwardRef:d,Fragment:s,Lazy:h,Memo:g,Portal:i,Profiler:l,StrictMode:c,Suspense:y,isAsyncMode:function(e){return O(e)||w(e)===p},isConcurrentMode:O,isContextConsumer:function(e){return w(e)===f},isContextProvider:function(e){return w(e)===u},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===a},isForwardRef:function(e){return w(e)===d},isFragment:function(e){return w(e)===s},isLazy:function(e){return w(e)===h},isMemo:function(e){return w(e)===g},isPortal:function(e){return w(e)===i},isProfiler:function(e){return w(e)===l},isStrictMode:function(e){return w(e)===c},isSuspense:function(e){return w(e)===y},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===s||e===m||e===l||e===c||e===y||e===b||"object"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===g||e.$$typeof===u||e.$$typeof===f||e.$$typeof===d||e.$$typeof===E||e.$$typeof===x||e.$$typeof===S||e.$$typeof===v)},typeOf:w},$=n((function(e,t){"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,a=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,u=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,m=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,y=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,h=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function E(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:var m=e.type;switch(m){case l:case u:case o:case i:case a:case p:return m;default:var b=m&&m.$$typeof;switch(b){case c:case f:case y:case d:case s:return b;default:return t}}case n:return t}}}var x=l,S=u,w=c,O=s,N=r,$=f,C=o,T=y,P=d,k=n,j=i,_=a,I=p,M=!1;function R(e){return E(e)===u}t.AsyncMode=x,t.ConcurrentMode=S,t.ContextConsumer=w,t.ContextProvider=O,t.Element=N,t.ForwardRef=$,t.Fragment=C,t.Lazy=T,t.Memo=P,t.Portal=k,t.Profiler=j,t.StrictMode=_,t.Suspense=I,t.isAsyncMode=function(e){return M||(M=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),R(e)||E(e)===l},t.isConcurrentMode=R,t.isContextConsumer=function(e){return E(e)===c},t.isContextProvider=function(e){return E(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return E(e)===f},t.isFragment=function(e){return E(e)===o},t.isLazy=function(e){return E(e)===y},t.isMemo=function(e){return E(e)===d},t.isPortal=function(e){return E(e)===n},t.isProfiler=function(e){return E(e)===i},t.isStrictMode=function(e){return E(e)===a},t.isSuspense=function(e){return E(e)===p},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===u||e===i||e===a||e===p||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===d||e.$$typeof===s||e.$$typeof===c||e.$$typeof===f||e.$$typeof===g||e.$$typeof===h||e.$$typeof===v||e.$$typeof===b)},t.typeOf=E}()}));$.AsyncMode,$.ConcurrentMode,$.ContextConsumer,$.ContextProvider,$.Element,$.ForwardRef,$.Fragment,$.Lazy,$.Memo,$.Portal,$.Profiler,$.StrictMode,$.Suspense,$.isAsyncMode,$.isConcurrentMode,$.isContextConsumer,$.isContextProvider,$.isElement,$.isForwardRef,$.isFragment,$.isLazy,$.isMemo,$.isPortal,$.isProfiler,$.isStrictMode,$.isSuspense,$.isValidElementType,$.typeOf;var C=n((function(e){"production"===process.env.NODE_ENV?e.exports=N:e.exports=$})),T=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;
10
+ /*
11
+ object-assign
12
+ (c) Sindre Sorhus
13
+ @license MIT
14
+ */var j=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;var n=Object.getOwnPropertyNames(t).map((function(e){return t[e]}));if("0123456789"!==n.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach((function(e){o[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,n,o=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),a=1;a<arguments.length;a++){for(var i in r=Object(arguments[a]))P.call(r,i)&&(o[i]=r[i]);if(T){n=T(r);for(var s=0;s<n.length;s++)k.call(r,n[s])&&(o[n[s]]=r[n[s]])}}return o},_="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",I=Function.call.bind(Object.prototype.hasOwnProperty),M=function(){};if("production"!==process.env.NODE_ENV){var R=_,A={},F=I;M=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function V(e,t,r,n,o){if("production"!==process.env.NODE_ENV)for(var a in e)if(F(e,a)){var i;try{if("function"!=typeof e[a]){var s=Error((n||"React class")+": "+r+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw s.name="Invariant Violation",s}i=e[a](t,a,n,r,null,R)}catch(e){i=e}if(!i||i instanceof Error||M((n||"React class")+": type specification of "+r+" `"+a+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof i+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),i instanceof Error&&!(i.message in A)){A[i.message]=!0;var c=o?o():"";M("Failed "+r+" type: "+i.message+(null!=c?c:""))}}}V.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(A={})};var z=V,q=function(){};function D(){return null}"production"!==process.env.NODE_ENV&&(q=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}});var L=function(e,t){var r="function"==typeof Symbol&&Symbol.iterator,n="@@iterator";var o="<<anonymous>>",a={array:l("array"),bigint:l("bigint"),bool:l("boolean"),func:l("function"),number:l("number"),object:l("object"),string:l("string"),symbol:l("symbol"),any:c(D),arrayOf:function(e){return c((function(t,r,n,o,a){if("function"!=typeof e)return new s("Property `"+a+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var i=t[r];if(!Array.isArray(i))return new s("Invalid "+o+" `"+a+"` of type `"+p(i)+"` supplied to `"+n+"`, expected an array.");for(var c=0;c<i.length;c++){var l=e(i,c,n,o,a+"["+c+"]",_);if(l instanceof Error)return l}return null}))},element:c((function(t,r,n,o,a){var i=t[r];return e(i)?null:new s("Invalid "+o+" `"+a+"` of type `"+p(i)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:c((function(e,t,r,n,o){var a=e[t];return C.isValidElementType(a)?null:new s("Invalid "+n+" `"+o+"` of type `"+p(a)+"` supplied to `"+r+"`, expected a single ReactElement type.")})),instanceOf:function(e){return c((function(t,r,n,a,i){if(!(t[r]instanceof e)){var c=e.name||o;return new s("Invalid "+a+" `"+i+"` of type `"+(((l=t[r]).constructor&&l.constructor.name?l.constructor.name:o)+"` supplied to `")+n+"`, expected instance of `"+c+"`.")}var l;return null}))},node:c((function(e,t,r,n,o){return f(e[t])?null:new s("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.")})),objectOf:function(e){return c((function(t,r,n,o,a){if("function"!=typeof e)return new s("Property `"+a+"` of component `"+n+"` has invalid PropType notation inside objectOf.");var i=t[r],c=p(i);if("object"!==c)return new s("Invalid "+o+" `"+a+"` of type `"+c+"` supplied to `"+n+"`, expected an object.");for(var l in i)if(I(i,l)){var u=e(i,l,n,o,a+"."+l,_);if(u instanceof Error)return u}return null}))},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&q(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),D;return c((function(t,r,n,o,a){for(var c=t[r],l=0;l<e.length;l++)if(i(c,e[l]))return null;var u=JSON.stringify(e,(function(e,t){return"symbol"===m(t)?String(t):t}));return new s("Invalid "+o+" `"+a+"` of value `"+String(c)+"` supplied to `"+n+"`, expected one of "+u+".")}))},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&q("Invalid argument supplied to oneOfType, expected an instance of array."),D;for(var t=0;t<e.length;t++){var r=e[t];if("function"!=typeof r)return q("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+d(r)+" at index "+t+"."),D}return c((function(t,r,n,o,a){for(var i=[],c=0;c<e.length;c++){var l=(0,e[c])(t,r,n,o,a,_);if(null==l)return null;l.data&&I(l.data,"expectedType")&&i.push(l.data.expectedType)}return new s("Invalid "+o+" `"+a+"` supplied to `"+n+"`"+(i.length>0?", expected one of type ["+i.join(", ")+"]":"")+".")}))},shape:function(e){return c((function(t,r,n,o,a){var i=t[r],c=p(i);if("object"!==c)return new s("Invalid "+o+" `"+a+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");for(var l in e){var f=e[l];if("function"!=typeof f)return u(n,o,a,l,m(f));var d=f(i,l,n,o,a+"."+l,_);if(d)return d}return null}))},exact:function(e){return c((function(t,r,n,o,a){var i=t[r],c=p(i);if("object"!==c)return new s("Invalid "+o+" `"+a+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");var l=j({},t[r],e);for(var f in l){var d=e[f];if(I(e,f)&&"function"!=typeof d)return u(n,o,a,f,m(d));if(!d)return new s("Invalid "+o+" `"+a+"` key `"+f+"` supplied to `"+n+"`.\nBad object: "+JSON.stringify(t[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=d(i,f,n,o,a+"."+f,_);if(y)return y}return null}))}};function i(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function c(e){if("production"!==process.env.NODE_ENV)var r={},n=0;function a(a,i,c,l,u,f,p){if(l=l||o,f=f||c,p!==_){if(t){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var d=l+":"+c;!r[d]&&n<3&&(q("You are manually calling a React.PropTypes validation function for the `"+f+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),r[d]=!0,n++)}}return null==i[c]?a?null===i[c]?new s("The "+u+" `"+f+"` is marked as required in `"+l+"`, but its value is `null`."):new s("The "+u+" `"+f+"` is marked as required in `"+l+"`, but its value is `undefined`."):null:e(i,c,l,u,f)}var i=a.bind(null,!1);return i.isRequired=a.bind(null,!0),i}function l(e){return c((function(t,r,n,o,a,i){var c=t[r];return p(c)!==e?new s("Invalid "+o+" `"+a+"` of type `"+m(c)+"` supplied to `"+n+"`, expected `"+e+"`.",{expectedType:e}):null}))}function u(e,t,r,n,o){return new s((e||"React class")+": "+t+" type `"+r+"."+n+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function f(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(f);if(null===t||e(t))return!0;var o=function(e){var t=e&&(r&&e[r]||e[n]);if("function"==typeof t)return t}(t);if(!o)return!1;var a,i=o.call(t);if(o!==t.entries){for(;!(a=i.next()).done;)if(!f(a.value))return!1}else for(;!(a=i.next()).done;){var s=a.value;if(s&&!f(s[1]))return!1}return!0;default:return!1}}function p(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function m(e){if(null==e)return""+e;var t=p(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function d(e){var t=m(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return s.prototype=Error.prototype,a.checkPropTypes=z,a.resetWarningCache=z.resetWarningCache,a.PropTypes=a,a};function W(){}function U(){}U.resetWarningCache=W;var Y=n((function(e){if("production"!==process.env.NODE_ENV){var t=C;e.exports=L(t.isElement,!0)}else e.exports=function(){function e(e,t,r,n,o,a){if(a!==_){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:U,resetWarningCache:W};return r.PropTypes=r,r}()}));const J=({variant:t="primary",size:r="md",onClick:n,children:o,icon:a,iconPosition:i="start",className:s,style:c="default",processing:l=!1})=>{let u=`btn ${s}`;"default"!==t&&(u+=` btn-${t}`),"md"!==r&&(u+=` btn-${r}`),"default"!==c&&(u+=` btn-${c}`),l&&(u+=" btn-processing");const f=l?e.createElement(e.Fragment,null,e.createElement("i",{className:"fa-solid fa-spinner-third fa-spin","aria-hidden":"true"}),o&&e.createElement("span",null,o,"…")):a?"end"===i?e.createElement(e.Fragment,null,o&&e.createElement("span",null,o),e.createElement("i",{className:`fa-solid ${a}`,"aria-hidden":"true"})):e.createElement(e.Fragment,null,e.createElement("i",{className:`fa-solid ${a}`,"aria-hidden":"true"}),o&&e.createElement("span",null,o)):o&&e.createElement("span",null,o);return e.createElement("button",{className:u,onClick:n},f)};J.propTypes={variant:Y.oneOf(["primary","secondary","terciary","outline"]),size:Y.oneOf(["xs","md","lg"]),onClick:Y.func,children:Y.node,icon:Y.string,iconPosition:Y.oneOf(["start","end"]),className:Y.string,style:Y.oneOf(["default","success","danger","warning","link"]),processing:Y.bool};const B=()=>({toCamelCase:t((e=>{let t=e?.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g,(function(e,t){return 0==+e?"":0===t?e?.toLowerCase():e?.toUpperCase()}));return t=t?.replace(/^\d+/,""),t=t?.replace(/[^a-zA-Z0-9_]/g,""),t}),[])}),Z=({children:t,className:r,id:n,name:o,status:a=!1,setStatus:i})=>{const{toCamelCase:s}=B();let c=n;n||"string"!=typeof t||(c=s(t));return e.createElement("div",{className:`form-group form-check ${r}`},e.createElement("label",{className:"checkbox"},e.createElement("input",{type:"checkbox",checked:a,onChange:e=>{i(e.target.checked)},minLength:"1",id:c,name:o}),e.createElement("span",{className:"outer"},e.createElement("span",{className:"inner"})),t))};Z.propTypes={className:Y.string,id:Y.string,name:Y.string,status:Y.bool,setStatus:Y.func};const H=({className:t,disabled:n,helpText:o,icon:a,label:i="Label",name:s,onChange:c,prefix:l,requiredText:u,showError:f,setShowError:p,size:m="md",suffix:d,type:y="text",value:b})=>{const{toCamelCase:g}=B(),h="lg"===m?"form-control-lg":"xs"===m?"form-control-xs":"",v=g(i);return r((()=>{f&&setTimeout((()=>{p(!1)}),3e3)}),[f]),e.createElement("div",{className:`position-relative ${t}`},l||d||a?e.createElement("div",{className:"input-group "+(f?"not-validated":""),"data-error":u},a&&e.createElement("span",{className:"input-group-text"},e.createElement("i",{className:`fa-solid ${a}`})),l&&e.createElement("span",{className:"input-group-text"},l),e.createElement("div",{className:"form-floating"},e.createElement("input",{type:y,className:`form-control ${h}`,value:b,id:v,name:s,placeholder:i,onChange:c,required:!!u}),e.createElement("label",{htmlFor:v},i)),d&&e.createElement("span",{className:"input-group-text"},d)):e.createElement("div",{className:"form-floating "+(f?"not-validated":""),"data-error":u},e.createElement("input",{type:y,className:`form-control ${h}`,value:b,id:v,placeholder:i,onChange:c,required:!!u,name:s,disabled:n}),e.createElement("label",{htmlFor:v},i)),o&&e.createElement("small",{className:"form-text text-muted"},o))};H.propTypes={className:Y.string,disabled:Y.bool,helpText:Y.string,icon:Y.string,label:Y.string,name:Y.string,onChange:Y.func,prefix:Y.string,requiredText:Y.string,size:Y.oneOf(["xs","md","lg"]),showError:Y.bool,setShowError:Y.func,suffix:Y.string,type:Y.oneOf(["color","date","datetime-local","email","file","image","month","number","password","tel","text","time","url","week"]),value:Y.oneOfType([Y.string,Y.number])};const G=({children:t,className:r,id:n,name:o,setStatus:a,status:i=!1})=>{const{toCamelCase:s}=B();let c=n;n||"string"!=typeof t||(c=s(t));return e.createElement("div",{className:`form-group form-check ${r}`},e.createElement("label",{className:"radio"},e.createElement("input",{type:"radio",checked:i,onChange:e=>{a(e.target.checked)},minLength:"1",id:c,name:o}),e.createElement("span",{className:"outer"},e.createElement("span",{className:"inner"})),t))};G.propTypes={className:Y.string,id:Y.string,name:Y.string,setStatus:Y.func,status:Y.bool};const K=({children:t,className:r,icon:n=!1,id:o,name:a,size:i,setStatus:s,status:c=!1,switchPosition:l="start"})=>{const{toCamelCase:u}=B(),f="lg"===i?"form-switch-lg":"xs"===i?"form-switch-xs":"",p=o||u(t);return e.createElement("div",{className:`form-check form-switch ${f} ${r} ${"end"===l?"switch-end":""} ${n?"switch-icon":""}`},e.createElement("input",{className:"form-check-input",type:"checkbox",role:"switch",onChange:e=>{s(e.target.checked)},id:p,name:a,checked:c}),t&&e.createElement("label",{className:"form-check-label",htmlFor:p},t))};K.propTypes={className:Y.string,icon:Y.bool,id:Y.string,name:Y.string,setStatus:Y.func,status:Y.bool,switchPosition:Y.oneOf(["start","end"])};const Q=({className:t,helpText:n,label:o="Label",name:a,onChange:i,requiredText:s,showError:c,setShowError:l,size:u="md"})=>{const{toCamelCase:f}=B(),p="lg"===u?"form-control-lg":"xs"===u?"form-control-xs":"",m=f(o);return r((()=>{c&&setTimeout((()=>{l(!1)}),3e3)}),[c]),e.createElement("div",{className:`position-relative ${t}`},e.createElement("div",{className:"form-floating "+(c?"not-validated":""),"data-error":s},e.createElement("textarea",{className:`form-control ${p}`,onChange:i,placeholder:o,id:m,name:a,required:!!s}),e.createElement("label",{htmlFor:m},o),n&&e.createElement("small",{className:"form-text text-muted"},n)))};Q.propTypes={className:Y.string,helpText:Y.string,label:Y.string,name:Y.string,onChange:Y.func,requiredText:Y.string,showError:Y.bool,size:Y.oneOf(["xs","md","lg"])};export{J as Button,Z as Checkbox,H as Input,G as Radio,K as Switch,Q as Textarea};
package/dist/index.js CHANGED
@@ -1 +1,14 @@
1
- "use strict";var e=require("react");const n=({variant:n,size:t,onClick:a,children:l,icon:r,iconPosition:s,className:i,style:c,processing:o})=>{let m=`btn ${i}`;"default"!==n&&(m+=` btn-${n}`),"md"!==t&&(m+=` btn-${t}`),"default"!==c&&(m+=` btn-${c}`),o&&(m+=" btn-processing");const u=o?e.createElement(e.Fragment,null,e.createElement("i",{className:"fa-solid fa-spinner-third fa-spin","aria-hidden":"true"}),l&&e.createElement("span",null,l,"…")):r?"end"===s?e.createElement(e.Fragment,null,l&&e.createElement("span",null,l),e.createElement("i",{className:`fa-solid ${r}`,"aria-hidden":"true"})):e.createElement(e.Fragment,null,e.createElement("i",{className:`fa-solid ${r}`,"aria-hidden":"true"}),l&&e.createElement("span",null,l)):l&&e.createElement("span",null,l);return e.createElement("button",{className:m,onClick:a},u)};n.propTypes={},n.defaultProps={variant:"primary",size:"md",onClick:null,icon:null,iconPosition:"start",className:"",style:"default",processing:!1},exports.Button=n;
1
+ "use strict";var e=require("react");function t(e,t){return e(t={exports:{}},t.exports),t.exports
2
+ /** @license React v16.13.1
3
+ * react-is.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */}var r="function"==typeof Symbol&&Symbol.for,n=r?Symbol.for("react.element"):60103,o=r?Symbol.for("react.portal"):60106,a=r?Symbol.for("react.fragment"):60107,i=r?Symbol.for("react.strict_mode"):60108,s=r?Symbol.for("react.profiler"):60114,c=r?Symbol.for("react.provider"):60109,l=r?Symbol.for("react.context"):60110,u=r?Symbol.for("react.async_mode"):60111,f=r?Symbol.for("react.concurrent_mode"):60111,p=r?Symbol.for("react.forward_ref"):60112,m=r?Symbol.for("react.suspense"):60113,d=r?Symbol.for("react.suspense_list"):60120,y=r?Symbol.for("react.memo"):60115,b=r?Symbol.for("react.lazy"):60116,g=r?Symbol.for("react.block"):60121,h=r?Symbol.for("react.fundamental"):60117,v=r?Symbol.for("react.responder"):60118,E=r?Symbol.for("react.scope"):60119;function x(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case u:case f:case a:case s:case i:case m:return e;default:switch(e=e&&e.$$typeof){case l:case p:case b:case y:case c:return e;default:return t}}case o:return t}}}function S(e){return x(e)===f}var w={AsyncMode:u,ConcurrentMode:f,ContextConsumer:l,ContextProvider:c,Element:n,ForwardRef:p,Fragment:a,Lazy:b,Memo:y,Portal:o,Profiler:s,StrictMode:i,Suspense:m,isAsyncMode:function(e){return S(e)||x(e)===u},isConcurrentMode:S,isContextConsumer:function(e){return x(e)===l},isContextProvider:function(e){return x(e)===c},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},isForwardRef:function(e){return x(e)===p},isFragment:function(e){return x(e)===a},isLazy:function(e){return x(e)===b},isMemo:function(e){return x(e)===y},isPortal:function(e){return x(e)===o},isProfiler:function(e){return x(e)===s},isStrictMode:function(e){return x(e)===i},isSuspense:function(e){return x(e)===m},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===a||e===f||e===s||e===i||e===m||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===b||e.$$typeof===y||e.$$typeof===c||e.$$typeof===l||e.$$typeof===p||e.$$typeof===h||e.$$typeof===v||e.$$typeof===E||e.$$typeof===g)},typeOf:x},O=t((function(e,t){"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,a=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,u=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,m=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,y=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,h=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function E(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:var m=e.type;switch(m){case l:case u:case o:case i:case a:case p:return m;default:var b=m&&m.$$typeof;switch(b){case c:case f:case y:case d:case s:return b;default:return t}}case n:return t}}}var x=l,S=u,w=c,O=s,N=r,$=f,C=o,T=y,k=d,P=n,j=i,_=a,I=p,M=!1;function R(e){return E(e)===u}t.AsyncMode=x,t.ConcurrentMode=S,t.ContextConsumer=w,t.ContextProvider=O,t.Element=N,t.ForwardRef=$,t.Fragment=C,t.Lazy=T,t.Memo=k,t.Portal=P,t.Profiler=j,t.StrictMode=_,t.Suspense=I,t.isAsyncMode=function(e){return M||(M=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),R(e)||E(e)===l},t.isConcurrentMode=R,t.isContextConsumer=function(e){return E(e)===c},t.isContextProvider=function(e){return E(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return E(e)===f},t.isFragment=function(e){return E(e)===o},t.isLazy=function(e){return E(e)===y},t.isMemo=function(e){return E(e)===d},t.isPortal=function(e){return E(e)===n},t.isProfiler=function(e){return E(e)===i},t.isStrictMode=function(e){return E(e)===a},t.isSuspense=function(e){return E(e)===p},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===u||e===i||e===a||e===p||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===d||e.$$typeof===s||e.$$typeof===c||e.$$typeof===f||e.$$typeof===g||e.$$typeof===h||e.$$typeof===v||e.$$typeof===b)},t.typeOf=E}()}));O.AsyncMode,O.ConcurrentMode,O.ContextConsumer,O.ContextProvider,O.Element,O.ForwardRef,O.Fragment,O.Lazy,O.Memo,O.Portal,O.Profiler,O.StrictMode,O.Suspense,O.isAsyncMode,O.isConcurrentMode,O.isContextConsumer,O.isContextProvider,O.isElement,O.isForwardRef,O.isFragment,O.isLazy,O.isMemo,O.isPortal,O.isProfiler,O.isStrictMode,O.isSuspense,O.isValidElementType,O.typeOf;var N=t((function(e){"production"===process.env.NODE_ENV?e.exports=w:e.exports=O})),$=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;
10
+ /*
11
+ object-assign
12
+ (c) Sindre Sorhus
13
+ @license MIT
14
+ */var k=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;var n=Object.getOwnPropertyNames(t).map((function(e){return t[e]}));if("0123456789"!==n.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach((function(e){o[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,n,o=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),a=1;a<arguments.length;a++){for(var i in r=Object(arguments[a]))C.call(r,i)&&(o[i]=r[i]);if($){n=$(r);for(var s=0;s<n.length;s++)T.call(r,n[s])&&(o[n[s]]=r[n[s]])}}return o},P="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",j=Function.call.bind(Object.prototype.hasOwnProperty),_=function(){};if("production"!==process.env.NODE_ENV){var I=P,M={},R=j;_=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function A(e,t,r,n,o){if("production"!==process.env.NODE_ENV)for(var a in e)if(R(e,a)){var i;try{if("function"!=typeof e[a]){var s=Error((n||"React class")+": "+r+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw s.name="Invariant Violation",s}i=e[a](t,a,n,r,null,I)}catch(e){i=e}if(!i||i instanceof Error||_((n||"React class")+": type specification of "+r+" `"+a+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof i+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),i instanceof Error&&!(i.message in M)){M[i.message]=!0;var c=o?o():"";_("Failed "+r+" type: "+i.message+(null!=c?c:""))}}}A.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(M={})};var F=A,V=function(){};function z(){return null}"production"!==process.env.NODE_ENV&&(V=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}});var q=function(e,t){var r="function"==typeof Symbol&&Symbol.iterator,n="@@iterator";var o="<<anonymous>>",a={array:l("array"),bigint:l("bigint"),bool:l("boolean"),func:l("function"),number:l("number"),object:l("object"),string:l("string"),symbol:l("symbol"),any:c(z),arrayOf:function(e){return c((function(t,r,n,o,a){if("function"!=typeof e)return new s("Property `"+a+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var i=t[r];if(!Array.isArray(i))return new s("Invalid "+o+" `"+a+"` of type `"+p(i)+"` supplied to `"+n+"`, expected an array.");for(var c=0;c<i.length;c++){var l=e(i,c,n,o,a+"["+c+"]",P);if(l instanceof Error)return l}return null}))},element:c((function(t,r,n,o,a){var i=t[r];return e(i)?null:new s("Invalid "+o+" `"+a+"` of type `"+p(i)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:c((function(e,t,r,n,o){var a=e[t];return N.isValidElementType(a)?null:new s("Invalid "+n+" `"+o+"` of type `"+p(a)+"` supplied to `"+r+"`, expected a single ReactElement type.")})),instanceOf:function(e){return c((function(t,r,n,a,i){if(!(t[r]instanceof e)){var c=e.name||o;return new s("Invalid "+a+" `"+i+"` of type `"+(((l=t[r]).constructor&&l.constructor.name?l.constructor.name:o)+"` supplied to `")+n+"`, expected instance of `"+c+"`.")}var l;return null}))},node:c((function(e,t,r,n,o){return f(e[t])?null:new s("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.")})),objectOf:function(e){return c((function(t,r,n,o,a){if("function"!=typeof e)return new s("Property `"+a+"` of component `"+n+"` has invalid PropType notation inside objectOf.");var i=t[r],c=p(i);if("object"!==c)return new s("Invalid "+o+" `"+a+"` of type `"+c+"` supplied to `"+n+"`, expected an object.");for(var l in i)if(j(i,l)){var u=e(i,l,n,o,a+"."+l,P);if(u instanceof Error)return u}return null}))},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&V(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),z;return c((function(t,r,n,o,a){for(var c=t[r],l=0;l<e.length;l++)if(i(c,e[l]))return null;var u=JSON.stringify(e,(function(e,t){return"symbol"===m(t)?String(t):t}));return new s("Invalid "+o+" `"+a+"` of value `"+String(c)+"` supplied to `"+n+"`, expected one of "+u+".")}))},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&V("Invalid argument supplied to oneOfType, expected an instance of array."),z;for(var t=0;t<e.length;t++){var r=e[t];if("function"!=typeof r)return V("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+d(r)+" at index "+t+"."),z}return c((function(t,r,n,o,a){for(var i=[],c=0;c<e.length;c++){var l=(0,e[c])(t,r,n,o,a,P);if(null==l)return null;l.data&&j(l.data,"expectedType")&&i.push(l.data.expectedType)}return new s("Invalid "+o+" `"+a+"` supplied to `"+n+"`"+(i.length>0?", expected one of type ["+i.join(", ")+"]":"")+".")}))},shape:function(e){return c((function(t,r,n,o,a){var i=t[r],c=p(i);if("object"!==c)return new s("Invalid "+o+" `"+a+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");for(var l in e){var f=e[l];if("function"!=typeof f)return u(n,o,a,l,m(f));var d=f(i,l,n,o,a+"."+l,P);if(d)return d}return null}))},exact:function(e){return c((function(t,r,n,o,a){var i=t[r],c=p(i);if("object"!==c)return new s("Invalid "+o+" `"+a+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");var l=k({},t[r],e);for(var f in l){var d=e[f];if(j(e,f)&&"function"!=typeof d)return u(n,o,a,f,m(d));if(!d)return new s("Invalid "+o+" `"+a+"` key `"+f+"` supplied to `"+n+"`.\nBad object: "+JSON.stringify(t[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=d(i,f,n,o,a+"."+f,P);if(y)return y}return null}))}};function i(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function c(e){if("production"!==process.env.NODE_ENV)var r={},n=0;function a(a,i,c,l,u,f,p){if(l=l||o,f=f||c,p!==P){if(t){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var d=l+":"+c;!r[d]&&n<3&&(V("You are manually calling a React.PropTypes validation function for the `"+f+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),r[d]=!0,n++)}}return null==i[c]?a?null===i[c]?new s("The "+u+" `"+f+"` is marked as required in `"+l+"`, but its value is `null`."):new s("The "+u+" `"+f+"` is marked as required in `"+l+"`, but its value is `undefined`."):null:e(i,c,l,u,f)}var i=a.bind(null,!1);return i.isRequired=a.bind(null,!0),i}function l(e){return c((function(t,r,n,o,a,i){var c=t[r];return p(c)!==e?new s("Invalid "+o+" `"+a+"` of type `"+m(c)+"` supplied to `"+n+"`, expected `"+e+"`.",{expectedType:e}):null}))}function u(e,t,r,n,o){return new s((e||"React class")+": "+t+" type `"+r+"."+n+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function f(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(f);if(null===t||e(t))return!0;var o=function(e){var t=e&&(r&&e[r]||e[n]);if("function"==typeof t)return t}(t);if(!o)return!1;var a,i=o.call(t);if(o!==t.entries){for(;!(a=i.next()).done;)if(!f(a.value))return!1}else for(;!(a=i.next()).done;){var s=a.value;if(s&&!f(s[1]))return!1}return!0;default:return!1}}function p(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function m(e){if(null==e)return""+e;var t=p(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function d(e){var t=m(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return s.prototype=Error.prototype,a.checkPropTypes=F,a.resetWarningCache=F.resetWarningCache,a.PropTypes=a,a};function D(){}function L(){}L.resetWarningCache=D;var W=t((function(e){if("production"!==process.env.NODE_ENV){var t=N;e.exports=q(t.isElement,!0)}else e.exports=function(){function e(e,t,r,n,o,a){if(a!==P){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:L,resetWarningCache:D};return r.PropTypes=r,r}()}));const U=({variant:t="primary",size:r="md",onClick:n,children:o,icon:a,iconPosition:i="start",className:s,style:c="default",processing:l=!1})=>{let u=`btn ${s}`;"default"!==t&&(u+=` btn-${t}`),"md"!==r&&(u+=` btn-${r}`),"default"!==c&&(u+=` btn-${c}`),l&&(u+=" btn-processing");const f=l?e.createElement(e.Fragment,null,e.createElement("i",{className:"fa-solid fa-spinner-third fa-spin","aria-hidden":"true"}),o&&e.createElement("span",null,o,"…")):a?"end"===i?e.createElement(e.Fragment,null,o&&e.createElement("span",null,o),e.createElement("i",{className:`fa-solid ${a}`,"aria-hidden":"true"})):e.createElement(e.Fragment,null,e.createElement("i",{className:`fa-solid ${a}`,"aria-hidden":"true"}),o&&e.createElement("span",null,o)):o&&e.createElement("span",null,o);return e.createElement("button",{className:u,onClick:n},f)};U.propTypes={variant:W.oneOf(["primary","secondary","terciary","outline"]),size:W.oneOf(["xs","md","lg"]),onClick:W.func,children:W.node,icon:W.string,iconPosition:W.oneOf(["start","end"]),className:W.string,style:W.oneOf(["default","success","danger","warning","link"]),processing:W.bool};const Y=()=>({toCamelCase:e.useCallback((e=>{let t=e?.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g,(function(e,t){return 0==+e?"":0===t?e?.toLowerCase():e?.toUpperCase()}));return t=t?.replace(/^\d+/,""),t=t?.replace(/[^a-zA-Z0-9_]/g,""),t}),[])}),B=({children:t,className:r,id:n,name:o,status:a=!1,setStatus:i})=>{const{toCamelCase:s}=Y();let c=n;n||"string"!=typeof t||(c=s(t));return e.createElement("div",{className:`form-group form-check ${r}`},e.createElement("label",{className:"checkbox"},e.createElement("input",{type:"checkbox",checked:a,onChange:e=>{i(e.target.checked)},minLength:"1",id:c,name:o}),e.createElement("span",{className:"outer"},e.createElement("span",{className:"inner"})),t))};B.propTypes={className:W.string,id:W.string,name:W.string,status:W.bool,setStatus:W.func};const J=({className:t,disabled:r,helpText:n,icon:o,label:a="Label",name:i,onChange:s,prefix:c,requiredText:l,showError:u,setShowError:f,size:p="md",suffix:m,type:d="text",value:y})=>{const{toCamelCase:b}=Y(),g="lg"===p?"form-control-lg":"xs"===p?"form-control-xs":"",h=b(a);return e.useEffect((()=>{u&&setTimeout((()=>{f(!1)}),3e3)}),[u]),e.createElement("div",{className:`position-relative ${t}`},c||m||o?e.createElement("div",{className:"input-group "+(u?"not-validated":""),"data-error":l},o&&e.createElement("span",{className:"input-group-text"},e.createElement("i",{className:`fa-solid ${o}`})),c&&e.createElement("span",{className:"input-group-text"},c),e.createElement("div",{className:"form-floating"},e.createElement("input",{type:d,className:`form-control ${g}`,value:y,id:h,name:i,placeholder:a,onChange:s,required:!!l}),e.createElement("label",{htmlFor:h},a)),m&&e.createElement("span",{className:"input-group-text"},m)):e.createElement("div",{className:"form-floating "+(u?"not-validated":""),"data-error":l},e.createElement("input",{type:d,className:`form-control ${g}`,value:y,id:h,placeholder:a,onChange:s,required:!!l,name:i,disabled:r}),e.createElement("label",{htmlFor:h},a)),n&&e.createElement("small",{className:"form-text text-muted"},n))};J.propTypes={className:W.string,disabled:W.bool,helpText:W.string,icon:W.string,label:W.string,name:W.string,onChange:W.func,prefix:W.string,requiredText:W.string,size:W.oneOf(["xs","md","lg"]),showError:W.bool,setShowError:W.func,suffix:W.string,type:W.oneOf(["color","date","datetime-local","email","file","image","month","number","password","tel","text","time","url","week"]),value:W.oneOfType([W.string,W.number])};const Z=({children:t,className:r,id:n,name:o,setStatus:a,status:i=!1})=>{const{toCamelCase:s}=Y();let c=n;n||"string"!=typeof t||(c=s(t));return e.createElement("div",{className:`form-group form-check ${r}`},e.createElement("label",{className:"radio"},e.createElement("input",{type:"radio",checked:i,onChange:e=>{a(e.target.checked)},minLength:"1",id:c,name:o}),e.createElement("span",{className:"outer"},e.createElement("span",{className:"inner"})),t))};Z.propTypes={className:W.string,id:W.string,name:W.string,setStatus:W.func,status:W.bool};const H=({children:t,className:r,icon:n=!1,id:o,name:a,size:i,setStatus:s,status:c=!1,switchPosition:l="start"})=>{const{toCamelCase:u}=Y(),f="lg"===i?"form-switch-lg":"xs"===i?"form-switch-xs":"",p=o||u(t);return e.createElement("div",{className:`form-check form-switch ${f} ${r} ${"end"===l?"switch-end":""} ${n?"switch-icon":""}`},e.createElement("input",{className:"form-check-input",type:"checkbox",role:"switch",onChange:e=>{s(e.target.checked)},id:p,name:a,checked:c}),t&&e.createElement("label",{className:"form-check-label",htmlFor:p},t))};H.propTypes={className:W.string,icon:W.bool,id:W.string,name:W.string,setStatus:W.func,status:W.bool,switchPosition:W.oneOf(["start","end"])};const G=({className:t,helpText:r,label:n="Label",name:o,onChange:a,requiredText:i,showError:s,setShowError:c,size:l="md"})=>{const{toCamelCase:u}=Y(),f="lg"===l?"form-control-lg":"xs"===l?"form-control-xs":"",p=u(n);return e.useEffect((()=>{s&&setTimeout((()=>{c(!1)}),3e3)}),[s]),e.createElement("div",{className:`position-relative ${t}`},e.createElement("div",{className:"form-floating "+(s?"not-validated":""),"data-error":i},e.createElement("textarea",{className:`form-control ${f}`,onChange:a,placeholder:n,id:p,name:o,required:!!i}),e.createElement("label",{htmlFor:p},n),r&&e.createElement("small",{className:"form-text text-muted"},r)))};G.propTypes={className:W.string,helpText:W.string,label:W.string,name:W.string,onChange:W.func,requiredText:W.string,showError:W.bool,size:W.oneOf(["xs","md","lg"])},exports.Button=U,exports.Checkbox=B,exports.Input=J,exports.Radio=Z,exports.Switch=H,exports.Textarea=G;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groovinads-ui",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "repository": "git@bitbucket.org:groovinads/react-components.git",
@@ -22,10 +22,10 @@
22
22
  "prettier": "^3.2.5",
23
23
  "prop-types": "^15.8.1",
24
24
  "react": "^18.2.0",
25
- "react-bootstrap": "^2.10.1",
26
25
  "react-dom": "^18.2.0",
27
26
  "rollup": "^4.14.0",
28
27
  "rollup-plugin-babel": "^4.4.0",
28
+ "rollup-plugin-commonjs": "^10.1.0",
29
29
  "rollup-plugin-peer-deps-external": "^2.2.4",
30
30
  "rollup-plugin-postcss": "^4.0.2",
31
31
  "rollup-plugin-terser": "^7.0.2",
@@ -44,5 +44,8 @@
44
44
  "sb": "storybook dev -p 6006",
45
45
  "build-storybook": "storybook build",
46
46
  "build-lib": "rollup -c"
47
+ },
48
+ "dependencies": {
49
+ "react-router-dom": "^6.23.0"
47
50
  }
48
51
  }
package/rollup.config.mjs CHANGED
@@ -3,6 +3,7 @@ import resolve from '@rollup/plugin-node-resolve';
3
3
  import external from 'rollup-plugin-peer-deps-external';
4
4
  import { terser } from 'rollup-plugin-terser';
5
5
  import postcss from 'rollup-plugin-postcss';
6
+ import commonjs from 'rollup-plugin-commonjs';
6
7
  // import typescript from 'rollup-plugin-typescript2';
7
8
 
8
9
  export default [
@@ -20,6 +21,9 @@ export default [
20
21
  }
21
22
  ],
22
23
  plugins: [
24
+ commonjs({
25
+ include: 'node_modules/**', // incluye todos los módulos de node_modules
26
+ }),
23
27
  postcss({
24
28
  plugins: [],
25
29
  minimize: true,
@@ -1,89 +1,78 @@
1
1
  import React from 'react';
2
- import * as PropTypes from 'prop-types';
2
+ import PropTypes from 'prop-types';
3
3
 
4
4
  const Button = ({
5
- variant,
6
- size,
7
- onClick,
8
- children,
9
- icon,
10
- iconPosition,
11
- className,
12
- style,
13
- processing,
5
+ variant = 'primary',
6
+ size = 'md',
7
+ onClick,
8
+ children,
9
+ icon,
10
+ iconPosition = 'start',
11
+ className,
12
+ style = 'default',
13
+ processing = false,
14
14
  }) => {
15
- let classes = `btn ${className}`;
15
+ let classes = `btn ${className}`;
16
16
 
17
- // Variant
18
- if (variant !== 'default') {
19
- classes += ` btn-${variant}`;
20
- }
17
+ // Variant
18
+ if (variant !== 'default') {
19
+ classes += ` btn-${variant}`;
20
+ }
21
21
 
22
- // Size
23
- if (size !== 'md') {
24
- classes += ` btn-${size}`;
25
- }
22
+ // Size
23
+ if (size !== 'md') {
24
+ classes += ` btn-${size}`;
25
+ }
26
26
 
27
- // Style
28
- if (style !== 'default') {
29
- classes += ` btn-${style}`;
30
- }
27
+ // Style
28
+ if (style !== 'default') {
29
+ classes += ` btn-${style}`;
30
+ }
31
31
 
32
- // Processing
33
- if (processing) {
34
- classes += ` btn-processing`;
35
- }
32
+ // Processing
33
+ if (processing) {
34
+ classes += ` btn-processing`;
35
+ }
36
36
 
37
- // Icon
38
- const content = processing ? (
39
- <>
40
- <i className='fa-solid fa-spinner-third fa-spin' aria-hidden='true'></i>
41
- {children && <span>{children}…</span>}
42
- </>
43
- ) : icon ? (
44
- iconPosition === 'end' ? (
45
- <>
46
- {children && <span>{children}</span>}
47
- <i className={`fa-solid ${icon}`} aria-hidden='true'></i>
48
- </>
49
- ) : (
50
- <>
51
- <i className={`fa-solid ${icon}`} aria-hidden='true'></i>
52
- {children && <span>{children}</span>}
53
- </>
54
- )
37
+ // Icon
38
+ const content = processing ? (
39
+ <>
40
+ <i className='fa-solid fa-spinner-third fa-spin' aria-hidden='true'></i>
41
+ {children && <span>{children}…</span>}
42
+ </>
43
+ ) : icon ? (
44
+ iconPosition === 'end' ? (
45
+ <>
46
+ {children && <span>{children}</span>}
47
+ <i className={`fa-solid ${icon}`} aria-hidden='true'></i>
48
+ </>
55
49
  ) : (
56
- children && <span>{children}</span>
57
- );
50
+ <>
51
+ <i className={`fa-solid ${icon}`} aria-hidden='true'></i>
52
+ {children && <span>{children}</span>}
53
+ </>
54
+ )
55
+ ) : (
56
+ children && <span>{children}</span>
57
+ );
58
58
 
59
- return (
60
- <button className={classes} onClick={onClick}>
61
- {content}
62
- </button>
63
- );
59
+ return (
60
+ <button className={classes} onClick={onClick}>
61
+ {content}
62
+ </button>
63
+ );
64
64
  };
65
65
 
66
66
  Button.propTypes = {
67
- // variant: PropTypes.oneOf(['primary', 'secondary', 'terciary', 'outline']),
68
- // size: PropTypes.oneOf(['xs', 'md', 'lg']),
69
- // onClick: PropTypes.func,
70
- // children: PropTypes.node,
71
- // icon: PropTypes.node,
72
- // iconPosition: PropTypes.oneOf(['start', 'end']),
73
- // className: PropTypes.string,
74
- // style: PropTypes.oneOf(['default', 'success', 'danger', 'warning', 'link']),
75
- // processing: PropTypes.bool,
76
- };
77
-
78
- Button.defaultProps = {
79
- variant: 'primary',
80
- size: 'md',
81
- onClick: null,
82
- icon: null,
83
- iconPosition: 'start',
84
- className: '',
85
- style: 'default',
86
- processing: false,
67
+ variant: PropTypes.oneOf(['primary', 'secondary', 'terciary', 'outline']),
68
+ size: PropTypes.oneOf(['xs', 'md', 'lg']),
69
+ onClick: PropTypes.func,
70
+ children: PropTypes.node,
71
+ icon: PropTypes.string,
72
+ iconPosition: PropTypes.oneOf(['start', 'end']),
73
+ className: PropTypes.string,
74
+ style: PropTypes.oneOf(['default', 'success', 'danger', 'warning', 'link']),
75
+ processing: PropTypes.bool,
87
76
  };
88
77
 
89
78
  export default Button;
@@ -1,3 +1,3 @@
1
1
  import Button from "./Button";
2
2
 
3
- export default Button;
3
+ export { Button };
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ // HOOKS
5
+ import useTextFormatter from '../../hooks/textFormatter';
6
+
7
+ // Checkbox
8
+ const Checkbox = ({
9
+ children,
10
+ className,
11
+ id,
12
+ name,
13
+ status = false,
14
+ setStatus
15
+ }) => {
16
+ const { toCamelCase } = useTextFormatter();
17
+
18
+ let checkboxId = id;
19
+ if (!id && typeof children === 'string') {
20
+ checkboxId = toCamelCase(children);
21
+ }
22
+
23
+ const handleChange = (event) => {
24
+ setStatus(event.target.checked);
25
+ };
26
+
27
+ return (
28
+ <div className={`form-group form-check ${className}`}>
29
+ <label className='checkbox'>
30
+ <input
31
+ type='checkbox'
32
+ checked={status}
33
+ onChange={handleChange}
34
+ minLength='1'
35
+ id={checkboxId}
36
+ name={name}
37
+ />
38
+ <span className='outer'>
39
+ <span className='inner'></span>
40
+ </span>
41
+ {children}
42
+ </label>
43
+ </div>
44
+ );
45
+ };
46
+
47
+ Checkbox.propTypes = {
48
+ className: PropTypes.string,
49
+ id: PropTypes.string,
50
+ name: PropTypes.string,
51
+ status: PropTypes.bool,
52
+ setStatus: PropTypes.func,
53
+ };
54
+
55
+ export default Checkbox;
@@ -0,0 +1,124 @@
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ // HOOKS
5
+ import useTextFormatter from '../../hooks/textFormatter';
6
+
7
+ // Input
8
+ const Input = ({
9
+ className,
10
+ disabled,
11
+ helpText,
12
+ icon,
13
+ label = 'Label',
14
+ name,
15
+ onChange,
16
+ prefix,
17
+ requiredText,
18
+ showError,
19
+ setShowError,
20
+ size = 'md',
21
+ suffix,
22
+ type = 'text',
23
+ value
24
+ }) => {
25
+ const { toCamelCase } = useTextFormatter();
26
+
27
+ const sizeClass =
28
+ size === 'lg' ? 'form-control-lg' : size === 'xs' ? 'form-control-xs' : '';
29
+ const id = toCamelCase(label);
30
+
31
+ useEffect(() => {
32
+ if (showError) {
33
+ setTimeout(() => {
34
+ setShowError(false);
35
+ }, 3000);
36
+ }
37
+ }, [showError]);
38
+
39
+ return (
40
+ <div className={`position-relative ${className}`}>
41
+ {prefix || suffix || icon ? (
42
+ <div
43
+ className={`input-group ${showError ? 'not-validated' : ''}`}
44
+ data-error={requiredText}
45
+ >
46
+ {icon && (
47
+ <span className='input-group-text'>
48
+ <i className={`fa-solid ${icon}`}></i>
49
+ </span>
50
+ )}
51
+ {prefix && <span className='input-group-text'>{prefix}</span>}
52
+ <div className='form-floating'>
53
+ <input
54
+ type={type}
55
+ className={`form-control ${sizeClass}`}
56
+ value={value}
57
+ id={id}
58
+ name={name}
59
+ placeholder={label}
60
+ onChange={onChange}
61
+ required={!!requiredText}
62
+ />
63
+ <label htmlFor={id}>{label}</label>
64
+ </div>
65
+ {suffix && <span className='input-group-text'>{suffix}</span>}
66
+ </div>
67
+ ) : (
68
+ <div
69
+ className={`form-floating ${showError ? 'not-validated' : ''}`}
70
+ data-error={requiredText}
71
+ >
72
+ <input
73
+ type={type}
74
+ className={`form-control ${sizeClass}`}
75
+ value={value}
76
+ id={id}
77
+ placeholder={label}
78
+ onChange={onChange}
79
+ required={!!requiredText}
80
+ name={name}
81
+ disabled={disabled}
82
+ />
83
+ <label htmlFor={id}>{label}</label>
84
+ </div>
85
+ )}
86
+ {helpText && <small className='form-text text-muted'>{helpText}</small>}
87
+ </div>
88
+ );
89
+ };
90
+
91
+ Input.propTypes = {
92
+ className: PropTypes.string,
93
+ disabled: PropTypes.bool,
94
+ helpText: PropTypes.string,
95
+ icon: PropTypes.string,
96
+ label: PropTypes.string,
97
+ name: PropTypes.string,
98
+ onChange: PropTypes.func,
99
+ prefix: PropTypes.string,
100
+ requiredText: PropTypes.string,
101
+ size: PropTypes.oneOf(['xs', 'md', 'lg']),
102
+ showError: PropTypes.bool,
103
+ setShowError: PropTypes.func,
104
+ suffix: PropTypes.string,
105
+ type: PropTypes.oneOf([
106
+ 'color',
107
+ 'date',
108
+ 'datetime-local',
109
+ 'email',
110
+ 'file',
111
+ 'image',
112
+ 'month',
113
+ 'number',
114
+ 'password',
115
+ 'tel',
116
+ 'text',
117
+ 'time',
118
+ 'url',
119
+ 'week',
120
+ ]),
121
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
122
+ };
123
+
124
+ export default Input;
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ // HOOKS
5
+ import useTextFormatter from '../../hooks/textFormatter';
6
+
7
+ // Radio
8
+ const Radio = ({
9
+ children,
10
+ className,
11
+ id,
12
+ name,
13
+ setStatus,
14
+ status = false
15
+ }) => {
16
+ const { toCamelCase } = useTextFormatter();
17
+
18
+ let RadioId = id;
19
+ if (!id && typeof children === 'string') {
20
+ RadioId = toCamelCase(children);
21
+ }
22
+
23
+ const handleChange = (event) => {
24
+ setStatus(event.target.checked);
25
+ };
26
+
27
+ return (
28
+ <div className={`form-group form-check ${className}`}>
29
+ <label className='radio'>
30
+ <input
31
+ type='radio'
32
+ checked={status}
33
+ onChange={handleChange}
34
+ minLength='1'
35
+ id={RadioId}
36
+ name={name}
37
+ />
38
+ <span className='outer'>
39
+ <span className='inner'></span>
40
+ </span>
41
+ {children}
42
+ </label>
43
+ </div>
44
+ );
45
+ };
46
+
47
+ Radio.propTypes = {
48
+ className: PropTypes.string,
49
+ id: PropTypes.string,
50
+ name: PropTypes.string,
51
+ setStatus: PropTypes.func,
52
+ status: PropTypes.bool,
53
+ };
54
+
55
+ export default Radio;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ // HOOKS
5
+ import useTextFormatter from '../../hooks/textFormatter';
6
+
7
+ const Switch = ({
8
+ children,
9
+ className,
10
+ icon = false,
11
+ id,
12
+ name,
13
+ size,
14
+ setStatus,
15
+ status = false,
16
+ switchPosition = 'start'
17
+ }) => {
18
+ const { toCamelCase } = useTextFormatter();
19
+
20
+ const sizeClass =
21
+ size === 'lg' ? 'form-switch-lg' : size === 'xs' ? 'form-switch-xs' : '';
22
+
23
+ const inputId = id ? id : toCamelCase(children);
24
+
25
+ const handleChange = (event) => {
26
+ setStatus(event.target.checked);
27
+ };
28
+
29
+ return (
30
+ <div
31
+ className={`form-check form-switch ${sizeClass} ${className} ${
32
+ switchPosition === 'end' ? 'switch-end' : ''
33
+ } ${icon ? 'switch-icon' : ''}`}
34
+ >
35
+ <input
36
+ className='form-check-input'
37
+ type='checkbox'
38
+ role='switch'
39
+ onChange={handleChange}
40
+ id={inputId}
41
+ name={name}
42
+ checked={status}
43
+ />
44
+ {children && (
45
+ <label className='form-check-label' htmlFor={inputId}>
46
+ {children}
47
+ </label>
48
+ )}
49
+ </div>
50
+ );
51
+ };
52
+
53
+ Switch.propTypes = {
54
+ className: PropTypes.string,
55
+ icon: PropTypes.bool,
56
+ id: PropTypes.string,
57
+ name: PropTypes.string,
58
+ setStatus: PropTypes.func,
59
+ status: PropTypes.bool,
60
+ switchPosition: PropTypes.oneOf(['start', 'end']),
61
+ };
62
+
63
+ export default Switch;
@@ -0,0 +1,64 @@
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ // HOOKS
5
+ import useTextFormatter from '../../hooks/textFormatter';
6
+
7
+ const Textarea = ({
8
+ className,
9
+ helpText,
10
+ label = 'Label',
11
+ name,
12
+ onChange,
13
+ requiredText,
14
+ showError,
15
+ setShowError,
16
+ size = 'md'
17
+ }) => {
18
+ const { toCamelCase } = useTextFormatter();
19
+
20
+ const sizeClass =
21
+ size === 'lg' ? 'form-control-lg' : size === 'xs' ? 'form-control-xs' : '';
22
+ const id = toCamelCase(label);
23
+
24
+ useEffect(() => {
25
+ if (showError) {
26
+ setTimeout(() => {
27
+ setShowError(false);
28
+ }, 3000);
29
+ }
30
+ }, [showError]);
31
+
32
+ return (
33
+ <div className={`position-relative ${className}`}>
34
+ <div
35
+ className={`form-floating ${showError ? 'not-validated' : ''}`}
36
+ data-error={requiredText}
37
+ >
38
+ <textarea
39
+ className={`form-control ${sizeClass}`}
40
+ onChange={onChange}
41
+ placeholder={label}
42
+ id={id}
43
+ name={name}
44
+ required={!!requiredText}
45
+ />
46
+ <label htmlFor={id}>{label}</label>
47
+ {helpText && <small className='form-text text-muted'>{helpText}</small>}
48
+ </div>
49
+ </div>
50
+ );
51
+ };
52
+
53
+ Textarea.propTypes = {
54
+ className: PropTypes.string,
55
+ helpText: PropTypes.string,
56
+ label: PropTypes.string,
57
+ name: PropTypes.string,
58
+ onChange: PropTypes.func,
59
+ requiredText: PropTypes.string,
60
+ showError: PropTypes.bool,
61
+ size: PropTypes.oneOf(['xs', 'md', 'lg']),
62
+ };
63
+
64
+ export default Textarea;
@@ -0,0 +1,7 @@
1
+ import Checkbox from './Checkbox';
2
+ import Input from './Input';
3
+ import Radio from './Radio';
4
+ import Switch from './Switch';
5
+ import Textarea from './Textarea';
6
+
7
+ export { Checkbox, Input, Radio, Switch, Textarea }
@@ -0,0 +1,3 @@
1
+ import textFormatter from './textFormatter';
2
+
3
+ export { textFormatter };
@@ -0,0 +1,24 @@
1
+ import { useCallback } from 'react';
2
+
3
+ const useTextFormatter = () => {
4
+ const toCamelCase = useCallback((str) => {
5
+ let s = str?.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
6
+ if (+match === 0) return ''; // or if (/\s+/.test(match)) for white spaces
7
+ return index === 0 ? match?.toLowerCase() : match?.toUpperCase();
8
+ });
9
+
10
+ // Ensure the string doesn't start with a number
11
+ s = s?.replace(/^\d+/, '');
12
+
13
+ // Remove any remaining non-alphanumeric characters (excluding underscores)
14
+ s = s?.replace(/[^a-zA-Z0-9_]/g, '');
15
+
16
+ return s;
17
+ }, []);
18
+
19
+ // Additional methods can be added here
20
+
21
+ return { toCamelCase };
22
+ };
23
+
24
+ export default useTextFormatter;
package/src/index.js CHANGED
@@ -1,3 +1,9 @@
1
1
  import Button from "./components/Button/Button";
2
2
 
3
- export { Button };
3
+ import Checkbox from './components/Inputs/Checkbox';
4
+ import Input from './components/Inputs/Input';
5
+ import Radio from './components/Inputs/Radio';
6
+ import Switch from './components/Inputs/Switch';
7
+ import Textarea from './components/Inputs/Textarea';
8
+
9
+ export { Button, Checkbox, Input, Radio, Switch, Textarea }
@@ -1,11 +1,11 @@
1
- import React from "react";
2
- import Button from "../components/Button/Button";
1
+ import React from 'react';
2
+ import Button from '../components/Button/Button';
3
3
 
4
4
  export default {
5
- title: "Example/Button",
5
+ title: 'Buttons/Button',
6
6
  component: Button,
7
7
  };
8
8
 
9
9
  const Template = (args) => <Button {...args}>Button</Button>;
10
10
 
11
- export const Primary = Template.bind({});
11
+ export const Default = Template.bind({});
@@ -0,0 +1,17 @@
1
+ import React, { useState } from 'react';
2
+ import Checkbox from '../components/Inputs/Checkbox';
3
+
4
+ export default {
5
+ title: 'Inputs/Checkbox',
6
+ component: Checkbox,
7
+ };
8
+
9
+ const Template = (args) => {
10
+ const [status, setStatus] = useState(false);
11
+
12
+ return (
13
+ <Checkbox {...args} status={status} setStatus={setStatus}>Checkbox</Checkbox>
14
+ )
15
+ };
16
+
17
+ export const Default = Template.bind({});
@@ -0,0 +1,20 @@
1
+ import React, { useState } from 'react';
2
+ import Input from '../components/Inputs/Input';
3
+
4
+ export default {
5
+ title: 'Inputs/Input',
6
+ component: Input,
7
+ };
8
+
9
+ const Template = (args) => {
10
+ const [showError, setShowError] = useState(false);
11
+
12
+ return (
13
+ <>
14
+ <button onClick={()=>setShowError(true)}>False</button>
15
+ <Input {...args} setShowError={setShowError} showError={showError} />
16
+ </>
17
+ )
18
+ };
19
+
20
+ export const Default = Template.bind({});
@@ -0,0 +1,18 @@
1
+ import React, { useState } from 'react';
2
+ import Radio from '../components/Inputs/Radio';
3
+
4
+ export default {
5
+ title: 'Inputs/Radio',
6
+ component: Radio,
7
+ };
8
+
9
+ const Template = (args) => {
10
+ const [status, setStatus] = useState(false);
11
+
12
+ return (
13
+ <Radio {...args} status={status} setStatus={setStatus}>Radio</Radio>
14
+ )
15
+ };
16
+
17
+ export const Default = Template.bind({});
18
+
@@ -0,0 +1,17 @@
1
+ import React, { useState } from 'react';
2
+ import Switch from '../components/Inputs/Switch';
3
+
4
+ export default {
5
+ title: 'Inputs/Switch',
6
+ component: Switch,
7
+ };
8
+
9
+ const Template = (args) => {
10
+ const [status, setStatus] = useState(false);
11
+
12
+ return (
13
+ <Switch {...args} status={status} setStatus={setStatus}>Switch</Switch>
14
+ )
15
+ };
16
+
17
+ export const Default = Template.bind({});
@@ -0,0 +1,20 @@
1
+ import React, { useState } from 'react';
2
+ import Textarea from '../components/Inputs/Textarea';
3
+
4
+ export default {
5
+ title: 'Inputs/Textarea',
6
+ component: Textarea,
7
+ };
8
+
9
+ const Template = (args) => {
10
+ const [showError, setShowError] = useState(false);
11
+
12
+ return (
13
+ <>
14
+ <button onClick={()=>setShowError(true)}>False</button>
15
+ <Textarea {...args} setShowError={setShowError} showError={showError} />
16
+ </>
17
+ )
18
+ };
19
+
20
+ export const Default = Template.bind({});