rharuow-ds 1.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/rharuow-ds.cjs.js +22 -0
- package/dist/rharuow-ds.es.js +399 -0
- package/dist/types/src/components/Button.d.ts +6 -0
- package/dist/types/src/components/Input.d.ts +12 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/lib/utils.d.ts +2 -0
- package/dist/types/src/stories/Button.stories.d.ts +7 -0
- package/dist/types/src/stories/Input.stories.d.ts +6 -0
- package/dist/types/vite.config.d.ts +2 -0
- package/package.json +39 -0
- package/src/components/Button.tsx +24 -0
- package/src/components/Input.tsx +104 -0
- package/src/components/index.ts +2 -0
- package/src/lib/utils.ts +5 -0
- package/src/stories/Button.stories.tsx +25 -0
- package/src/stories/Input.stories.tsx +29 -0
- package/src/styles/tailwind.css +3 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react");function fe(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(o,t,a.get?a:{enumerable:!0,get:()=>r[t]})}}return o.default=r,Object.freeze(o)}const Y=fe(R);var F={exports:{}},k={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and 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 H;function de(){if(H)return k;H=1;var r=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function t(a,s,c){var d=null;if(c!==void 0&&(d=""+c),s.key!==void 0&&(d=""+s.key),"key"in s){c={};for(var m in s)m!=="key"&&(c[m]=s[m])}else c=s;return s=c.ref,{$$typeof:r,type:a,key:d,ref:s!==void 0?s:null,props:c}}return k.Fragment=o,k.jsx=t,k.jsxs=t,k}var h={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Z;function me(){return Z||(Z=1,process.env.NODE_ENV!=="production"&&function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case w:return"Profiler";case I:return"StrictMode";case C:return"Suspense";case O:return"SuspenseList";case ue:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case A:return"Portal";case P:return(e.displayName||"Context")+".Provider";case D:return(e._context.displayName||"Context")+".Consumer";case N:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return n=e.displayName||null,n!==null?n:r(e.type)||"Memo";case z:n=e._payload,e=e._init;try{return r(e(n))}catch{}}return null}function o(e){return""+e}function t(e){try{o(e);var n=!1}catch{n=!0}if(n){n=console;var u=n.error,l=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",l),o(e)}}function a(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===z)return"<...>";try{var n=r(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function s(){var e=W.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function d(e){if(q.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function m(e,n){function u(){J||(J=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}function T(){var e=r(this.type);return V[e]||(V[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function f(e,n,u,l,E,b,L,M){return u=b.ref,e={$$typeof:v,type:e,key:n,props:b,_owner:E},(u!==void 0?u:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:T}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function x(e,n,u,l,E,b,L,M){var i=n.children;if(i!==void 0)if(l)if(le(i)){for(l=0;l<i.length;l++)j(i[l]);Object.freeze&&Object.freeze(i)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(i);if(q.call(n,"key")){i=r(e);var g=Object.keys(n).filter(function(ie){return ie!=="key"});l=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",X[i+l]||(g=0<g.length?"{"+g.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,l,i,g,i),X[i+l]=!0)}if(i=null,u!==void 0&&(t(u),i=""+u),d(n)&&(t(n.key),i=""+n.key),"key"in n){u={};for(var U in n)U!=="key"&&(u[U]=n[U])}else u=n;return i&&m(u,typeof e=="function"?e.displayName||e.name||"Unknown":e),f(e,i,b,E,s(),u,L,M)}function j(e){typeof e=="object"&&e!==null&&e.$$typeof===v&&e._store&&(e._store.validated=1)}var _=R,v=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),D=Symbol.for("react.consumer"),P=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),ue=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),W=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=Object.prototype.hasOwnProperty,le=Array.isArray,$=console.createTask?console.createTask:function(){return null};_={"react-stack-bottom-frame":function(e){return e()}};var J,V={},G=_["react-stack-bottom-frame"].bind(_,c)(),B=$(a(c)),X={};h.Fragment=y,h.jsx=function(e,n,u,l,E){var b=1e4>W.recentlyCreatedOwnerStacks++;return x(e,n,u,!1,l,E,b?Error("react-stack-top-frame"):G,b?$(a(e)):B)},h.jsxs=function(e,n,u,l,E){var b=1e4>W.recentlyCreatedOwnerStacks++;return x(e,n,u,!0,l,E,b?Error("react-stack-top-frame"):G,b?$(a(e)):B)}}()),h}var Q;function be(){return Q||(Q=1,process.env.NODE_ENV==="production"?F.exports=de():F.exports=me()),F.exports}var p=be();function re(r){var o,t,a="";if(typeof r=="string"||typeof r=="number")a+=r;else if(typeof r=="object")if(Array.isArray(r)){var s=r.length;for(o=0;o<s;o++)r[o]&&(t=re(r[o]))&&(a&&(a+=" "),a+=t)}else for(t in r)r[t]&&(a&&(a+=" "),a+=t);return a}function ve(){for(var r,o,t=0,a="",s=arguments.length;t<s;t++)(r=arguments[t])&&(o=re(r))&&(a&&(a+=" "),a+=o);return a}function S(...r){return ve(...r)}const Ee=({children:r,variant:o="default",className:t="",...a})=>{const s="px-4 py-2 rounded font-medium transition",c={default:"bg-blue-600 text-white hover:bg-blue-700",outline:"border border-blue-600 text-blue-600 bg-white hover:bg-blue-50"};return p.jsx("button",{className:S(s,c[o],t),...a,children:r})};var _e=r=>r instanceof Date,te=r=>r==null;const pe=r=>typeof r=="object";var Re=r=>!te(r)&&!Array.isArray(r)&&pe(r)&&!_e(r),xe=r=>/^\w*$/.test(r),K=r=>r===void 0,ge=r=>Array.isArray(r)?r.filter(Boolean):[],Te=r=>ge(r.replace(/["|']|\]/g,"").split(/\.|\[/)),ee=(r,o,t)=>{if(!o||!Re(r))return t;const a=(xe(o)?[o]:Te(o)).reduce((s,c)=>te(s)?s:s[c],r);return K(a)||a===r?K(r[o])?t:r[o]:a};const ne=R.createContext(null);ne.displayName="HookFormContext";const ae=()=>R.useContext(ne),ye=typeof window<"u"?Y.useLayoutEffect:Y.useEffect;var Oe=r=>typeof r=="string",ke=(r,o,t,a,s)=>Oe(r)?ee(t,r,s):Array.isArray(r)?r.map(c=>ee(t,c)):t;function he(r){const o=ae(),{control:t=o.control,name:a,defaultValue:s,disabled:c,exact:d}=r||{},m=R.useRef(s),[T,f]=R.useState(t._getWatch(a,m.current));return ye(()=>t._subscribe({name:a,formState:{values:!0},exact:d,callback:x=>!c&&f(ke(a,t._names,x.values||t._formValues,!1,m.current))}),[a,t,c,d]),R.useEffect(()=>t._removeUnmounted()),T}const oe=Y.forwardRef(({className:r,type:o="text",label:t,onFocus:a,onBlur:s,Icon:c,iconClassName:d,iconAction:m,containerClassName:T,...f},x)=>{var P,N,C;const[j,_]=Y.useState(!1),v=ae(),A=v==null?void 0:v.control,y=A&&f.name?he({control:A,name:String(f.name)}):void 0,I=f.value??y??"",w=(C=(N=(P=v==null?void 0:v.formState)==null?void 0:P.errors)==null?void 0:N[f.name])==null?void 0:C.message,D=j||!!I;return p.jsxs("div",{className:S("relative",T),children:[p.jsx("input",{id:f.id||f.name,type:o,className:S("peer flex h-12 w-full border border-input rounded-md bg-transparent px-3 pt-6 pb-2 text-sm text-white placeholder-transparent transition focus:outline-none focus:border-blue-500 disabled:cursor-not-allowed disabled:opacity-50",r),onFocus:O=>{_(!0),a&&a(O)},onBlur:O=>{_(!1),s&&s(O)},ref:x,...f}),t&&p.jsx("label",{htmlFor:f.id||f.name,className:S("absolute left-3 top-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",D?"scale-90 -translate-y-3 text-xs text-blue-400":"scale-100 translate-y-0"),children:t}),c&&p.jsx("div",{className:S("absolute top-1/2 right-3 -translate-y-1/2 text-white",d),onClick:m,children:p.jsx(c,{})}),w&&p.jsx("span",{className:"text-red-500 text-xs mt-1 block",children:w})]})});oe.displayName="Input";exports.Button=Ee;exports.Input=oe;
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import * as Y from "react";
|
|
2
|
+
import T from "react";
|
|
3
|
+
var F = { exports: {} }, h = {};
|
|
4
|
+
/**
|
|
5
|
+
* @license React
|
|
6
|
+
* react-jsx-runtime.production.js
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
var H;
|
|
14
|
+
function ie() {
|
|
15
|
+
if (H) return h;
|
|
16
|
+
H = 1;
|
|
17
|
+
var r = Symbol.for("react.transitional.element"), s = Symbol.for("react.fragment");
|
|
18
|
+
function n(a, o, l) {
|
|
19
|
+
var d = null;
|
|
20
|
+
if (l !== void 0 && (d = "" + l), o.key !== void 0 && (d = "" + o.key), "key" in o) {
|
|
21
|
+
l = {};
|
|
22
|
+
for (var m in o)
|
|
23
|
+
m !== "key" && (l[m] = o[m]);
|
|
24
|
+
} else l = o;
|
|
25
|
+
return o = l.ref, {
|
|
26
|
+
$$typeof: r,
|
|
27
|
+
type: a,
|
|
28
|
+
key: d,
|
|
29
|
+
ref: o !== void 0 ? o : null,
|
|
30
|
+
props: l
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return h.Fragment = s, h.jsx = n, h.jsxs = n, h;
|
|
34
|
+
}
|
|
35
|
+
var A = {};
|
|
36
|
+
/**
|
|
37
|
+
* @license React
|
|
38
|
+
* react-jsx-runtime.development.js
|
|
39
|
+
*
|
|
40
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the MIT license found in the
|
|
43
|
+
* LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/
|
|
45
|
+
var Z;
|
|
46
|
+
function fe() {
|
|
47
|
+
return Z || (Z = 1, process.env.NODE_ENV !== "production" && function() {
|
|
48
|
+
function r(e) {
|
|
49
|
+
if (e == null) return null;
|
|
50
|
+
if (typeof e == "function")
|
|
51
|
+
return e.$$typeof === ue ? null : e.displayName || e.name || null;
|
|
52
|
+
if (typeof e == "string") return e;
|
|
53
|
+
switch (e) {
|
|
54
|
+
case y:
|
|
55
|
+
return "Fragment";
|
|
56
|
+
case j:
|
|
57
|
+
return "Profiler";
|
|
58
|
+
case I:
|
|
59
|
+
return "StrictMode";
|
|
60
|
+
case C:
|
|
61
|
+
return "Suspense";
|
|
62
|
+
case k:
|
|
63
|
+
return "SuspenseList";
|
|
64
|
+
case se:
|
|
65
|
+
return "Activity";
|
|
66
|
+
}
|
|
67
|
+
if (typeof e == "object")
|
|
68
|
+
switch (typeof e.tag == "number" && console.error(
|
|
69
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
70
|
+
), e.$$typeof) {
|
|
71
|
+
case S:
|
|
72
|
+
return "Portal";
|
|
73
|
+
case P:
|
|
74
|
+
return (e.displayName || "Context") + ".Provider";
|
|
75
|
+
case D:
|
|
76
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
77
|
+
case N:
|
|
78
|
+
var t = e.render;
|
|
79
|
+
return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
80
|
+
case oe:
|
|
81
|
+
return t = e.displayName || null, t !== null ? t : r(e.type) || "Memo";
|
|
82
|
+
case z:
|
|
83
|
+
t = e._payload, e = e._init;
|
|
84
|
+
try {
|
|
85
|
+
return r(e(t));
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
function s(e) {
|
|
92
|
+
return "" + e;
|
|
93
|
+
}
|
|
94
|
+
function n(e) {
|
|
95
|
+
try {
|
|
96
|
+
s(e);
|
|
97
|
+
var t = !1;
|
|
98
|
+
} catch {
|
|
99
|
+
t = !0;
|
|
100
|
+
}
|
|
101
|
+
if (t) {
|
|
102
|
+
t = console;
|
|
103
|
+
var u = t.error, c = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
104
|
+
return u.call(
|
|
105
|
+
t,
|
|
106
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
107
|
+
c
|
|
108
|
+
), s(e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function a(e) {
|
|
112
|
+
if (e === y) return "<>";
|
|
113
|
+
if (typeof e == "object" && e !== null && e.$$typeof === z)
|
|
114
|
+
return "<...>";
|
|
115
|
+
try {
|
|
116
|
+
var t = r(e);
|
|
117
|
+
return t ? "<" + t + ">" : "<...>";
|
|
118
|
+
} catch {
|
|
119
|
+
return "<...>";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function o() {
|
|
123
|
+
var e = W.A;
|
|
124
|
+
return e === null ? null : e.getOwner();
|
|
125
|
+
}
|
|
126
|
+
function l() {
|
|
127
|
+
return Error("react-stack-top-frame");
|
|
128
|
+
}
|
|
129
|
+
function d(e) {
|
|
130
|
+
if (J.call(e, "key")) {
|
|
131
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
132
|
+
if (t && t.isReactWarning) return !1;
|
|
133
|
+
}
|
|
134
|
+
return e.key !== void 0;
|
|
135
|
+
}
|
|
136
|
+
function m(e, t) {
|
|
137
|
+
function u() {
|
|
138
|
+
V || (V = !0, console.error(
|
|
139
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
140
|
+
t
|
|
141
|
+
));
|
|
142
|
+
}
|
|
143
|
+
u.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
144
|
+
get: u,
|
|
145
|
+
configurable: !0
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function g() {
|
|
149
|
+
var e = r(this.type);
|
|
150
|
+
return q[e] || (q[e] = !0, console.error(
|
|
151
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
152
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
153
|
+
}
|
|
154
|
+
function f(e, t, u, c, E, b, L, U) {
|
|
155
|
+
return u = b.ref, e = {
|
|
156
|
+
$$typeof: v,
|
|
157
|
+
type: e,
|
|
158
|
+
key: t,
|
|
159
|
+
props: b,
|
|
160
|
+
_owner: E
|
|
161
|
+
}, (u !== void 0 ? u : null) !== null ? Object.defineProperty(e, "ref", {
|
|
162
|
+
enumerable: !1,
|
|
163
|
+
get: g
|
|
164
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
165
|
+
configurable: !1,
|
|
166
|
+
enumerable: !1,
|
|
167
|
+
writable: !0,
|
|
168
|
+
value: 0
|
|
169
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
170
|
+
configurable: !1,
|
|
171
|
+
enumerable: !1,
|
|
172
|
+
writable: !0,
|
|
173
|
+
value: null
|
|
174
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
175
|
+
configurable: !1,
|
|
176
|
+
enumerable: !1,
|
|
177
|
+
writable: !0,
|
|
178
|
+
value: L
|
|
179
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
180
|
+
configurable: !1,
|
|
181
|
+
enumerable: !1,
|
|
182
|
+
writable: !0,
|
|
183
|
+
value: U
|
|
184
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
185
|
+
}
|
|
186
|
+
function x(e, t, u, c, E, b, L, U) {
|
|
187
|
+
var i = t.children;
|
|
188
|
+
if (i !== void 0)
|
|
189
|
+
if (c)
|
|
190
|
+
if (le(i)) {
|
|
191
|
+
for (c = 0; c < i.length; c++)
|
|
192
|
+
w(i[c]);
|
|
193
|
+
Object.freeze && Object.freeze(i);
|
|
194
|
+
} else
|
|
195
|
+
console.error(
|
|
196
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
|
+
);
|
|
198
|
+
else w(i);
|
|
199
|
+
if (J.call(t, "key")) {
|
|
200
|
+
i = r(e);
|
|
201
|
+
var p = Object.keys(t).filter(function(ce) {
|
|
202
|
+
return ce !== "key";
|
|
203
|
+
});
|
|
204
|
+
c = 0 < p.length ? "{key: someKey, " + p.join(": ..., ") + ": ...}" : "{key: someKey}", B[i + c] || (p = 0 < p.length ? "{" + p.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
206
|
+
let props = %s;
|
|
207
|
+
<%s {...props} />
|
|
208
|
+
React keys must be passed directly to JSX without using spread:
|
|
209
|
+
let props = %s;
|
|
210
|
+
<%s key={someKey} {...props} />`,
|
|
211
|
+
c,
|
|
212
|
+
i,
|
|
213
|
+
p,
|
|
214
|
+
i
|
|
215
|
+
), B[i + c] = !0);
|
|
216
|
+
}
|
|
217
|
+
if (i = null, u !== void 0 && (n(u), i = "" + u), d(t) && (n(t.key), i = "" + t.key), "key" in t) {
|
|
218
|
+
u = {};
|
|
219
|
+
for (var M in t)
|
|
220
|
+
M !== "key" && (u[M] = t[M]);
|
|
221
|
+
} else u = t;
|
|
222
|
+
return i && m(
|
|
223
|
+
u,
|
|
224
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
225
|
+
), f(
|
|
226
|
+
e,
|
|
227
|
+
i,
|
|
228
|
+
b,
|
|
229
|
+
E,
|
|
230
|
+
o(),
|
|
231
|
+
u,
|
|
232
|
+
L,
|
|
233
|
+
U
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
function w(e) {
|
|
237
|
+
typeof e == "object" && e !== null && e.$$typeof === v && e._store && (e._store.validated = 1);
|
|
238
|
+
}
|
|
239
|
+
var _ = T, v = Symbol.for("react.transitional.element"), S = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), I = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), D = Symbol.for("react.consumer"), P = Symbol.for("react.context"), N = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), k = Symbol.for("react.suspense_list"), oe = Symbol.for("react.memo"), z = Symbol.for("react.lazy"), se = Symbol.for("react.activity"), ue = Symbol.for("react.client.reference"), W = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, le = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
240
|
+
return null;
|
|
241
|
+
};
|
|
242
|
+
_ = {
|
|
243
|
+
"react-stack-bottom-frame": function(e) {
|
|
244
|
+
return e();
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
var V, q = {}, G = _["react-stack-bottom-frame"].bind(
|
|
248
|
+
_,
|
|
249
|
+
l
|
|
250
|
+
)(), X = $(a(l)), B = {};
|
|
251
|
+
A.Fragment = y, A.jsx = function(e, t, u, c, E) {
|
|
252
|
+
var b = 1e4 > W.recentlyCreatedOwnerStacks++;
|
|
253
|
+
return x(
|
|
254
|
+
e,
|
|
255
|
+
t,
|
|
256
|
+
u,
|
|
257
|
+
!1,
|
|
258
|
+
c,
|
|
259
|
+
E,
|
|
260
|
+
b ? Error("react-stack-top-frame") : G,
|
|
261
|
+
b ? $(a(e)) : X
|
|
262
|
+
);
|
|
263
|
+
}, A.jsxs = function(e, t, u, c, E) {
|
|
264
|
+
var b = 1e4 > W.recentlyCreatedOwnerStacks++;
|
|
265
|
+
return x(
|
|
266
|
+
e,
|
|
267
|
+
t,
|
|
268
|
+
u,
|
|
269
|
+
!0,
|
|
270
|
+
c,
|
|
271
|
+
E,
|
|
272
|
+
b ? Error("react-stack-top-frame") : G,
|
|
273
|
+
b ? $(a(e)) : X
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
}()), A;
|
|
277
|
+
}
|
|
278
|
+
var Q;
|
|
279
|
+
function de() {
|
|
280
|
+
return Q || (Q = 1, process.env.NODE_ENV === "production" ? F.exports = ie() : F.exports = fe()), F.exports;
|
|
281
|
+
}
|
|
282
|
+
var R = de();
|
|
283
|
+
function re(r) {
|
|
284
|
+
var s, n, a = "";
|
|
285
|
+
if (typeof r == "string" || typeof r == "number") a += r;
|
|
286
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
287
|
+
var o = r.length;
|
|
288
|
+
for (s = 0; s < o; s++) r[s] && (n = re(r[s])) && (a && (a += " "), a += n);
|
|
289
|
+
} else for (n in r) r[n] && (a && (a += " "), a += n);
|
|
290
|
+
return a;
|
|
291
|
+
}
|
|
292
|
+
function me() {
|
|
293
|
+
for (var r, s, n = 0, a = "", o = arguments.length; n < o; n++) (r = arguments[n]) && (s = re(r)) && (a && (a += " "), a += s);
|
|
294
|
+
return a;
|
|
295
|
+
}
|
|
296
|
+
function O(...r) {
|
|
297
|
+
return me(...r);
|
|
298
|
+
}
|
|
299
|
+
const Ae = ({
|
|
300
|
+
children: r,
|
|
301
|
+
variant: s = "default",
|
|
302
|
+
className: n = "",
|
|
303
|
+
...a
|
|
304
|
+
}) => {
|
|
305
|
+
const o = "px-4 py-2 rounded font-medium transition", l = {
|
|
306
|
+
default: "bg-blue-600 text-white hover:bg-blue-700",
|
|
307
|
+
outline: "border border-blue-600 text-blue-600 bg-white hover:bg-blue-50"
|
|
308
|
+
};
|
|
309
|
+
return /* @__PURE__ */ R.jsx("button", { className: O(o, l[s], n), ...a, children: r });
|
|
310
|
+
};
|
|
311
|
+
var be = (r) => r instanceof Date, te = (r) => r == null;
|
|
312
|
+
const ve = (r) => typeof r == "object";
|
|
313
|
+
var Ee = (r) => !te(r) && !Array.isArray(r) && ve(r) && !be(r), _e = (r) => /^\w*$/.test(r), K = (r) => r === void 0, Re = (r) => Array.isArray(r) ? r.filter(Boolean) : [], xe = (r) => Re(r.replace(/["|']|\]/g, "").split(/\.|\[/)), ee = (r, s, n) => {
|
|
314
|
+
if (!s || !Ee(r))
|
|
315
|
+
return n;
|
|
316
|
+
const a = (_e(s) ? [s] : xe(s)).reduce((o, l) => te(o) ? o : o[l], r);
|
|
317
|
+
return K(a) || a === r ? K(r[s]) ? n : r[s] : a;
|
|
318
|
+
};
|
|
319
|
+
const ne = T.createContext(null);
|
|
320
|
+
ne.displayName = "HookFormContext";
|
|
321
|
+
const ae = () => T.useContext(ne), pe = typeof window < "u" ? Y.useLayoutEffect : Y.useEffect;
|
|
322
|
+
var Te = (r) => typeof r == "string", ge = (r, s, n, a, o) => Te(r) ? ee(n, r, o) : Array.isArray(r) ? r.map((l) => ee(n, l)) : n;
|
|
323
|
+
function ye(r) {
|
|
324
|
+
const s = ae(), { control: n = s.control, name: a, defaultValue: o, disabled: l, exact: d } = r || {}, m = T.useRef(o), [g, f] = T.useState(n._getWatch(a, m.current));
|
|
325
|
+
return pe(() => n._subscribe({
|
|
326
|
+
name: a,
|
|
327
|
+
formState: {
|
|
328
|
+
values: !0
|
|
329
|
+
},
|
|
330
|
+
exact: d,
|
|
331
|
+
callback: (x) => !l && f(ge(a, n._names, x.values || n._formValues, !1, m.current))
|
|
332
|
+
}), [a, n, l, d]), T.useEffect(() => n._removeUnmounted()), g;
|
|
333
|
+
}
|
|
334
|
+
const ke = Y.forwardRef(
|
|
335
|
+
({
|
|
336
|
+
className: r,
|
|
337
|
+
type: s = "text",
|
|
338
|
+
label: n,
|
|
339
|
+
onFocus: a,
|
|
340
|
+
onBlur: o,
|
|
341
|
+
Icon: l,
|
|
342
|
+
iconClassName: d,
|
|
343
|
+
iconAction: m,
|
|
344
|
+
containerClassName: g,
|
|
345
|
+
...f
|
|
346
|
+
}, x) => {
|
|
347
|
+
var P, N, C;
|
|
348
|
+
const [w, _] = Y.useState(!1), v = ae(), S = v == null ? void 0 : v.control, y = S && f.name ? ye({ control: S, name: String(f.name) }) : void 0, I = f.value ?? y ?? "", j = (C = (N = (P = v == null ? void 0 : v.formState) == null ? void 0 : P.errors) == null ? void 0 : N[f.name]) == null ? void 0 : C.message, D = w || !!I;
|
|
349
|
+
return /* @__PURE__ */ R.jsxs("div", { className: O("relative", g), children: [
|
|
350
|
+
/* @__PURE__ */ R.jsx(
|
|
351
|
+
"input",
|
|
352
|
+
{
|
|
353
|
+
id: f.id || f.name,
|
|
354
|
+
type: s,
|
|
355
|
+
className: O(
|
|
356
|
+
"peer flex h-12 w-full border border-input rounded-md bg-transparent px-3 pt-6 pb-2 text-sm text-white placeholder-transparent transition focus:outline-none focus:border-blue-500 disabled:cursor-not-allowed disabled:opacity-50",
|
|
357
|
+
r
|
|
358
|
+
),
|
|
359
|
+
onFocus: (k) => {
|
|
360
|
+
_(!0), a && a(k);
|
|
361
|
+
},
|
|
362
|
+
onBlur: (k) => {
|
|
363
|
+
_(!1), o && o(k);
|
|
364
|
+
},
|
|
365
|
+
ref: x,
|
|
366
|
+
...f
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
n && /* @__PURE__ */ R.jsx(
|
|
370
|
+
"label",
|
|
371
|
+
{
|
|
372
|
+
htmlFor: f.id || f.name,
|
|
373
|
+
className: O(
|
|
374
|
+
"absolute left-3 top-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",
|
|
375
|
+
D ? "scale-90 -translate-y-3 text-xs text-blue-400" : "scale-100 translate-y-0"
|
|
376
|
+
),
|
|
377
|
+
children: n
|
|
378
|
+
}
|
|
379
|
+
),
|
|
380
|
+
l && /* @__PURE__ */ R.jsx(
|
|
381
|
+
"div",
|
|
382
|
+
{
|
|
383
|
+
className: O(
|
|
384
|
+
"absolute top-1/2 right-3 -translate-y-1/2 text-white",
|
|
385
|
+
d
|
|
386
|
+
),
|
|
387
|
+
onClick: m,
|
|
388
|
+
children: /* @__PURE__ */ R.jsx(l, {})
|
|
389
|
+
}
|
|
390
|
+
),
|
|
391
|
+
j && /* @__PURE__ */ R.jsx("span", { className: "text-red-500 text-xs mt-1 block", children: j })
|
|
392
|
+
] });
|
|
393
|
+
}
|
|
394
|
+
);
|
|
395
|
+
ke.displayName = "Input";
|
|
396
|
+
export {
|
|
397
|
+
Ae as Button,
|
|
398
|
+
ke as Input
|
|
399
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
}
|
|
4
|
+
export interface CustomProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
Icon?: React.ElementType;
|
|
7
|
+
iconClassName?: string;
|
|
8
|
+
containerClassName?: string;
|
|
9
|
+
iconAction?: React.MouseEventHandler<HTMLDivElement>;
|
|
10
|
+
}
|
|
11
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & CustomProps & React.RefAttributes<HTMLInputElement>>;
|
|
12
|
+
export { Input };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Button } from "../components/Button";
|
|
3
|
+
declare const meta: Meta<typeof Button>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Button>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Outline: Story;
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rharuow-ds",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
|
+
"build": "vite build && tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
8
|
+
"storybook": "storybook dev -p 6006",
|
|
9
|
+
"build-storybook": "storybook build"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"description": "",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"clsx": "^2.1.1",
|
|
17
|
+
"react": "^19.1.0",
|
|
18
|
+
"react-dom": "^19.1.0",
|
|
19
|
+
"react-hook-form": "^7.59.0",
|
|
20
|
+
"shadcn-ui": "^0.9.5"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@storybook/react-vite": "^9.0.14",
|
|
24
|
+
"@types/react": "^19.1.8",
|
|
25
|
+
"@types/react-dom": "^19.1.6",
|
|
26
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
27
|
+
"autoprefixer": "^10.4.21",
|
|
28
|
+
"postcss": "^8.5.6",
|
|
29
|
+
"storybook": "^9.0.14",
|
|
30
|
+
"tailwindcss": "^3.4.3",
|
|
31
|
+
"typescript": "^5.8.3"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"src",
|
|
36
|
+
"package.json",
|
|
37
|
+
"README.md"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../lib/utils";
|
|
3
|
+
|
|
4
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
variant?: "default" | "outline";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const Button: React.FC<ButtonProps> = ({
|
|
9
|
+
children,
|
|
10
|
+
variant = "default",
|
|
11
|
+
className = "",
|
|
12
|
+
...props
|
|
13
|
+
}) => {
|
|
14
|
+
const base = "px-4 py-2 rounded font-medium transition";
|
|
15
|
+
const variants = {
|
|
16
|
+
default: "bg-blue-600 text-white hover:bg-blue-700",
|
|
17
|
+
outline: "border border-blue-600 text-blue-600 bg-white hover:bg-blue-50",
|
|
18
|
+
};
|
|
19
|
+
return (
|
|
20
|
+
<button className={cn(base, variants[variant], className)} {...props}>
|
|
21
|
+
{children}
|
|
22
|
+
</button>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
6
|
+
|
|
7
|
+
export interface InputProps
|
|
8
|
+
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
9
|
+
|
|
10
|
+
export interface CustomProps {
|
|
11
|
+
label?: string;
|
|
12
|
+
Icon?: React.ElementType;
|
|
13
|
+
iconClassName?: string;
|
|
14
|
+
containerClassName?: string;
|
|
15
|
+
iconAction?: React.MouseEventHandler<HTMLDivElement>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Input = React.forwardRef<HTMLInputElement, InputProps & CustomProps>(
|
|
19
|
+
(
|
|
20
|
+
{
|
|
21
|
+
className,
|
|
22
|
+
type = "text",
|
|
23
|
+
label,
|
|
24
|
+
onFocus,
|
|
25
|
+
onBlur,
|
|
26
|
+
Icon,
|
|
27
|
+
iconClassName,
|
|
28
|
+
iconAction,
|
|
29
|
+
containerClassName,
|
|
30
|
+
...props
|
|
31
|
+
},
|
|
32
|
+
ref
|
|
33
|
+
) => {
|
|
34
|
+
const [focused, setFocused] = React.useState(false);
|
|
35
|
+
|
|
36
|
+
const form = useFormContext();
|
|
37
|
+
const control = form?.control;
|
|
38
|
+
const valueWatch =
|
|
39
|
+
control && props.name
|
|
40
|
+
? useWatch({ control, name: String(props.name) })
|
|
41
|
+
: undefined;
|
|
42
|
+
|
|
43
|
+
const value = props.value ?? valueWatch ?? "";
|
|
44
|
+
const error = form?.formState?.errors?.[props.name as string]?.message;
|
|
45
|
+
|
|
46
|
+
// Floating label: label sobe se input está focado ou tem valor
|
|
47
|
+
const isFloating = focused || !!value;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className={cn("relative", containerClassName)}>
|
|
51
|
+
<input
|
|
52
|
+
id={props.id || props.name}
|
|
53
|
+
type={type}
|
|
54
|
+
className={cn(
|
|
55
|
+
"peer flex h-12 w-full border border-input rounded-md bg-transparent px-3 pt-6 pb-2 text-sm text-white placeholder-transparent transition focus:outline-none focus:border-blue-500 disabled:cursor-not-allowed disabled:opacity-50",
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
onFocus={(event) => {
|
|
59
|
+
setFocused(true);
|
|
60
|
+
onFocus && onFocus(event);
|
|
61
|
+
}}
|
|
62
|
+
onBlur={(event) => {
|
|
63
|
+
setFocused(false);
|
|
64
|
+
onBlur && onBlur(event);
|
|
65
|
+
}}
|
|
66
|
+
ref={ref}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
{label && (
|
|
70
|
+
<label
|
|
71
|
+
htmlFor={props.id || props.name}
|
|
72
|
+
className={cn(
|
|
73
|
+
"absolute left-3 top-3 z-10 origin-[0] cursor-text select-none text-sm text-gray-400 transition-all duration-200",
|
|
74
|
+
isFloating
|
|
75
|
+
? "scale-90 -translate-y-3 text-xs text-blue-400"
|
|
76
|
+
: "scale-100 translate-y-0"
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
79
|
+
{label}
|
|
80
|
+
</label>
|
|
81
|
+
)}
|
|
82
|
+
{Icon && (
|
|
83
|
+
<div
|
|
84
|
+
className={cn(
|
|
85
|
+
"absolute top-1/2 right-3 -translate-y-1/2 text-white",
|
|
86
|
+
iconClassName
|
|
87
|
+
)}
|
|
88
|
+
onClick={iconAction}
|
|
89
|
+
>
|
|
90
|
+
<Icon />
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
{error && (
|
|
94
|
+
<span className="text-red-500 text-xs mt-1 block">
|
|
95
|
+
{error as string}
|
|
96
|
+
</span>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
Input.displayName = "Input";
|
|
103
|
+
|
|
104
|
+
export { Input };
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Button } from "../components/Button";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Button> = {
|
|
5
|
+
title: "Components/Button",
|
|
6
|
+
component: Button,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof Button>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
children: "Botão padrão",
|
|
16
|
+
variant: "default",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Outline: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
children: "Botão outline",
|
|
23
|
+
variant: "outline",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Input } from "../components/Input";
|
|
3
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Input> = {
|
|
6
|
+
title: "Components/Input",
|
|
7
|
+
component: Input,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof Input>;
|
|
13
|
+
|
|
14
|
+
const Template = (args: any) => {
|
|
15
|
+
const methods = useForm();
|
|
16
|
+
return (
|
|
17
|
+
<FormProvider {...methods}>
|
|
18
|
+
<Input {...args} name="email" />
|
|
19
|
+
</FormProvider>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const Default: Story = {
|
|
24
|
+
render: Template,
|
|
25
|
+
args: {
|
|
26
|
+
label: "E-mail",
|
|
27
|
+
placeholder: "Digite seu e-mail",
|
|
28
|
+
},
|
|
29
|
+
};
|