@mobilestock-native/button 1.1.13 → 1.1.14
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.js +5 -4
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Co=Object.create;var E=Object.defineProperty,ho=Object.defineProperties,$o=Object.getOwnPropertyDescriptor,yo=Object.getOwnPropertyDescriptors,
|
|
1
|
+
"use strict";var Co=Object.create;var E=Object.defineProperty,ho=Object.defineProperties,$o=Object.getOwnPropertyDescriptor,yo=Object.getOwnPropertyDescriptors,bo=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols,Po=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var H=(o,e,t)=>e in o?E(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,K=(o,e)=>{for(var t in e||(e={}))A.call(e,t)&&H(o,t,e[t]);if(N)for(var t of N(e))M.call(e,t)&&H(o,t,e[t]);return o},j=(o,e)=>ho(o,yo(e));var _=(o,e)=>{var t={};for(var r in o)A.call(o,r)&&e.indexOf(r)<0&&(t[r]=o[r]);if(o!=null&&N)for(var r of N(o))e.indexOf(r)<0&&M.call(o,r)&&(t[r]=o[r]);return t};var Ro=(o,e)=>{for(var t in e)E(o,t,{get:e[t],enumerable:!0})},G=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of bo(e))!A.call(o,i)&&i!==t&&E(o,i,{get:()=>e[i],enumerable:!(r=$o(e,i))||r.enumerable});return o};var m=(o,e,t)=>(t=o!=null?Co(Po(o)):{},G(e||!o||!o.__esModule?E(t,"default",{value:o,enumerable:!0}):t,o)),Bo=o=>G(E({},"__esModule",{value:!0}),o);var Do={};Ro(Do,{Button:()=>po});module.exports=Bo(Do);var co=require("react-native"),C=m(require("styled-components/native")),lo=require("@mobilestock-native/clickable"),R=require("@mobilestock-native/container"),so=m(require("@mobilestock-native/tools")),uo=require("@mobilestock-native/typography");var $=m(require("chroma-js")),l=require("styled-components/native"),n=m(require("@mobilestock-native/tools"));function x(o,e){let t=o.split("_"),r=500;if(t.length>1)switch(t[1]){case"LIGHT":r=400;break;case"DARK":r=600;break}return n.default.getColorWithLuminosity(e.colors.button[t[0].toLowerCase()],r)}function J(o,e,t){if(o==="AUTO"){let r=x(e,t);return(0,$.default)(r).luminance()>.5?(0,$.default)(r).darken(.8).hex():(0,$.default)(r).brighten(.8).hex()}return o.startsWith("#")?o:x(o,t)}function Y(o,e,t,r,i,s){if(o){let d=x(t,r),c={transform:"scale(0.98)"};switch(e){case"DEFAULT":c.backgroundColor=(0,$.default)(d).shade(.25).css();break;case"OUTLINE":{let p=i?J(i,t,r):d,u=s?parseFloat(r.borderWidth[s.toLowerCase()]):void 0;c.borderColor=(0,$.default)(p).shade(.25).css(),u!==void 0&&(c.borderWidth=u);break}}return c}return{}}function w(o){switch(o){case"START":return l.css`
|
|
2
2
|
justify-content: space-between;
|
|
3
3
|
`;case"BEFORE-TEXT":return l.css`
|
|
4
4
|
justify-content: center;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
${d}
|
|
29
29
|
width: ${c};
|
|
30
30
|
min-height: ${c};
|
|
31
|
-
`}return d}var eo=require("styled-components/native"),L=require("@mobilestock-native/icons"),ro=m(require("@mobilestock-native/tools"));var y=m(require("styled-components/native")),oo=m(require("@mobilestock-native/tools")),to=require("@mobilestock-native/typography"),k=require("react/jsx-runtime");function
|
|
31
|
+
`}return d}var eo=require("styled-components/native"),L=require("@mobilestock-native/icons"),ro=m(require("@mobilestock-native/tools"));var y=m(require("styled-components/native")),oo=m(require("@mobilestock-native/tools")),to=require("@mobilestock-native/typography"),k=require("react/jsx-runtime");function b(o){return(0,k.jsx)(No,{$position:o.notificationPosition,$size:o.size,children:(0,k.jsx)(So,{size:o.size,weight:"BOLD",children:o.notification>99?"99+":o.notification})})}var Eo={XS:{top:"-8px",right:"-10px"},SM:{top:"-10px",right:"-8px"},MD:{top:"-10px",right:"-8px"},LG:{top:"-12px",right:"-8px"},XL:{top:"-16px",right:"-10px"},"2XL":{top:"-16px",right:"-10px"},"3XL":{top:"-18px",right:"-10px"}},No=y.default.View`
|
|
32
32
|
position: absolute;
|
|
33
33
|
background-color: ${({theme:o})=>o.colors.alert.urgent};
|
|
34
34
|
padding: 2px 4px;
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
`}}
|
|
43
43
|
`,So=(0,y.default)(to.Typography)`
|
|
44
44
|
color: ${({theme:o})=>oo.default.defineTextColor(o.colors.alert.urgent)};
|
|
45
|
-
`;var g=require("react/jsx-runtime");function I(o){let e=(0,eo.useTheme)(),t=o.notification&&o.notificationPosition==="ICON";function r(){let i=x(o.backgroundColor,e);if(o.color)return o.color;switch(o.variant){case"DEFAULT":return ro.default.defineTextColor(i);case"TRANSPARENT":case"OUTLINE":return i;case"LINK":return e.colors.text.default}}return o.icon?t?(0,g.jsxs)(S,{children:[(0,g.jsx)(L.Icon,{color:r(),name:o.icon,size:o.size}),(0,g.jsx)(
|
|
45
|
+
`;var g=require("react/jsx-runtime");function I(o){let e=(0,eo.useTheme)(),t=o.notification&&o.notificationPosition==="ICON";function r(){let i=x(o.backgroundColor,e);if(o.color)return o.color;switch(o.variant){case"DEFAULT":return ro.default.defineTextColor(i);case"TRANSPARENT":case"OUTLINE":return i;case"LINK":return e.colors.text.default}}return o.icon?t?(0,g.jsxs)(S,{children:[(0,g.jsx)(L.Icon,{color:r(),name:o.icon,size:o.size}),(0,g.jsx)(b,{notification:o.notification,notificationPosition:o.notificationPosition,size:o.size})]}):(0,g.jsx)(L.Icon,{testID:"icon-container",color:r(),name:o.icon,size:o.size}):(0,g.jsx)(g.Fragment,{})}var h=m(require("styled-components/native")),no=m(require("@mobilestock-native/tools")),ao=require("@mobilestock-native/typography");var P=require("react/jsx-runtime");function D(o){return o.text?o.notification&&o.notificationPosition==="TEXT"?(0,P.jsxs)(S,{children:[(0,P.jsx)(io,{$color:o.color,$backgroundColor:o.backgroundColor,$variant:o.variant,align:"CENTER",weight:o.fontWeight,size:o.size,withUnderline:o.withUnderline,children:o.text}),(0,P.jsx)(b,{notification:o.notification,notificationPosition:o.notificationPosition,size:o.size})]}):(0,P.jsx)(io,{$color:o.color,$backgroundColor:o.backgroundColor,$variant:o.variant,align:"CENTER",weight:o.fontWeight,size:o.size,withUnderline:o.withUnderline,children:o.text}):null}var io=(0,h.default)(ao.Typography)`
|
|
46
46
|
${({$variant:o,$backgroundColor:e,$color:t,theme:r})=>{let i=x(e,r);if(t)return h.css`
|
|
47
47
|
color: ${t};
|
|
48
48
|
`;switch(o){case"DEFAULT":return h.css`
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
`;case"LINK":return h.css`
|
|
53
53
|
color: ${r.colors.text.default};
|
|
54
54
|
`}}}
|
|
55
|
-
`;var a=require("react/jsx-runtime"),fo=[{name:"View",component:co.View},{name:"Container",component:R.Container},{name:"Container.Vertical",component:R.Container.Vertical},{name:"Container.Horizontal",component:R.Container.Horizontal},{name:"Typography",component:uo.Typography}],Ao=fo.map(o=>o.component);function po(zo){var U=zo,{variant:o="DEFAULT",size:e="MD",iconAlign:t="BEFORE-TEXT",backgroundColor:r="DEFAULT",notificationPosition:i="ICON",fontWeight:s="REGULAR",textAlign:d="CENTER",circular:c=!1,notification:p,text:u,isLoading:z,icon:W,disabled:mo,padding:go,borderColor:V,borderWidth:v}=U,F=_(U,["variant","size","iconAlign","backgroundColor","notificationPosition","fontWeight","textAlign","circular","notification","text","isLoading","icon","disabled","padding","borderColor","borderWidth"]);let To=(0,C.useTheme)();function O(f){return typeof f=="object"&&f&&"color"in f&&typeof f.color=="string"?f.color:""}if(typeof u!="string"&&u&&!so.default.validateJSXTree(u,Ao))throw new Error(`Invalid jsx text props. Expected one of ${fo.map(T=>T.name).join(", ")}, but received: ${u.type.target||u.type}`);return(0,a.jsx)(wo,j(K({style:({pressed:f})=>Y(f,o,r,To,V,v)},F),{isLoading:z,disabled:mo||z,size:e,$backgroundColor:r,$variant:o,$circular:c,$borderColor:V,$borderWidth:v,children:f=>{let T=F.style;typeof T=="function"&&(T=T({pressed:f.pressed}));let B=O(T);if(Array.isArray(T)){let xo=T.findLast(X=>X&&"color"in X);B=O(xo)}return(0,a.jsxs)(ko,{padding:go,gap:e,align:"CENTER",$textAlign:d,$iconAlign:t,children:[t!=="START"&&t!=="END"?(0,a.jsxs)(Lo,{gap:t==="ABOVE-TEXT"?"NONE":e,align:"CENTER",$iconAlign:t,children:[(0,a.jsx)(I,{variant:o,backgroundColor:r,icon:W,size:e,color:B,notification:p,notificationPosition:i}),(0,a.jsx)(D,{backgroundColor:r,variant:o,fontWeight:s,text:u,size:e,color:B,withUnderline:o==="LINK",notification:p,notificationPosition:i})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I,{variant:o,backgroundColor:r,icon:W,size:e,color:B,notification:p,notificationPosition:i}),(0,a.jsx)(D,{backgroundColor:r,variant:o,fontWeight:s,text:u,size:e,color:B,withUnderline:o==="LINK",notification:p,notificationPosition:i})]}),!!p&&i==="END"&&(0,a.jsx)(
|
|
55
|
+
`;var a=require("react/jsx-runtime"),fo=[{name:"View",component:co.View},{name:"Container",component:R.Container},{name:"Container.Vertical",component:R.Container.Vertical},{name:"Container.Horizontal",component:R.Container.Horizontal},{name:"Typography",component:uo.Typography}],Ao=fo.map(o=>o.component);function po(zo){var U=zo,{variant:o="DEFAULT",size:e="MD",iconAlign:t="BEFORE-TEXT",backgroundColor:r="DEFAULT",notificationPosition:i="ICON",fontWeight:s="REGULAR",textAlign:d="CENTER",circular:c=!1,notification:p,text:u,isLoading:z,icon:W,disabled:mo,padding:go,borderColor:V,borderWidth:v}=U,F=_(U,["variant","size","iconAlign","backgroundColor","notificationPosition","fontWeight","textAlign","circular","notification","text","isLoading","icon","disabled","padding","borderColor","borderWidth"]);let To=(0,C.useTheme)();function O(f){return typeof f=="object"&&f&&"color"in f&&typeof f.color=="string"?f.color:""}if(typeof u!="string"&&u&&!so.default.validateJSXTree(u,Ao))throw new Error(`Invalid jsx text props. Expected one of ${fo.map(T=>T.name).join(", ")}, but received: ${u.type.target||u.type}`);return(0,a.jsx)(wo,j(K({style:({pressed:f})=>Y(f,o,r,To,V,v)},F),{isLoading:z,disabled:mo||z,size:e,$backgroundColor:r,$variant:o,$circular:c,$borderColor:V,$borderWidth:v,children:f=>{let T=F.style;typeof T=="function"&&(T=T({pressed:f.pressed}));let B=O(T);if(Array.isArray(T)){let xo=T.findLast(X=>X&&"color"in X);B=O(xo)}return(0,a.jsxs)(ko,{padding:go,gap:e,align:"CENTER",$textAlign:d,$iconAlign:t,children:[t!=="START"&&t!=="END"?(0,a.jsxs)(Lo,{gap:t==="ABOVE-TEXT"?"NONE":e,align:"CENTER",$iconAlign:t,children:[(0,a.jsx)(I,{variant:o,backgroundColor:r,icon:W,size:e,color:B,notification:p,notificationPosition:i}),(0,a.jsx)(D,{backgroundColor:r,variant:o,fontWeight:s,text:u,size:e,color:B,withUnderline:o==="LINK",notification:p,notificationPosition:i})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I,{variant:o,backgroundColor:r,icon:W,size:e,color:B,notification:p,notificationPosition:i}),(0,a.jsx)(D,{backgroundColor:r,variant:o,fontWeight:s,text:u,size:e,color:B,withUnderline:o==="LINK",notification:p,notificationPosition:i})]}),!!p&&i==="END"&&(0,a.jsx)(b,{notification:p,notificationPosition:i,size:e}),!(p&&i==="END")&&(t==="START"||t==="END")&&!c&&(0,a.jsx)(Io,{testID:"flex-helper"})]})}}))}var wo=(0,C.default)(lo.Clickable)`
|
|
56
56
|
justify-content: center;
|
|
57
57
|
${({$variant:o,$backgroundColor:e,$borderColor:t,$borderWidth:r,theme:i})=>Q(o,e,i,t,r)}
|
|
58
58
|
${({size:o,$circular:e,theme:t})=>Z(o,e,t)}
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
`,S=C.default.View`
|
|
64
64
|
position: relative;
|
|
65
65
|
display: inline-flex;
|
|
66
|
+
flex-direction: row;
|
|
66
67
|
align-items: center;
|
|
67
68
|
`,Lo=(0,C.default)(R.Container)`
|
|
68
69
|
flex-direction: row;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilestock-native/button",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"chroma-js": "^3.1.2",
|
|
7
|
-
"@mobilestock-native/icons": "^0.10.1",
|
|
8
|
-
"@mobilestock-native/container": "^1.4.0",
|
|
9
7
|
"@mobilestock-native/clickable": "^1.1.3",
|
|
8
|
+
"@mobilestock-native/container": "^1.4.0",
|
|
9
|
+
"@mobilestock-native/icons": "^0.10.1",
|
|
10
10
|
"@mobilestock-native/tools": "^0.1.0",
|
|
11
11
|
"@mobilestock-native/typography": "^0.1.3"
|
|
12
12
|
},
|