@mobilestockweb/form 1.0.3 → 1.0.5
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/index.d.ts +47 -0
- package/index.js +1 -1
- package/package.json +5 -5
package/index.d.ts
CHANGED
|
@@ -45,7 +45,14 @@ type EventOnChangeRemoveFile = {
|
|
|
45
45
|
};
|
|
46
46
|
interface MultipleArchiveProps extends Omit<MultipleArchiveProviderProps, 'children' | 'accept'> {
|
|
47
47
|
children?: React.ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* @description Accepted file types. Can be an array of TypeFiles enum values or a string in the same format as the HTML input accept attribute.
|
|
50
|
+
*/
|
|
48
51
|
accept?: (keyof typeof TypeFiles)[] | string;
|
|
52
|
+
/**
|
|
53
|
+
* @default 'START'
|
|
54
|
+
* @description Alignment of the label text.
|
|
55
|
+
*/
|
|
49
56
|
alignLabel?: 'END' | 'CENTER' | 'START';
|
|
50
57
|
label?: string;
|
|
51
58
|
}
|
|
@@ -92,10 +99,30 @@ interface CounterRootProps {
|
|
|
92
99
|
minCount?: number;
|
|
93
100
|
label?: string;
|
|
94
101
|
name: string;
|
|
102
|
+
/**
|
|
103
|
+
* @default false
|
|
104
|
+
* @description if true, the Display component will be editable, allowing the user to type a number directly into it.
|
|
105
|
+
*/
|
|
95
106
|
editable?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* @default 1
|
|
109
|
+
* @description The value by which the counter increments or decrements when the buttons are pressed in long press mode.
|
|
110
|
+
*/
|
|
96
111
|
multiplier?: number;
|
|
112
|
+
/**
|
|
113
|
+
* @default 'TOP_START'
|
|
114
|
+
* @description Position of the label relative to the counter.
|
|
115
|
+
*/
|
|
97
116
|
labelPosition?: 'TOP_START' | 'LEFT' | 'TOP_CENTER';
|
|
117
|
+
/**
|
|
118
|
+
* @default false
|
|
119
|
+
* @description If true, the buttons will have a transparent background.
|
|
120
|
+
*/
|
|
98
121
|
buttonTransparent?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* @default false
|
|
124
|
+
* @description If true, the counter elements (buttons and display) will be grouped together.
|
|
125
|
+
*/
|
|
99
126
|
groupElements?: boolean;
|
|
100
127
|
onChange?(data: {
|
|
101
128
|
value: number;
|
|
@@ -131,7 +158,15 @@ type TypeEventOnChange = EventOnChangeRemoveImage | EventOnChangeReorderImages |
|
|
|
131
158
|
type PhotoListProviderProps<TypeEventOnChangeGeneric extends TypeEventOnChange = TypeEventOnChange> = {
|
|
132
159
|
children: ReactNode;
|
|
133
160
|
onChange?(event: TypeEventOnChangeGeneric): void;
|
|
161
|
+
/**
|
|
162
|
+
* @default true
|
|
163
|
+
* @description Allows selection of multiple images.
|
|
164
|
+
*/
|
|
134
165
|
multiple?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* @default true
|
|
168
|
+
* @description Enables drag and drop functionality for reordering images.
|
|
169
|
+
*/
|
|
135
170
|
dragAndDrop?: boolean;
|
|
136
171
|
buttonAddDirection?: 'LEFT' | 'RIGHT';
|
|
137
172
|
name: string;
|
|
@@ -153,8 +188,20 @@ type EventOnChangeCropSave = {
|
|
|
153
188
|
};
|
|
154
189
|
interface PhotoInputProps extends Omit<PhotoListProviderProps, 'children'> {
|
|
155
190
|
label?: string;
|
|
191
|
+
/**
|
|
192
|
+
* @default 'START'
|
|
193
|
+
* @description Alignment of the label text.
|
|
194
|
+
*/
|
|
156
195
|
alignLabel?: 'END' | 'CENTER' | 'START';
|
|
196
|
+
/**
|
|
197
|
+
* @default 'LEFT'
|
|
198
|
+
* @description Direction of the add button.
|
|
199
|
+
*/
|
|
157
200
|
buttonAddDirection?: 'LEFT' | 'RIGHT';
|
|
201
|
+
/**
|
|
202
|
+
* @default 0
|
|
203
|
+
* @description Number of images visible in the viewport.
|
|
204
|
+
*/
|
|
158
205
|
numberOfImagesVisible?: number;
|
|
159
206
|
}
|
|
160
207
|
declare function FormPhotoList({ label, alignLabel, buttonAddDirection, numberOfImagesVisible, ...props }: PhotoInputProps): react_jsx_runtime.JSX.Element;
|
package/index.js
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
text-align: center;
|
|
43
43
|
width: 40px;
|
|
44
44
|
height: 34px;
|
|
45
|
-
`;he.displayName="Form.FormCounter.Display";var R=require("react/jsx-runtime");function Kt(){let{label:e,labelPosition:t,error:o}=U();return(0,R.jsxs)(re.Container.Vertical,{align:"CENTER_START",children:[t==="TOP_START"&&e&&(0,R.jsxs)(re.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,R.jsx)(oe,{children:e}),o&&(0,R.jsx)(Y,{children:o})]}),t!=="LEFT"&&(0,R.jsxs)(re.Container.Vertical,{align:"CENTER",children:[t!=="TOP_START"&&(e||o)&&(0,R.jsxs)(re.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,R.jsx)(oe,{children:e}),o&&(0,R.jsx)(Y,{children:o})]}),(0,R.jsxs)(ge,{children:[(0,R.jsx)(Q,{type:"MINUS"}),(0,R.jsx)(he,{}),(0,R.jsx)(Q,{type:"PLUS"})]})]}),t==="LEFT"&&(0,R.jsx)(re.Container.Vertical,{children:(0,R.jsxs)(re.Container.Horizontal,{align:"CENTER",children:[(e||o)&&(0,R.jsxs)(re.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,R.jsx)(oe,{children:e}),o&&(0,R.jsx)(Y,{children:o})]}),(0,R.jsxs)(ge,{children:[(0,R.jsx)(Q,{type:"MINUS"}),(0,R.jsx)(he,{}),(0,R.jsx)(Q,{type:"PLUS"})]})]})})]})}var Ne=require("react/jsx-runtime");function Zt(o){var n=o,{children:e}=n,t=P(n,["children"]);return(0,Ne.jsx)(xt,v(h({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},t),{children:e?(0,Ne.jsx)(Ut,{children:e}):(0,Ne.jsx)(Kt,{})}))}var Yt=require("react/jsx-runtime");function Ke(e){return(0,Yt.jsx)(Q,v(h({},e),{type:"MINUS"}))}Ke.displayName="Form.FormCounter.Minus";var Jt=require("react/jsx-runtime");function Ze(e){return(0,Jt.jsx)(Q,v(h({},e),{type:"PLUS"}))}Ze.displayName="Form.FormCounter.Plus";var Qt=Object.assign(Zt,{Display:he,Plus:Ze,Minus:Ke,Badge:Fe});var jt=require("@mobilestockweb/container");var to=require("react/jsx-runtime");function eo(o){var n=o,{children:e}=n,t=P(n,["children"]);return(0,to.jsx)(jt.Container.Horizontal,v(h({gap:"SM"},t),{children:e}))}var oo=require("@unform/core"),O=require("react"),Pe=I(require("styled-components")),ro=require("@mobilestockweb/button"),Je=require("@mobilestockweb/container"),Ye=I(require("@mobilestockweb/tools")),Qe=require("@mobilestockweb/typography");var ne=require("react/jsx-runtime"),no=(0,O.forwardRef)(function(s,b){var m=s,{name:t,label:o,defaultValue:n,type:r,autoSubmit:u,full:i,error:l,format:a,onChange:g,maxLength:c}=m,p=P(m,["name","label","defaultValue","type","autoSubmit","full","error","format","onChange","maxLength"]);let{loading:E}=k(),C=(0,oo.useField)(t),d=(0,O.useRef)(null),[F,L]=(0,O.useState)(!1),[y,S]=(0,O.useState)(""),B=r==="password",N=r==="tel"?15:r==="zipcode"?9:c,$=t+"-input"+(0,O.useId)();(0,O.useEffect)(()=>{let f=y||n||(C==null?void 0:C.defaultValue)||"";d.current.value=f,S(f),C.registerField({name:C.fieldName,ref:d,getValue:T=>{var W;return((W=T.current)==null?void 0:W.value)||""},setValue:(T,W)=>{T.current&&(T.current.value=W,S(W))},clearValue:T=>{T.current&&(T.current.value="",S(""))}})},[C==null?void 0:C.fieldName,C==null?void 0:C.registerField]),(0,O.useImperativeHandle)(b,()=>({focus(){var f;(f=d.current)==null||f.focus()},blur(){var f;(f=d.current)==null||f.blur()}}));let ee=(0,O.useCallback)(f=>{let T=f.target.value;switch(r){case"tel":T=Ye.default.phoneNumberFormatter(T);break;case"email":case"url":T=T.trim();break;case"zipcode":T=Ye.default.formatZipcode(T);break}a&&(T=a(T)),S(T),f.target.value=T,d.current.value=T,g==null||g(f),r==="tel"&&u&&T.length===15&&d.current.form&&(d.current.form.requestSubmit(),d.current.blur()),r==="zipcode"&&u&&T.length===9&&d.current.form&&(d.current.form.requestSubmit(),d.current.blur())},[r,a,u,g,C]);function fe(){return r==="password"?F?"text":"password":r}return(0,ne.jsxs)(Kr,{full:i,$show:r!=="hidden",children:[o&&(0,ne.jsx)(Zr,{htmlFor:$,size:"SM",children:o}),(0,ne.jsxs)(Yr,{align:"CENTER",padding:"XS_NONE",gap:"SM",$isError:!!(C!=null&&C.error),$isPassword:B,children:[(0,ne.jsx)(Jr,v(h({},p),{ref:d,id:$,value:y,onChange:ee,maxLength:N,type:fe(),disabled:E||p.disabled})),B&&(0,ne.jsx)(ro.Button,{size:"SM",onClick:()=>L(!F),icon:F?"EyeOutline":"EyeOff",variant:"TRANSPARENT",type:"button"})]})
|
|
45
|
+
`;he.displayName="Form.FormCounter.Display";var R=require("react/jsx-runtime");function Kt(){let{label:e,labelPosition:t,error:o}=U();return(0,R.jsxs)(re.Container.Vertical,{align:"CENTER_START",children:[t==="TOP_START"&&e&&(0,R.jsxs)(re.Container.Horizontal,{padding:"NONE_NONE_2XS_NONE",gap:"2XS",children:[(0,R.jsx)(oe,{children:e}),o&&(0,R.jsx)(Y,{children:o})]}),t!=="LEFT"&&(0,R.jsxs)(re.Container.Vertical,{align:"CENTER",children:[t!=="TOP_START"&&(e||o)&&(0,R.jsxs)(re.Container.Vertical,{align:"CENTER",padding:"NONE_NONE_2XS_NONE",children:[e&&(0,R.jsx)(oe,{children:e}),o&&(0,R.jsx)(Y,{children:o})]}),(0,R.jsxs)(ge,{children:[(0,R.jsx)(Q,{type:"MINUS"}),(0,R.jsx)(he,{}),(0,R.jsx)(Q,{type:"PLUS"})]})]}),t==="LEFT"&&(0,R.jsx)(re.Container.Vertical,{children:(0,R.jsxs)(re.Container.Horizontal,{align:"CENTER",children:[(e||o)&&(0,R.jsxs)(re.Container.Vertical,{padding:"NONE_2XS_NONE_NONE",children:[e&&(0,R.jsx)(oe,{children:e}),o&&(0,R.jsx)(Y,{children:o})]}),(0,R.jsxs)(ge,{children:[(0,R.jsx)(Q,{type:"MINUS"}),(0,R.jsx)(he,{}),(0,R.jsx)(Q,{type:"PLUS"})]})]})})]})}var Ne=require("react/jsx-runtime");function Zt(o){var n=o,{children:e}=n,t=P(n,["children"]);return(0,Ne.jsx)(xt,v(h({buttonTransparent:!1,labelPosition:"TOP_START",multiplier:1},t),{children:e?(0,Ne.jsx)(Ut,{children:e}):(0,Ne.jsx)(Kt,{})}))}var Yt=require("react/jsx-runtime");function Ke(e){return(0,Yt.jsx)(Q,v(h({},e),{type:"MINUS"}))}Ke.displayName="Form.FormCounter.Minus";var Jt=require("react/jsx-runtime");function Ze(e){return(0,Jt.jsx)(Q,v(h({},e),{type:"PLUS"}))}Ze.displayName="Form.FormCounter.Plus";var Qt=Object.assign(Zt,{Display:he,Plus:Ze,Minus:Ke,Badge:Fe});var jt=require("@mobilestockweb/container");var to=require("react/jsx-runtime");function eo(o){var n=o,{children:e}=n,t=P(n,["children"]);return(0,to.jsx)(jt.Container.Horizontal,v(h({gap:"SM"},t),{children:e}))}var oo=require("@unform/core"),O=require("react"),Pe=I(require("styled-components")),ro=require("@mobilestockweb/button"),Je=require("@mobilestockweb/container"),Ye=I(require("@mobilestockweb/tools")),Qe=require("@mobilestockweb/typography");var ne=require("react/jsx-runtime"),no=(0,O.forwardRef)(function(s,b){var m=s,{name:t,label:o,defaultValue:n,type:r,autoSubmit:u,full:i,error:l,format:a,onChange:g,maxLength:c}=m,p=P(m,["name","label","defaultValue","type","autoSubmit","full","error","format","onChange","maxLength"]);let{loading:E}=k(),C=(0,oo.useField)(t),d=(0,O.useRef)(null),[F,L]=(0,O.useState)(!1),[y,S]=(0,O.useState)(""),B=r==="password",N=r==="tel"?15:r==="zipcode"?9:c,$=t+"-input"+(0,O.useId)();(0,O.useEffect)(()=>{let f=y||n||(C==null?void 0:C.defaultValue)||"";d.current.value=f,S(f),C.registerField({name:C.fieldName,ref:d,getValue:T=>{var W;return((W=T.current)==null?void 0:W.value)||""},setValue:(T,W)=>{T.current&&(T.current.value=W,S(W))},clearValue:T=>{T.current&&(T.current.value="",S(""))}})},[C==null?void 0:C.fieldName,C==null?void 0:C.registerField]),(0,O.useImperativeHandle)(b,()=>({focus(){var f;(f=d.current)==null||f.focus()},blur(){var f;(f=d.current)==null||f.blur()}}));let ee=(0,O.useCallback)(f=>{let T=f.target.value;switch(r){case"tel":T=Ye.default.phoneNumberFormatter(T);break;case"email":case"url":T=T.trim();break;case"zipcode":T=Ye.default.formatZipcode(T);break}a&&(T=a(T)),S(T),f.target.value=T,d.current.value=T,g==null||g(f),r==="tel"&&u&&T.length===15&&d.current.form&&(d.current.form.requestSubmit(),d.current.blur()),r==="zipcode"&&u&&T.length===9&&d.current.form&&(d.current.form.requestSubmit(),d.current.blur())},[r,a,u,g,C]);function fe(){return r==="password"?F?"text":"password":r}return(0,ne.jsxs)(Kr,{full:i,$show:r!=="hidden",children:[o&&(0,ne.jsx)(Zr,{htmlFor:$,size:"SM",children:o}),(0,ne.jsxs)(Yr,{align:"CENTER",padding:"XS_NONE",gap:"SM",$isError:!!(C!=null&&C.error),$isPassword:B,children:[(0,ne.jsx)(Jr,v(h({},p),{ref:d,id:$,value:y,onChange:ee,maxLength:N,type:fe(),disabled:E||p.disabled})),B&&(0,ne.jsx)(ro.Button,{size:"SM",onClick:()=>L(!F),icon:F?"EyeOutline":"EyeOff",variant:"TRANSPARENT",type:"button"})]}),!!(C!=null&&C.error)&&(0,ne.jsx)(Qe.Typography,{color:"DANGER",size:"SM",children:C==null?void 0:C.error})]})}),Kr=(0,Pe.default)(Je.Container.Vertical)`
|
|
46
46
|
display: ${({$show:e})=>e?"flex":"none"};
|
|
47
47
|
`,Zr=(0,Pe.default)(Qe.Typography).attrs({forwardedAs:"label"})``,Yr=(0,Pe.default)(Je.Container.Horizontal)`
|
|
48
48
|
padding: ${({$isPassword:e})=>e?"0 0 0 10px":"0 10px"};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilestockweb/form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"notistack": "^3.0.1",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"ua-parser-js": "^2.0.6",
|
|
15
15
|
"react-image-crop": "^11.0.10",
|
|
16
16
|
"react-modal": "^3.16.3",
|
|
17
|
-
"@mobilestockweb/button": "^1.0.
|
|
17
|
+
"@mobilestockweb/button": "^1.0.13",
|
|
18
18
|
"@mobilestockweb/badge": "^0.0.6",
|
|
19
|
-
"@mobilestockweb/snackbar": "^0.0.
|
|
19
|
+
"@mobilestockweb/snackbar": "^0.0.18",
|
|
20
20
|
"@mobilestockweb/tools": "^0.0.16",
|
|
21
21
|
"@mobilestockweb/typography": "^0.0.6",
|
|
22
|
-
"@mobilestockweb/clickable": "^1.0.
|
|
23
|
-
"@mobilestockweb/data-table": "^
|
|
22
|
+
"@mobilestockweb/clickable": "^1.0.8",
|
|
23
|
+
"@mobilestockweb/data-table": "^2.0.1",
|
|
24
24
|
"@mobilestockweb/spacer": "^1.0.6",
|
|
25
25
|
"@mobilestockweb/container": "^1.0.0"
|
|
26
26
|
},
|