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