@telegraph/button 0.2.7 → 0.3.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/CHANGELOG.md +11 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/css/default.css +1 -1
- package/dist/esm/index.mjs +68 -68
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/Button/Button.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @telegraph/button
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#615](https://github.com/knocklabs/telegraph/pull/615) [`8d9f23c`](https://github.com/knocklabs/telegraph/commit/8d9f23cdc43701b6a281cd4ac0c6a1d5fdfe107a) Thanks [@kylemcd](https://github.com/kylemcd)! - feat: add spinner component and utilize within the button component
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`8d9f23c`](https://github.com/knocklabs/telegraph/commit/8d9f23cdc43701b6a281cd4ac0c6a1d5fdfe107a)]:
|
|
12
|
+
- @telegraph/icon@0.3.0
|
|
13
|
+
|
|
3
14
|
## 0.2.7
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),V=require("@telegraph/helpers"),j=require("@telegraph/icon"),E=require("@telegraph/layout"),O=require("@telegraph/style-engine"),P=require("@telegraph/typography"),R=require("clsx"),B=require("lucide-react"),b=require("react"),L={default_buttonShadowColor:{cssVar:"--box-shadow",value:"inset 0 0 0 1px var(--tgph-VARIABLE)"},hover_buttonShadowColor:{cssVar:"--tgph-button-hover-shadow",value:"inset 0 0 0 1px var(--tgph-VARIABLE)"},focus_buttonShadowColor:{cssVar:"--tgph-button-focus-shadow",value:"inset 0 0 0 1px var(--tgph-VARIABLE)"},active_buttonShadowColor:{cssVar:"--tgph-button-active-shadow",value:"inset 0 0 0 1px var(--tgph-VARIABLE)"},hover_textColor:{cssVar:"--tgph-button-hover-text-color",value:"var(--tgph-VARIABLE)"}},M={solid:{default:{backgroundColor:"gray-12",hover_backgroundColor:"gray-11",focus_backgroundColor:"gray-10",active_backgroundColor:"gray-10",hover_textColor:"white"},accent:{backgroundColor:"accent-9",hover_backgroundColor:"accent-10",focus_backgroundColor:"accent-11",active_backgroundColor:"accent-11",hover_textColor:"white"},red:{backgroundColor:"red-9",hover_backgroundColor:"red-10",focus_backgroundColor:"red-11",active_backgroundColor:"red-11",hover_textColor:"white"},gray:{backgroundColor:"gray-9",hover_backgroundColor:"gray-10",focus_backgroundColor:"gray-11",active_backgroundColor:"gray-11",hover_textColor:"white"},green:{backgroundColor:"green-9",hover_backgroundColor:"green-10",focus_backgroundColor:"green-11",active_backgroundColor:"green-11",hover_textColor:"white"},blue:{backgroundColor:"blue-9",hover_backgroundColor:"blue-10",focus_backgroundColor:"blue-11",active_backgroundColor:"blue-11",hover_textColor:"white"},yellow:{backgroundColor:"yellow-9",hover_backgroundColor:"yellow-10",focus_backgroundColor:"yellow-11",active_backgroundColor:"yellow-11",hover_textColor:"white"},purple:{backgroundColor:"purple-9",hover_backgroundColor:"purple-10",focus_backgroundColor:"purple-11",active_backgroundColor:"purple-11",hover_textColor:"white"}},soft:{default:{backgroundColor:"gray-3",hover_backgroundColor:"gray-4",focus_backgroundColor:"gray-5",active_backgroundColor:"gray-5",hover_textColor:"gray-12"},gray:{backgroundColor:"gray-3",hover_backgroundColor:"gray-4",focus_backgroundColor:"gray-5",active_backgroundColor:"gray-5",hover_textColor:"gray-12"},red:{backgroundColor:"red-3",hover_backgroundColor:"red-4",focus_backgroundColor:"red-5",active_backgroundColor:"red-5",hover_textColor:"red-11"},accent:{backgroundColor:"accent-3",hover_backgroundColor:"accent-4",focus_backgroundColor:"accent-5",active_backgroundColor:"accent-5",hover_textColor:"accent-11"},green:{backgroundColor:"green-3",hover_backgroundColor:"green-4",focus_backgroundColor:"green-5",active_backgroundColor:"green-5",hover_textColor:"green-11"},blue:{backgroundColor:"blue-3",hover_backgroundColor:"blue-4",focus_backgroundColor:"blue-5",active_backgroundColor:"blue-5",hover_textColor:"blue-11"},yellow:{backgroundColor:"yellow-3",hover_backgroundColor:"yellow-4",focus_backgroundColor:"yellow-5",active_backgroundColor:"yellow-5",hover_textColor:"yellow-11"},purple:{backgroundColor:"purple-3",hover_backgroundColor:"purple-4",focus_backgroundColor:"purple-5",active_backgroundColor:"purple-5",hover_textColor:"purple-11"}},outline:{default:{backgroundColor:"surface-1",hover_backgroundColor:"gray-2",default_buttonShadowColor:"gray-6",hover_buttonShadowColor:"gray-7",focus_buttonShadowColor:"gray-8",active_buttonShadowColor:"gray-8",hover_textColor:"gray-12"},gray:{backgroundColor:"surface-1",hover_backgroundColor:"gray-2",default_buttonShadowColor:"gray-6",hover_buttonShadowColor:"gray-7",focus_buttonShadowColor:"gray-8",active_buttonShadowColor:"gray-8",hover_textColor:"gray-12"},red:{backgroundColor:"surface-1",hover_backgroundColor:"red-2",default_buttonShadowColor:"red-6",hover_buttonShadowColor:"red-7",focus_buttonShadowColor:"red-8",active_buttonShadowColor:"red-8",hover_textColor:"red-11"},accent:{backgroundColor:"surface-1",hover_backgroundColor:"accent-2",default_buttonShadowColor:"accent-6",hover_buttonShadowColor:"accent-7",focus_buttonShadowColor:"accent-8",active_buttonShadowColor:"accent-8",hover_textColor:"accent-11"},green:{backgroundColor:"surface-1",hover_backgroundColor:"green-2",default_buttonShadowColor:"green-6",hover_buttonShadowColor:"green-7",focus_buttonShadowColor:"green-8",active_buttonShadowColor:"green-8",hover_textColor:"green-11"},blue:{backgroundColor:"surface-1",hover_backgroundColor:"blue-2",default_buttonShadowColor:"blue-6",hover_buttonShadowColor:"blue-7",focus_buttonShadowColor:"blue-8",active_buttonShadowColor:"blue-8",hover_textColor:"blue-11"},yellow:{backgroundColor:"surface-1",hover_backgroundColor:"yellow-2",default_buttonShadowColor:"yellow-6",hover_buttonShadowColor:"yellow-7",focus_buttonShadowColor:"yellow-8",active_buttonShadowColor:"yellow-8",hover_textColor:"yellow-11"},purple:{backgroundColor:"surface-1",hover_backgroundColor:"purple-2",default_buttonShadowColor:"purple-6",hover_buttonShadowColor:"purple-7",focus_buttonShadowColor:"purple-8",active_buttonShadowColor:"purple-8",hover_textColor:"purple-11"}},ghost:{default:{backgroundColor:"transparent",hover_backgroundColor:"gray-3",focus_backgroundColor:"gray-4",active_backgroundColor:"gray-4",hover_textColor:"gray-12"},gray:{backgroundColor:"transparent",hover_backgroundColor:"gray-3",focus_backgroundColor:"gray-4",active_backgroundColor:"gray-4",hover_textColor:"gray-12"},red:{backgroundColor:"transparent",hover_backgroundColor:"red-3",focus_backgroundColor:"red-4",active_backgroundColor:"red-4",hover_textColor:"red-11"},accent:{backgroundColor:"transparent",hover_backgroundColor:"accent-3",focus_backgroundColor:"accent-4",active_backgroundColor:"accent-4",hover_textColor:"accent-11"},green:{backgroundColor:"transparent",hover_backgroundColor:"green-3",focus_backgroundColor:"green-4",active_backgroundColor:"green-4",hover_textColor:"green-11"},blue:{backgroundColor:"transparent",hover_backgroundColor:"blue-3",focus_backgroundColor:"blue-4",active_backgroundColor:"blue-4",hover_textColor:"blue-11"},yellow:{backgroundColor:"transparent",hover_backgroundColor:"yellow-3",focus_backgroundColor:"yellow-4",active_backgroundColor:"yellow-4",hover_textColor:"yellow-11"},purple:{backgroundColor:"transparent",hover_backgroundColor:"purple-3",focus_backgroundColor:"purple-4",active_backgroundColor:"purple-4",hover_textColor:"purple-11"}}},m={default:{0:{w:"auto",h:"5",gap:"0_5",px:"1",rounded:"2"},1:{w:"auto",h:"6",gap:"1",px:"1_5",rounded:"2"},2:{w:"auto",h:"8",gap:"1_5",px:"2",rounded:"2"},3:{w:"auto",h:"10",gap:"2",px:"3",rounded:"3"}},"icon-only":{0:{w:"5",h:"5",gap:"0",px:"0",rounded:"2"},1:{w:"6",h:"6",gap:"0",px:"0",rounded:"2"},2:{w:"8",h:"8",gap:"0",px:"0",rounded:"2"},3:{w:"10",h:"10",gap:"0",px:"0",rounded:"3"}}},q={0:"0",1:"1",2:"2",3:"3"},N={solid:{default:"white",gray:"white",red:"white",accent:"white",green:"white",blue:"white",yellow:"white",purple:"white",disabled:"disabled"},soft:{default:"default",gray:"gray",red:"red",accent:"accent",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"},outline:{default:"default",gray:"gray",red:"red",accent:"accent",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"},ghost:{default:"default",gray:"gray",red:"red",accent:"accent",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"}},z={0:"0",1:"1",2:"2",3:"3"},D={solid:{default:"white",gray:"white",red:"white",accent:"white",green:"white",blue:"white",yellow:"white",purple:"white",disabled:"disabled"},soft:{default:"default",accent:"accent",gray:"gray",red:"red",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"},outline:{default:"default",accent:"accent",gray:"gray",red:"red",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"},ghost:{default:"gray",accent:"accent",gray:"gray",red:"red",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"}},Z={default:"secondary","icon-only":"primary"},v=b.createContext({variant:"solid",size:"2",color:"default",state:"default",layout:"default",active:!1}),U=o=>o.disabled?"disabled":o.state==="loading"?"loading":o.active?"active":o.state,w=({as:o,variant:r="solid",size:l="2",color:e="default",state:n="default",active:t=!1,type:u="button",disabled:d,className:c,children:g,style:h,...S})=>{const A=U({state:n,disabled:d,active:t}),s=V.useDeterminateState({value:A,determinateValue:"loading",minDurationMs:1200}),{styleProp:I,otherProps:T}=O.useStyleEngine({props:{...M[r][e],style:h},cssVars:L}),y=d||!o?"button":o,_=b.useMemo(()=>{var k;const C=b.Children.toArray(g);if((C==null?void 0:C.length)===1&&b.isValidElement(C[0])){const p=C[0];if((k=p==null?void 0:p.props)!=null&&k.icon)return"icon-only"}return"default"},[g]);return a.jsx(v.Provider,{value:{variant:r,size:l,color:e,state:s,layout:_,active:t},children:a.jsxs(E.Stack,{as:y,className:R("tgph-button",c),display:"inline-flex",align:"center",justify:"center",...m[_][l],style:I,"data-tgph-button":!0,"data-tgph-button-layout":_,"data-tgph-button-state":s,"data-tgph-button-variant":r,"data-tgph-button-color":e,disabled:s==="disabled"||s==="loading",...y==="button"&&{type:u},...T,...S,children:[s==="loading"&&a.jsx(i,{icon:B.LoaderCircle,"aria-hidden":!0,"data-tgph-button-loading-icon":!0}),g]})})},i=({size:o,color:r,variant:l,icon:e,alt:n,"aria-hidden":t,internal_iconType:u,...d})=>{const c=b.useContext(v),g={size:o??z[c.size],color:r??D[c.variant][c.state==="disabled"?"disabled":c.color],variant:l??Z[c.layout]},h=n?{alt:n}:{"aria-hidden":t};return c.state==="loading"&&u==="leading"?null:a.jsx(j.Icon,{icon:e,"data-button-icon":!0,"data-button-icon-color":g.color,...h,...g,...d})},f=({as:o,color:r,size:l,weight:e="medium",style:n,...t})=>{const u=b.useContext(v),d=r??N[u.variant][u.state==="disabled"?"disabled":u.color];return a.jsx(P.Text,{as:o||"span",color:d,size:l??q[u.size],weight:e,internal_optionalAs:!0,"data-button-text":!0,"data-button-text-color":d,style:{textDecoration:"none",whiteSpace:"nowrap",...n},...t})},x=({leadingIcon:o,trailingIcon:r,icon:l,children:e,...n})=>{const t=o||l;return a.jsxs(w,{...n,children:[t&&a.jsx(i,{...t,internal_iconType:"leading"}),e&&a.jsx(f,{children:e}),r&&a.jsx(i,{...r,internal_iconType:"trailing"})]})};Object.assign(x,{Root:w,Icon:i,Text:f});const X=x;exports.Button=X;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),P=require("@telegraph/helpers"),w=require("@telegraph/icon"),R=require("@telegraph/layout"),B=require("@telegraph/style-engine"),M=require("@telegraph/typography"),m=require("clsx"),b=require("react"),L={default_buttonShadowColor:{cssVar:"--box-shadow",value:"inset 0 0 0 1px var(--tgph-VARIABLE)"},hover_buttonShadowColor:{cssVar:"--tgph-button-hover-shadow",value:"inset 0 0 0 1px var(--tgph-VARIABLE)"},focus_buttonShadowColor:{cssVar:"--tgph-button-focus-shadow",value:"inset 0 0 0 1px var(--tgph-VARIABLE)"},active_buttonShadowColor:{cssVar:"--tgph-button-active-shadow",value:"inset 0 0 0 1px var(--tgph-VARIABLE)"},hover_textColor:{cssVar:"--tgph-button-hover-text-color",value:"var(--tgph-VARIABLE)"}},q={solid:{default:{backgroundColor:"gray-12",hover_backgroundColor:"gray-11",focus_backgroundColor:"gray-10",active_backgroundColor:"gray-10",hover_textColor:"white"},accent:{backgroundColor:"accent-9",hover_backgroundColor:"accent-10",focus_backgroundColor:"accent-11",active_backgroundColor:"accent-11",hover_textColor:"white"},red:{backgroundColor:"red-9",hover_backgroundColor:"red-10",focus_backgroundColor:"red-11",active_backgroundColor:"red-11",hover_textColor:"white"},gray:{backgroundColor:"gray-9",hover_backgroundColor:"gray-10",focus_backgroundColor:"gray-11",active_backgroundColor:"gray-11",hover_textColor:"white"},green:{backgroundColor:"green-9",hover_backgroundColor:"green-10",focus_backgroundColor:"green-11",active_backgroundColor:"green-11",hover_textColor:"white"},blue:{backgroundColor:"blue-9",hover_backgroundColor:"blue-10",focus_backgroundColor:"blue-11",active_backgroundColor:"blue-11",hover_textColor:"white"},yellow:{backgroundColor:"yellow-9",hover_backgroundColor:"yellow-10",focus_backgroundColor:"yellow-11",active_backgroundColor:"yellow-11",hover_textColor:"white"},purple:{backgroundColor:"purple-9",hover_backgroundColor:"purple-10",focus_backgroundColor:"purple-11",active_backgroundColor:"purple-11",hover_textColor:"white"}},soft:{default:{backgroundColor:"gray-3",hover_backgroundColor:"gray-4",focus_backgroundColor:"gray-5",active_backgroundColor:"gray-5",hover_textColor:"gray-12"},gray:{backgroundColor:"gray-3",hover_backgroundColor:"gray-4",focus_backgroundColor:"gray-5",active_backgroundColor:"gray-5",hover_textColor:"gray-12"},red:{backgroundColor:"red-3",hover_backgroundColor:"red-4",focus_backgroundColor:"red-5",active_backgroundColor:"red-5",hover_textColor:"red-11"},accent:{backgroundColor:"accent-3",hover_backgroundColor:"accent-4",focus_backgroundColor:"accent-5",active_backgroundColor:"accent-5",hover_textColor:"accent-11"},green:{backgroundColor:"green-3",hover_backgroundColor:"green-4",focus_backgroundColor:"green-5",active_backgroundColor:"green-5",hover_textColor:"green-11"},blue:{backgroundColor:"blue-3",hover_backgroundColor:"blue-4",focus_backgroundColor:"blue-5",active_backgroundColor:"blue-5",hover_textColor:"blue-11"},yellow:{backgroundColor:"yellow-3",hover_backgroundColor:"yellow-4",focus_backgroundColor:"yellow-5",active_backgroundColor:"yellow-5",hover_textColor:"yellow-11"},purple:{backgroundColor:"purple-3",hover_backgroundColor:"purple-4",focus_backgroundColor:"purple-5",active_backgroundColor:"purple-5",hover_textColor:"purple-11"}},outline:{default:{backgroundColor:"surface-1",hover_backgroundColor:"gray-2",default_buttonShadowColor:"gray-6",hover_buttonShadowColor:"gray-7",focus_buttonShadowColor:"gray-8",active_buttonShadowColor:"gray-8",hover_textColor:"gray-12"},gray:{backgroundColor:"surface-1",hover_backgroundColor:"gray-2",default_buttonShadowColor:"gray-6",hover_buttonShadowColor:"gray-7",focus_buttonShadowColor:"gray-8",active_buttonShadowColor:"gray-8",hover_textColor:"gray-12"},red:{backgroundColor:"surface-1",hover_backgroundColor:"red-2",default_buttonShadowColor:"red-6",hover_buttonShadowColor:"red-7",focus_buttonShadowColor:"red-8",active_buttonShadowColor:"red-8",hover_textColor:"red-11"},accent:{backgroundColor:"surface-1",hover_backgroundColor:"accent-2",default_buttonShadowColor:"accent-6",hover_buttonShadowColor:"accent-7",focus_buttonShadowColor:"accent-8",active_buttonShadowColor:"accent-8",hover_textColor:"accent-11"},green:{backgroundColor:"surface-1",hover_backgroundColor:"green-2",default_buttonShadowColor:"green-6",hover_buttonShadowColor:"green-7",focus_buttonShadowColor:"green-8",active_buttonShadowColor:"green-8",hover_textColor:"green-11"},blue:{backgroundColor:"surface-1",hover_backgroundColor:"blue-2",default_buttonShadowColor:"blue-6",hover_buttonShadowColor:"blue-7",focus_buttonShadowColor:"blue-8",active_buttonShadowColor:"blue-8",hover_textColor:"blue-11"},yellow:{backgroundColor:"surface-1",hover_backgroundColor:"yellow-2",default_buttonShadowColor:"yellow-6",hover_buttonShadowColor:"yellow-7",focus_buttonShadowColor:"yellow-8",active_buttonShadowColor:"yellow-8",hover_textColor:"yellow-11"},purple:{backgroundColor:"surface-1",hover_backgroundColor:"purple-2",default_buttonShadowColor:"purple-6",hover_buttonShadowColor:"purple-7",focus_buttonShadowColor:"purple-8",active_buttonShadowColor:"purple-8",hover_textColor:"purple-11"}},ghost:{default:{backgroundColor:"transparent",hover_backgroundColor:"gray-3",focus_backgroundColor:"gray-4",active_backgroundColor:"gray-4",hover_textColor:"gray-12"},gray:{backgroundColor:"transparent",hover_backgroundColor:"gray-3",focus_backgroundColor:"gray-4",active_backgroundColor:"gray-4",hover_textColor:"gray-12"},red:{backgroundColor:"transparent",hover_backgroundColor:"red-3",focus_backgroundColor:"red-4",active_backgroundColor:"red-4",hover_textColor:"red-11"},accent:{backgroundColor:"transparent",hover_backgroundColor:"accent-3",focus_backgroundColor:"accent-4",active_backgroundColor:"accent-4",hover_textColor:"accent-11"},green:{backgroundColor:"transparent",hover_backgroundColor:"green-3",focus_backgroundColor:"green-4",active_backgroundColor:"green-4",hover_textColor:"green-11"},blue:{backgroundColor:"transparent",hover_backgroundColor:"blue-3",focus_backgroundColor:"blue-4",active_backgroundColor:"blue-4",hover_textColor:"blue-11"},yellow:{backgroundColor:"transparent",hover_backgroundColor:"yellow-3",focus_backgroundColor:"yellow-4",active_backgroundColor:"yellow-4",hover_textColor:"yellow-11"},purple:{backgroundColor:"transparent",hover_backgroundColor:"purple-3",focus_backgroundColor:"purple-4",active_backgroundColor:"purple-4",hover_textColor:"purple-11"}}},N={default:{0:{w:"auto",h:"5",gap:"0_5",px:"1",rounded:"2"},1:{w:"auto",h:"6",gap:"1",px:"1_5",rounded:"2"},2:{w:"auto",h:"8",gap:"1_5",px:"2",rounded:"2"},3:{w:"auto",h:"10",gap:"2",px:"3",rounded:"3"}},"icon-only":{0:{w:"5",h:"5",gap:"0",px:"0",rounded:"2"},1:{w:"6",h:"6",gap:"0",px:"0",rounded:"2"},2:{w:"8",h:"8",gap:"0",px:"0",rounded:"2"},3:{w:"10",h:"10",gap:"0",px:"0",rounded:"3"}}},z={0:"0",1:"1",2:"2",3:"3"},D={solid:{default:"white",gray:"white",red:"white",accent:"white",green:"white",blue:"white",yellow:"white",purple:"white",disabled:"disabled"},soft:{default:"default",gray:"gray",red:"red",accent:"accent",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"},outline:{default:"default",gray:"gray",red:"red",accent:"accent",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"},ghost:{default:"default",gray:"gray",red:"red",accent:"accent",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"}},f={0:"0",1:"1",2:"2",3:"3"},x={solid:{default:"white",gray:"white",red:"white",accent:"white",green:"white",blue:"white",yellow:"white",purple:"white",disabled:"disabled"},soft:{default:"default",accent:"accent",gray:"gray",red:"red",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"},outline:{default:"default",accent:"accent",gray:"gray",red:"red",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"},ghost:{default:"gray",accent:"accent",gray:"gray",red:"red",green:"green",blue:"blue",yellow:"yellow",purple:"purple",disabled:"disabled"}},S={default:"secondary","icon-only":"primary"},v=b.createContext({variant:"solid",size:"2",color:"default",state:"default",layout:"default",active:!1}),Z=o=>o.disabled?"disabled":o.state==="loading"?"loading":o.active?"active":o.state,A=({as:o,variant:r="solid",size:t="2",color:e="default",state:n="default",active:a=!1,type:u="button",disabled:d,className:c,children:g,style:h,...V})=>{const j=Z({state:n,disabled:d,active:a}),s=P.useDeterminateState({value:j,determinateValue:"loading",minDurationMs:1200}),{styleProp:E,otherProps:O}=B.useStyleEngine({props:{...q[r][e],style:h},cssVars:L}),y=d||!o?"button":o,i=b.useMemo(()=>{var k;const C=b.Children.toArray(g);if((C==null?void 0:C.length)===1&&b.isValidElement(C[0])){const _=C[0];if((k=_==null?void 0:_.props)!=null&&k.icon)return"icon-only"}return"default"},[g]);return l.jsx(v.Provider,{value:{variant:r,size:t,color:e,state:s,layout:i,active:a},children:l.jsxs(R.Stack,{as:y,className:m("tgph-button",c),display:"inline-flex",align:"center",justify:"center",...N[i][t],style:E,"data-tgph-button":!0,"data-tgph-button-layout":i,"data-tgph-button-state":s,"data-tgph-button-variant":r,"data-tgph-button-color":e,disabled:s==="disabled"||s==="loading",...y==="button"&&{type:u},...O,...V,children:[s==="loading"&&l.jsx(w.Spinner,{size:f[t],color:x[r][e],variant:S[i],"data-tgph-button-loading-icon":!0}),g]})})},p=({size:o,color:r,variant:t,icon:e,alt:n,"aria-hidden":a,internal_iconType:u,...d})=>{const c=b.useContext(v),g={size:o??f[c.size],color:r??x[c.variant][c.state==="disabled"?"disabled":c.color],variant:t??S[c.layout]},h=n?{alt:n}:{"aria-hidden":a};return c.state==="loading"&&u==="leading"?null:l.jsx(w.Icon,{icon:e,"data-button-icon":!0,"data-button-icon-color":g.color,...h,...g,...d})},I=({as:o,color:r,size:t,weight:e="medium",style:n,...a})=>{const u=b.useContext(v),d=r??D[u.variant][u.state==="disabled"?"disabled":u.color];return l.jsx(M.Text,{as:o||"span",color:d,size:t??z[u.size],weight:e,internal_optionalAs:!0,"data-button-text":!0,"data-button-text-color":d,style:{textDecoration:"none",whiteSpace:"nowrap",...n},...a})},T=({leadingIcon:o,trailingIcon:r,icon:t,children:e,...n})=>{const a=o||t;return l.jsxs(A,{...n,children:[a&&l.jsx(p,{...a,internal_iconType:"leading"}),e&&l.jsx(I,{children:e}),r&&l.jsx(p,{...r,internal_iconType:"trailing"})]})};Object.assign(T,{Root:A,Icon:p,Text:I});const U=T;exports.Button=U;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Button/Button.constants.ts","../../src/Button/Button.tsx"],"sourcesContent":["import type { tokens } from \"@telegraph/style-engine\";\nimport type { CssVarProp } from \"@telegraph/style-engine\";\n\n// Styles for controlling the \"border\" on the outline variant\n// of the button. We use a shadow so we don't need apply a border\n// to all other buttons to make them the same height.\nexport type BaseStyleProps = {\n default_buttonShadowColor: keyof typeof tokens.color;\n hover_buttonShadowColor: keyof typeof tokens.color;\n focus_buttonShadowColor: keyof typeof tokens.color;\n active_buttonShadowColor: keyof typeof tokens.color;\n hover_textColor?: keyof typeof tokens.color;\n};\n\nexport const cssVars: Record<keyof BaseStyleProps, CssVarProp> = {\n default_buttonShadowColor: {\n cssVar: \"--box-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n hover_buttonShadowColor: {\n cssVar: \"--tgph-button-hover-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n focus_buttonShadowColor: {\n cssVar: \"--tgph-button-focus-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n active_buttonShadowColor: {\n cssVar: \"--tgph-button-active-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n hover_textColor: {\n cssVar: \"--tgph-button-hover-text-color\",\n value: \"var(--tgph-VARIABLE)\",\n },\n} as const;\n\nexport const BUTTON_COLOR_MAP = {\n solid: {\n default: {\n backgroundColor: \"gray-12\",\n hover_backgroundColor: \"gray-11\",\n focus_backgroundColor: \"gray-10\",\n active_backgroundColor: \"gray-10\",\n hover_textColor: \"white\",\n },\n accent: {\n backgroundColor: \"accent-9\",\n hover_backgroundColor: \"accent-10\",\n focus_backgroundColor: \"accent-11\",\n active_backgroundColor: \"accent-11\",\n hover_textColor: \"white\",\n },\n red: {\n backgroundColor: \"red-9\",\n hover_backgroundColor: \"red-10\",\n focus_backgroundColor: \"red-11\",\n active_backgroundColor: \"red-11\",\n hover_textColor: \"white\",\n },\n gray: {\n backgroundColor: \"gray-9\",\n hover_backgroundColor: \"gray-10\",\n focus_backgroundColor: \"gray-11\",\n active_backgroundColor: \"gray-11\",\n hover_textColor: \"white\",\n },\n green: {\n backgroundColor: \"green-9\",\n hover_backgroundColor: \"green-10\",\n focus_backgroundColor: \"green-11\",\n active_backgroundColor: \"green-11\",\n hover_textColor: \"white\",\n },\n blue: {\n backgroundColor: \"blue-9\",\n hover_backgroundColor: \"blue-10\",\n focus_backgroundColor: \"blue-11\",\n active_backgroundColor: \"blue-11\",\n hover_textColor: \"white\",\n },\n yellow: {\n backgroundColor: \"yellow-9\",\n hover_backgroundColor: \"yellow-10\",\n focus_backgroundColor: \"yellow-11\",\n active_backgroundColor: \"yellow-11\",\n hover_textColor: \"white\",\n },\n purple: {\n backgroundColor: \"purple-9\",\n hover_backgroundColor: \"purple-10\",\n focus_backgroundColor: \"purple-11\",\n active_backgroundColor: \"purple-11\",\n hover_textColor: \"white\",\n },\n },\n soft: {\n default: {\n backgroundColor: \"gray-3\",\n hover_backgroundColor: \"gray-4\",\n focus_backgroundColor: \"gray-5\",\n active_backgroundColor: \"gray-5\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"gray-3\",\n hover_backgroundColor: \"gray-4\",\n focus_backgroundColor: \"gray-5\",\n active_backgroundColor: \"gray-5\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"red-3\",\n hover_backgroundColor: \"red-4\",\n focus_backgroundColor: \"red-5\",\n active_backgroundColor: \"red-5\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"accent-3\",\n hover_backgroundColor: \"accent-4\",\n focus_backgroundColor: \"accent-5\",\n active_backgroundColor: \"accent-5\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"green-3\",\n hover_backgroundColor: \"green-4\",\n focus_backgroundColor: \"green-5\",\n active_backgroundColor: \"green-5\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"blue-3\",\n hover_backgroundColor: \"blue-4\",\n focus_backgroundColor: \"blue-5\",\n active_backgroundColor: \"blue-5\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"yellow-3\",\n hover_backgroundColor: \"yellow-4\",\n focus_backgroundColor: \"yellow-5\",\n active_backgroundColor: \"yellow-5\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"purple-3\",\n hover_backgroundColor: \"purple-4\",\n focus_backgroundColor: \"purple-5\",\n active_backgroundColor: \"purple-5\",\n hover_textColor: \"purple-11\",\n },\n },\n outline: {\n default: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"gray-2\",\n default_buttonShadowColor: \"gray-6\",\n hover_buttonShadowColor: \"gray-7\",\n focus_buttonShadowColor: \"gray-8\",\n active_buttonShadowColor: \"gray-8\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"gray-2\",\n default_buttonShadowColor: \"gray-6\",\n hover_buttonShadowColor: \"gray-7\",\n focus_buttonShadowColor: \"gray-8\",\n active_buttonShadowColor: \"gray-8\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"red-2\",\n default_buttonShadowColor: \"red-6\",\n hover_buttonShadowColor: \"red-7\",\n focus_buttonShadowColor: \"red-8\",\n active_buttonShadowColor: \"red-8\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"accent-2\",\n default_buttonShadowColor: \"accent-6\",\n hover_buttonShadowColor: \"accent-7\",\n focus_buttonShadowColor: \"accent-8\",\n active_buttonShadowColor: \"accent-8\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"green-2\",\n default_buttonShadowColor: \"green-6\",\n hover_buttonShadowColor: \"green-7\",\n focus_buttonShadowColor: \"green-8\",\n active_buttonShadowColor: \"green-8\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"blue-2\",\n default_buttonShadowColor: \"blue-6\",\n hover_buttonShadowColor: \"blue-7\",\n focus_buttonShadowColor: \"blue-8\",\n active_buttonShadowColor: \"blue-8\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"yellow-2\",\n default_buttonShadowColor: \"yellow-6\",\n hover_buttonShadowColor: \"yellow-7\",\n focus_buttonShadowColor: \"yellow-8\",\n active_buttonShadowColor: \"yellow-8\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"purple-2\",\n default_buttonShadowColor: \"purple-6\",\n hover_buttonShadowColor: \"purple-7\",\n focus_buttonShadowColor: \"purple-8\",\n active_buttonShadowColor: \"purple-8\",\n hover_textColor: \"purple-11\",\n },\n },\n ghost: {\n default: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"gray-3\",\n focus_backgroundColor: \"gray-4\",\n active_backgroundColor: \"gray-4\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"gray-3\",\n focus_backgroundColor: \"gray-4\",\n active_backgroundColor: \"gray-4\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"red-3\",\n focus_backgroundColor: \"red-4\",\n active_backgroundColor: \"red-4\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"accent-3\",\n focus_backgroundColor: \"accent-4\",\n active_backgroundColor: \"accent-4\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"green-3\",\n focus_backgroundColor: \"green-4\",\n active_backgroundColor: \"green-4\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"blue-3\",\n focus_backgroundColor: \"blue-4\",\n active_backgroundColor: \"blue-4\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"yellow-3\",\n focus_backgroundColor: \"yellow-4\",\n active_backgroundColor: \"yellow-4\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"purple-3\",\n focus_backgroundColor: \"purple-4\",\n active_backgroundColor: \"purple-4\",\n hover_textColor: \"purple-11\",\n },\n },\n} as const;\n\nexport const BUTTON_SIZE_MAP = {\n default: {\n \"0\": {\n w: \"auto\",\n h: \"5\",\n gap: \"0_5\",\n px: \"1\",\n rounded: \"2\",\n },\n \"1\": {\n w: \"auto\",\n h: \"6\",\n gap: \"1\",\n px: \"1_5\",\n rounded: \"2\",\n },\n \"2\": {\n w: \"auto\",\n h: \"8\",\n gap: \"1_5\",\n px: \"2\",\n rounded: \"2\",\n },\n \"3\": {\n w: \"auto\",\n h: \"10\",\n gap: \"2\",\n px: \"3\",\n rounded: \"3\",\n },\n },\n \"icon-only\": {\n \"0\": {\n w: \"5\",\n h: \"5\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"1\": {\n w: \"6\",\n h: \"6\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"2\": {\n w: \"8\",\n h: \"8\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"3\": {\n w: \"10\",\n h: \"10\",\n gap: \"0\",\n px: \"0\",\n rounded: \"3\",\n },\n },\n} as const;\n\nexport const TEXT_SIZE_MAP = {\n \"0\": \"0\",\n \"1\": \"1\",\n \"2\": \"2\",\n \"3\": \"3\",\n} as const;\n\nexport const TEXT_COLOR_MAP = {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n green: \"white\",\n blue: \"white\",\n yellow: \"white\",\n purple: \"white\",\n disabled: \"disabled\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n outline: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n ghost: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n} as const;\n\nexport const ICON_SIZE_MAP = {\n \"0\": \"0\",\n \"1\": \"1\",\n \"2\": \"2\",\n \"3\": \"3\",\n} as const;\n\nexport const ICON_COLOR_MAP = {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n green: \"white\",\n blue: \"white\",\n yellow: \"white\",\n purple: \"white\",\n disabled: \"disabled\",\n },\n soft: {\n default: \"default\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n outline: {\n default: \"default\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n ghost: {\n default: \"gray\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n} as const;\n\nexport const ICON_VARIANT_MAP = {\n default: \"secondary\",\n \"icon-only\": \"primary\",\n} as const;\n\nexport type ButtonVariant = keyof typeof BUTTON_COLOR_MAP;\nexport type ButtonColor = keyof (typeof BUTTON_COLOR_MAP)[ButtonVariant];\nexport type ButtonSize = keyof (typeof BUTTON_SIZE_MAP)[\"default\"];\n","import {\n type PolymorphicProps,\n type PolymorphicPropsWithTgphRef,\n RemappedOmit,\n type Required,\n type TgphComponentProps,\n type TgphElement,\n useDeterminateState,\n} from \"@telegraph/helpers\";\nimport { Icon as TelegraphIcon } from \"@telegraph/icon\";\nimport { Stack } from \"@telegraph/layout\";\nimport { useStyleEngine } from \"@telegraph/style-engine\";\nimport { Text as TelegraphText } from \"@telegraph/typography\";\nimport clsx from \"clsx\";\nimport { LoaderCircle } from \"lucide-react\";\nimport React from \"react\";\n\nimport {\n BUTTON_COLOR_MAP,\n BUTTON_SIZE_MAP,\n type ButtonColor,\n type ButtonSize,\n type ButtonVariant,\n ICON_COLOR_MAP,\n ICON_SIZE_MAP,\n ICON_VARIANT_MAP,\n TEXT_COLOR_MAP,\n TEXT_SIZE_MAP,\n cssVars,\n} from \"./Button.constants\";\n\ntype RootBaseProps = {\n variant?: ButtonVariant;\n color?: ButtonColor;\n size?: ButtonSize;\n state?: \"default\" | \"loading\";\n active?: boolean;\n};\n\ntype InternalProps = {\n layout: \"default\" | \"icon-only\";\n color: Required<RootBaseProps>[\"color\"];\n state: Required<RootBaseProps>[\"state\"] | \"disabled\" | \"active\";\n};\n\ntype RootProps<T extends TgphElement> = Omit<\n TgphComponentProps<typeof Stack>,\n \"tgphRef\"\n> &\n PolymorphicPropsWithTgphRef<T, HTMLButtonElement> &\n RootBaseProps;\n\nconst ButtonContext = React.createContext<\n Required<Omit<RootBaseProps, \"color\" | \"as\" | \"state\"> & InternalProps>\n>({\n variant: \"solid\",\n size: \"2\",\n color: \"default\",\n state: \"default\",\n layout: \"default\",\n active: false,\n});\n\ntype DeriveStateParams = {\n state: Required<RootBaseProps>[\"state\"];\n disabled?: boolean;\n active?: boolean;\n};\n\n// Derive the state of the button based on the html button props in\nconst deriveState = (params: DeriveStateParams): InternalProps[\"state\"] => {\n if (params.disabled) return \"disabled\";\n if (params.state === \"loading\") return \"loading\";\n if (params.active) return \"active\";\n return params.state;\n};\n\nconst Root = <T extends TgphElement>({\n as,\n variant = \"solid\",\n size = \"2\",\n color = \"default\",\n state: stateProp = \"default\",\n active = false,\n type = \"button\",\n disabled,\n className,\n children,\n style,\n ...props\n}: RootProps<T>) => {\n const derivedState = deriveState({ state: stateProp, disabled, active });\n const state = useDeterminateState<DefaultProps<T>[\"state\"]>({\n value: derivedState,\n determinateValue: \"loading\",\n minDurationMs: 1200,\n });\n\n const { styleProp, otherProps } = useStyleEngine({\n props: {\n ...BUTTON_COLOR_MAP[variant][color],\n style,\n },\n cssVars,\n });\n\n // If the button is in a disabled state, we don't want any clicks to fire.\n // To do this reliably, we convert the element back to a button if it is\n // disabled. We do this so we can use the native button element's disabled\n // state to prevent clicks.\n // We also want to trivially pass in \"button\" if no \"as\" prop is provided\n const derivedAs = disabled || !as ? \"button\" : as;\n\n const layout = React.useMemo<InternalProps[\"layout\"]>(() => {\n const childrenArray = React.Children.toArray(children);\n if (childrenArray?.length === 1 && React.isValidElement(childrenArray[0])) {\n const child = childrenArray[0] as\n | React.ReactComponentElement<typeof Icon>\n | {\n props: {\n icon: undefined;\n };\n };\n if (child?.props?.icon) {\n return \"icon-only\";\n }\n }\n return \"default\";\n }, [children]);\n\n return (\n <ButtonContext.Provider\n value={{ variant, size, color, state, layout, active }}\n >\n <Stack\n as={derivedAs}\n className={clsx(\"tgph-button\", className)}\n display=\"inline-flex\"\n align=\"center\"\n justify=\"center\"\n {...BUTTON_SIZE_MAP[layout][size]}\n style={styleProp}\n data-tgph-button\n data-tgph-button-layout={layout}\n data-tgph-button-state={state}\n data-tgph-button-variant={variant}\n data-tgph-button-color={color}\n disabled={state === \"disabled\" || state === \"loading\"}\n {...(derivedAs === \"button\" && { type })} // Only pass in type if we are a button\n {...otherProps}\n {...props}\n >\n {state === \"loading\" && (\n <Icon\n icon={LoaderCircle}\n aria-hidden={true}\n data-tgph-button-loading-icon\n />\n )}\n {children}\n </Stack>\n </ButtonContext.Provider>\n );\n};\n\ntype IconProps<T extends TgphElement> = TgphComponentProps<\n typeof TelegraphIcon<T>\n> & {\n internal_iconType?: \"leading\" | \"trailing\";\n};\n\nconst Icon = <T extends TgphElement>({\n size,\n color,\n variant,\n icon,\n alt,\n \"aria-hidden\": ariaHidden,\n internal_iconType,\n ...props\n}: IconProps<T>) => {\n const context = React.useContext(ButtonContext);\n\n const iconProps = {\n size: size ?? ICON_SIZE_MAP[context.size],\n color:\n color ??\n ICON_COLOR_MAP[context.variant][\n context.state === \"disabled\" ? \"disabled\" : context.color\n ],\n variant: variant ?? ICON_VARIANT_MAP[context.layout],\n };\n\n const a11yProps = !alt ? { \"aria-hidden\": ariaHidden } : { alt };\n\n // If the button is set to loading and this icon is identified as leading,\n // we don't want to render this icon and instead the loading icon which\n // is managed in the root component. We choose to render the loading icon\n // in the root component so that it displays when there is no icon already\n // inside of the button.\n if (context.state === \"loading\" && internal_iconType === \"leading\") {\n return null;\n }\n\n return (\n <TelegraphIcon\n icon={icon}\n data-button-icon\n data-button-icon-color={iconProps.color}\n {...a11yProps}\n {...iconProps}\n {...props}\n />\n );\n};\n\ntype TextProps<T extends TgphElement> = RemappedOmit<\n TgphComponentProps<typeof TelegraphText<T>>,\n \"as\"\n> & {\n as?: T;\n};\n\nconst Text = <T extends TgphElement>({\n as,\n color,\n size,\n weight = \"medium\",\n style,\n ...props\n}: TextProps<T>) => {\n const context = React.useContext(ButtonContext);\n const derivedColor =\n color ??\n TEXT_COLOR_MAP[context.variant][\n context.state === \"disabled\" ? \"disabled\" : context.color\n ];\n return (\n <TelegraphText\n as={(as || \"span\") as T}\n color={derivedColor}\n size={size ?? TEXT_SIZE_MAP[context.size]}\n weight={weight}\n internal_optionalAs={true}\n data-button-text\n data-button-text-color={derivedColor}\n style={{\n textDecoration: \"none\",\n whiteSpace: \"nowrap\",\n ...style,\n }}\n {...props}\n />\n );\n};\n\ntype DefaultIconProps = React.ComponentProps<typeof Icon>;\n\ntype BaseDefaultProps =\n | {\n leadingIcon?: DefaultIconProps;\n trailingIcon?: DefaultIconProps;\n icon?: never;\n }\n | {\n icon?: DefaultIconProps;\n leadingIcon?: never;\n trailingIcon?: never;\n };\ntype DefaultProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Root> &\n BaseDefaultProps;\n\nconst Default = <T extends TgphElement>({\n leadingIcon,\n trailingIcon,\n icon,\n children,\n ...props\n}: DefaultProps<T>) => {\n const combinedLeadingIcon = leadingIcon || icon;\n return (\n <Root {...props}>\n {combinedLeadingIcon && (\n <Icon {...combinedLeadingIcon} internal_iconType=\"leading\" />\n )}\n {children && <Text>{children}</Text>}\n {trailingIcon && <Icon {...trailingIcon} internal_iconType=\"trailing\" />}\n </Root>\n );\n};\n\nObject.assign(Default, {\n Root,\n Icon,\n Text,\n});\n\nconst Button = Default as typeof Default & {\n Root: typeof Root;\n Icon: typeof Icon;\n Text: typeof Text;\n};\n\nexport { Button };\n"],"names":["cssVars","BUTTON_COLOR_MAP","BUTTON_SIZE_MAP","TEXT_SIZE_MAP","TEXT_COLOR_MAP","ICON_SIZE_MAP","ICON_COLOR_MAP","ICON_VARIANT_MAP","ButtonContext","React","deriveState","params","Root","as","variant","size","color","stateProp","active","type","disabled","className","children","style","props","derivedState","state","useDeterminateState","styleProp","otherProps","useStyleEngine","derivedAs","layout","childrenArray","child","_a","jsx","jsxs","Stack","clsx","Icon","LoaderCircle","icon","alt","ariaHidden","internal_iconType","context","iconProps","a11yProps","TelegraphIcon","Text","weight","derivedColor","TelegraphText","Default","leadingIcon","trailingIcon","combinedLeadingIcon","Button"],"mappings":"wVAcaA,EAAoD,CAC/D,0BAA2B,CACzB,OAAQ,eACR,MAAO,sCAAA,EAET,wBAAyB,CACvB,OAAQ,6BACR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+
{"version":3,"file":"index.js","sources":["../../src/Button/Button.constants.ts","../../src/Button/Button.tsx"],"sourcesContent":["import type { tokens } from \"@telegraph/style-engine\";\nimport type { CssVarProp } from \"@telegraph/style-engine\";\n\n// Styles for controlling the \"border\" on the outline variant\n// of the button. We use a shadow so we don't need apply a border\n// to all other buttons to make them the same height.\nexport type BaseStyleProps = {\n default_buttonShadowColor: keyof typeof tokens.color;\n hover_buttonShadowColor: keyof typeof tokens.color;\n focus_buttonShadowColor: keyof typeof tokens.color;\n active_buttonShadowColor: keyof typeof tokens.color;\n hover_textColor?: keyof typeof tokens.color;\n};\n\nexport const cssVars: Record<keyof BaseStyleProps, CssVarProp> = {\n default_buttonShadowColor: {\n cssVar: \"--box-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n hover_buttonShadowColor: {\n cssVar: \"--tgph-button-hover-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n focus_buttonShadowColor: {\n cssVar: \"--tgph-button-focus-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n active_buttonShadowColor: {\n cssVar: \"--tgph-button-active-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n hover_textColor: {\n cssVar: \"--tgph-button-hover-text-color\",\n value: \"var(--tgph-VARIABLE)\",\n },\n} as const;\n\nexport const BUTTON_COLOR_MAP = {\n solid: {\n default: {\n backgroundColor: \"gray-12\",\n hover_backgroundColor: \"gray-11\",\n focus_backgroundColor: \"gray-10\",\n active_backgroundColor: \"gray-10\",\n hover_textColor: \"white\",\n },\n accent: {\n backgroundColor: \"accent-9\",\n hover_backgroundColor: \"accent-10\",\n focus_backgroundColor: \"accent-11\",\n active_backgroundColor: \"accent-11\",\n hover_textColor: \"white\",\n },\n red: {\n backgroundColor: \"red-9\",\n hover_backgroundColor: \"red-10\",\n focus_backgroundColor: \"red-11\",\n active_backgroundColor: \"red-11\",\n hover_textColor: \"white\",\n },\n gray: {\n backgroundColor: \"gray-9\",\n hover_backgroundColor: \"gray-10\",\n focus_backgroundColor: \"gray-11\",\n active_backgroundColor: \"gray-11\",\n hover_textColor: \"white\",\n },\n green: {\n backgroundColor: \"green-9\",\n hover_backgroundColor: \"green-10\",\n focus_backgroundColor: \"green-11\",\n active_backgroundColor: \"green-11\",\n hover_textColor: \"white\",\n },\n blue: {\n backgroundColor: \"blue-9\",\n hover_backgroundColor: \"blue-10\",\n focus_backgroundColor: \"blue-11\",\n active_backgroundColor: \"blue-11\",\n hover_textColor: \"white\",\n },\n yellow: {\n backgroundColor: \"yellow-9\",\n hover_backgroundColor: \"yellow-10\",\n focus_backgroundColor: \"yellow-11\",\n active_backgroundColor: \"yellow-11\",\n hover_textColor: \"white\",\n },\n purple: {\n backgroundColor: \"purple-9\",\n hover_backgroundColor: \"purple-10\",\n focus_backgroundColor: \"purple-11\",\n active_backgroundColor: \"purple-11\",\n hover_textColor: \"white\",\n },\n },\n soft: {\n default: {\n backgroundColor: \"gray-3\",\n hover_backgroundColor: \"gray-4\",\n focus_backgroundColor: \"gray-5\",\n active_backgroundColor: \"gray-5\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"gray-3\",\n hover_backgroundColor: \"gray-4\",\n focus_backgroundColor: \"gray-5\",\n active_backgroundColor: \"gray-5\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"red-3\",\n hover_backgroundColor: \"red-4\",\n focus_backgroundColor: \"red-5\",\n active_backgroundColor: \"red-5\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"accent-3\",\n hover_backgroundColor: \"accent-4\",\n focus_backgroundColor: \"accent-5\",\n active_backgroundColor: \"accent-5\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"green-3\",\n hover_backgroundColor: \"green-4\",\n focus_backgroundColor: \"green-5\",\n active_backgroundColor: \"green-5\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"blue-3\",\n hover_backgroundColor: \"blue-4\",\n focus_backgroundColor: \"blue-5\",\n active_backgroundColor: \"blue-5\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"yellow-3\",\n hover_backgroundColor: \"yellow-4\",\n focus_backgroundColor: \"yellow-5\",\n active_backgroundColor: \"yellow-5\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"purple-3\",\n hover_backgroundColor: \"purple-4\",\n focus_backgroundColor: \"purple-5\",\n active_backgroundColor: \"purple-5\",\n hover_textColor: \"purple-11\",\n },\n },\n outline: {\n default: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"gray-2\",\n default_buttonShadowColor: \"gray-6\",\n hover_buttonShadowColor: \"gray-7\",\n focus_buttonShadowColor: \"gray-8\",\n active_buttonShadowColor: \"gray-8\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"gray-2\",\n default_buttonShadowColor: \"gray-6\",\n hover_buttonShadowColor: \"gray-7\",\n focus_buttonShadowColor: \"gray-8\",\n active_buttonShadowColor: \"gray-8\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"red-2\",\n default_buttonShadowColor: \"red-6\",\n hover_buttonShadowColor: \"red-7\",\n focus_buttonShadowColor: \"red-8\",\n active_buttonShadowColor: \"red-8\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"accent-2\",\n default_buttonShadowColor: \"accent-6\",\n hover_buttonShadowColor: \"accent-7\",\n focus_buttonShadowColor: \"accent-8\",\n active_buttonShadowColor: \"accent-8\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"green-2\",\n default_buttonShadowColor: \"green-6\",\n hover_buttonShadowColor: \"green-7\",\n focus_buttonShadowColor: \"green-8\",\n active_buttonShadowColor: \"green-8\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"blue-2\",\n default_buttonShadowColor: \"blue-6\",\n hover_buttonShadowColor: \"blue-7\",\n focus_buttonShadowColor: \"blue-8\",\n active_buttonShadowColor: \"blue-8\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"yellow-2\",\n default_buttonShadowColor: \"yellow-6\",\n hover_buttonShadowColor: \"yellow-7\",\n focus_buttonShadowColor: \"yellow-8\",\n active_buttonShadowColor: \"yellow-8\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"purple-2\",\n default_buttonShadowColor: \"purple-6\",\n hover_buttonShadowColor: \"purple-7\",\n focus_buttonShadowColor: \"purple-8\",\n active_buttonShadowColor: \"purple-8\",\n hover_textColor: \"purple-11\",\n },\n },\n ghost: {\n default: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"gray-3\",\n focus_backgroundColor: \"gray-4\",\n active_backgroundColor: \"gray-4\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"gray-3\",\n focus_backgroundColor: \"gray-4\",\n active_backgroundColor: \"gray-4\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"red-3\",\n focus_backgroundColor: \"red-4\",\n active_backgroundColor: \"red-4\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"accent-3\",\n focus_backgroundColor: \"accent-4\",\n active_backgroundColor: \"accent-4\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"green-3\",\n focus_backgroundColor: \"green-4\",\n active_backgroundColor: \"green-4\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"blue-3\",\n focus_backgroundColor: \"blue-4\",\n active_backgroundColor: \"blue-4\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"yellow-3\",\n focus_backgroundColor: \"yellow-4\",\n active_backgroundColor: \"yellow-4\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"purple-3\",\n focus_backgroundColor: \"purple-4\",\n active_backgroundColor: \"purple-4\",\n hover_textColor: \"purple-11\",\n },\n },\n} as const;\n\nexport const BUTTON_SIZE_MAP = {\n default: {\n \"0\": {\n w: \"auto\",\n h: \"5\",\n gap: \"0_5\",\n px: \"1\",\n rounded: \"2\",\n },\n \"1\": {\n w: \"auto\",\n h: \"6\",\n gap: \"1\",\n px: \"1_5\",\n rounded: \"2\",\n },\n \"2\": {\n w: \"auto\",\n h: \"8\",\n gap: \"1_5\",\n px: \"2\",\n rounded: \"2\",\n },\n \"3\": {\n w: \"auto\",\n h: \"10\",\n gap: \"2\",\n px: \"3\",\n rounded: \"3\",\n },\n },\n \"icon-only\": {\n \"0\": {\n w: \"5\",\n h: \"5\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"1\": {\n w: \"6\",\n h: \"6\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"2\": {\n w: \"8\",\n h: \"8\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"3\": {\n w: \"10\",\n h: \"10\",\n gap: \"0\",\n px: \"0\",\n rounded: \"3\",\n },\n },\n} as const;\n\nexport const TEXT_SIZE_MAP = {\n \"0\": \"0\",\n \"1\": \"1\",\n \"2\": \"2\",\n \"3\": \"3\",\n} as const;\n\nexport const TEXT_COLOR_MAP = {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n green: \"white\",\n blue: \"white\",\n yellow: \"white\",\n purple: \"white\",\n disabled: \"disabled\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n outline: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n ghost: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n} as const;\n\nexport const ICON_SIZE_MAP = {\n \"0\": \"0\",\n \"1\": \"1\",\n \"2\": \"2\",\n \"3\": \"3\",\n} as const;\n\nexport const ICON_COLOR_MAP = {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n green: \"white\",\n blue: \"white\",\n yellow: \"white\",\n purple: \"white\",\n disabled: \"disabled\",\n },\n soft: {\n default: \"default\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n outline: {\n default: \"default\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n ghost: {\n default: \"gray\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n} as const;\n\nexport const ICON_VARIANT_MAP = {\n default: \"secondary\",\n \"icon-only\": \"primary\",\n} as const;\n\nexport type ButtonVariant = keyof typeof BUTTON_COLOR_MAP;\nexport type ButtonColor = keyof (typeof BUTTON_COLOR_MAP)[ButtonVariant];\nexport type ButtonSize = keyof (typeof BUTTON_SIZE_MAP)[\"default\"];\n","import {\n type PolymorphicProps,\n type PolymorphicPropsWithTgphRef,\n RemappedOmit,\n type Required,\n type TgphComponentProps,\n type TgphElement,\n useDeterminateState,\n} from \"@telegraph/helpers\";\nimport { Spinner, Icon as TelegraphIcon } from \"@telegraph/icon\";\nimport { Stack } from \"@telegraph/layout\";\nimport { useStyleEngine } from \"@telegraph/style-engine\";\nimport { Text as TelegraphText } from \"@telegraph/typography\";\nimport clsx from \"clsx\";\nimport React from \"react\";\n\nimport {\n BUTTON_COLOR_MAP,\n BUTTON_SIZE_MAP,\n type ButtonColor,\n type ButtonSize,\n type ButtonVariant,\n ICON_COLOR_MAP,\n ICON_SIZE_MAP,\n ICON_VARIANT_MAP,\n TEXT_COLOR_MAP,\n TEXT_SIZE_MAP,\n cssVars,\n} from \"./Button.constants\";\n\ntype RootBaseProps = {\n variant?: ButtonVariant;\n color?: ButtonColor;\n size?: ButtonSize;\n state?: \"default\" | \"loading\";\n active?: boolean;\n};\n\ntype InternalProps = {\n layout: \"default\" | \"icon-only\";\n color: Required<RootBaseProps>[\"color\"];\n state: Required<RootBaseProps>[\"state\"] | \"disabled\" | \"active\";\n};\n\ntype RootProps<T extends TgphElement> = Omit<\n TgphComponentProps<typeof Stack>,\n \"tgphRef\"\n> &\n PolymorphicPropsWithTgphRef<T, HTMLButtonElement> &\n RootBaseProps;\n\nconst ButtonContext = React.createContext<\n Required<Omit<RootBaseProps, \"color\" | \"as\" | \"state\"> & InternalProps>\n>({\n variant: \"solid\",\n size: \"2\",\n color: \"default\",\n state: \"default\",\n layout: \"default\",\n active: false,\n});\n\ntype DeriveStateParams = {\n state: Required<RootBaseProps>[\"state\"];\n disabled?: boolean;\n active?: boolean;\n};\n\n// Derive the state of the button based on the html button props in\nconst deriveState = (params: DeriveStateParams): InternalProps[\"state\"] => {\n if (params.disabled) return \"disabled\";\n if (params.state === \"loading\") return \"loading\";\n if (params.active) return \"active\";\n return params.state;\n};\n\nconst Root = <T extends TgphElement>({\n as,\n variant = \"solid\",\n size = \"2\",\n color = \"default\",\n state: stateProp = \"default\",\n active = false,\n type = \"button\",\n disabled,\n className,\n children,\n style,\n ...props\n}: RootProps<T>) => {\n const derivedState = deriveState({ state: stateProp, disabled, active });\n const state = useDeterminateState<DefaultProps<T>[\"state\"]>({\n value: derivedState,\n determinateValue: \"loading\",\n minDurationMs: 1200,\n });\n\n const { styleProp, otherProps } = useStyleEngine({\n props: {\n ...BUTTON_COLOR_MAP[variant][color],\n style,\n },\n cssVars,\n });\n\n // If the button is in a disabled state, we don't want any clicks to fire.\n // To do this reliably, we convert the element back to a button if it is\n // disabled. We do this so we can use the native button element's disabled\n // state to prevent clicks.\n // We also want to trivially pass in \"button\" if no \"as\" prop is provided\n const derivedAs = disabled || !as ? \"button\" : as;\n\n const layout = React.useMemo<InternalProps[\"layout\"]>(() => {\n const childrenArray = React.Children.toArray(children);\n if (childrenArray?.length === 1 && React.isValidElement(childrenArray[0])) {\n const child = childrenArray[0] as\n | React.ReactComponentElement<typeof Icon>\n | {\n props: {\n icon: undefined;\n };\n };\n if (child?.props?.icon) {\n return \"icon-only\";\n }\n }\n return \"default\";\n }, [children]);\n\n return (\n <ButtonContext.Provider\n value={{ variant, size, color, state, layout, active }}\n >\n <Stack\n as={derivedAs}\n className={clsx(\"tgph-button\", className)}\n display=\"inline-flex\"\n align=\"center\"\n justify=\"center\"\n {...BUTTON_SIZE_MAP[layout][size]}\n style={styleProp}\n data-tgph-button\n data-tgph-button-layout={layout}\n data-tgph-button-state={state}\n data-tgph-button-variant={variant}\n data-tgph-button-color={color}\n disabled={state === \"disabled\" || state === \"loading\"}\n {...(derivedAs === \"button\" && { type })} // Only pass in type if we are a button\n {...otherProps}\n {...props}\n >\n {state === \"loading\" && (\n <Spinner\n size={ICON_SIZE_MAP[size]}\n color={ICON_COLOR_MAP[variant][color]}\n variant={ICON_VARIANT_MAP[layout]}\n data-tgph-button-loading-icon\n />\n )}\n {children}\n </Stack>\n </ButtonContext.Provider>\n );\n};\n\ntype IconProps<T extends TgphElement> = TgphComponentProps<\n typeof TelegraphIcon<T>\n> & {\n internal_iconType?: \"leading\" | \"trailing\";\n};\n\nconst Icon = <T extends TgphElement>({\n size,\n color,\n variant,\n icon,\n alt,\n \"aria-hidden\": ariaHidden,\n internal_iconType,\n ...props\n}: IconProps<T>) => {\n const context = React.useContext(ButtonContext);\n\n const iconProps = {\n size: size ?? ICON_SIZE_MAP[context.size],\n color:\n color ??\n ICON_COLOR_MAP[context.variant][\n context.state === \"disabled\" ? \"disabled\" : context.color\n ],\n variant: variant ?? ICON_VARIANT_MAP[context.layout],\n };\n\n const a11yProps = !alt ? { \"aria-hidden\": ariaHidden } : { alt };\n\n // If the button is set to loading and this icon is identified as leading,\n // we don't want to render this icon and instead the loading icon which\n // is managed in the root component. We choose to render the loading icon\n // in the root component so that it displays when there is no icon already\n // inside of the button.\n if (context.state === \"loading\" && internal_iconType === \"leading\") {\n return null;\n }\n\n return (\n <TelegraphIcon\n icon={icon}\n data-button-icon\n data-button-icon-color={iconProps.color}\n {...a11yProps}\n {...iconProps}\n {...props}\n />\n );\n};\n\ntype TextProps<T extends TgphElement> = RemappedOmit<\n TgphComponentProps<typeof TelegraphText<T>>,\n \"as\"\n> & {\n as?: T;\n};\n\nconst Text = <T extends TgphElement>({\n as,\n color,\n size,\n weight = \"medium\",\n style,\n ...props\n}: TextProps<T>) => {\n const context = React.useContext(ButtonContext);\n const derivedColor =\n color ??\n TEXT_COLOR_MAP[context.variant][\n context.state === \"disabled\" ? \"disabled\" : context.color\n ];\n return (\n <TelegraphText\n as={(as || \"span\") as T}\n color={derivedColor}\n size={size ?? TEXT_SIZE_MAP[context.size]}\n weight={weight}\n internal_optionalAs={true}\n data-button-text\n data-button-text-color={derivedColor}\n style={{\n textDecoration: \"none\",\n whiteSpace: \"nowrap\",\n ...style,\n }}\n {...props}\n />\n );\n};\n\ntype DefaultIconProps = React.ComponentProps<typeof Icon>;\n\ntype BaseDefaultProps =\n | {\n leadingIcon?: DefaultIconProps;\n trailingIcon?: DefaultIconProps;\n icon?: never;\n }\n | {\n icon?: DefaultIconProps;\n leadingIcon?: never;\n trailingIcon?: never;\n };\ntype DefaultProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Root> &\n BaseDefaultProps;\n\nconst Default = <T extends TgphElement>({\n leadingIcon,\n trailingIcon,\n icon,\n children,\n ...props\n}: DefaultProps<T>) => {\n const combinedLeadingIcon = leadingIcon || icon;\n return (\n <Root {...props}>\n {combinedLeadingIcon && (\n <Icon {...combinedLeadingIcon} internal_iconType=\"leading\" />\n )}\n {children && <Text>{children}</Text>}\n {trailingIcon && <Icon {...trailingIcon} internal_iconType=\"trailing\" />}\n </Root>\n );\n};\n\nObject.assign(Default, {\n Root,\n Icon,\n Text,\n});\n\nconst Button = Default as typeof Default & {\n Root: typeof Root;\n Icon: typeof Icon;\n Text: typeof Text;\n};\n\nexport { Button };\n"],"names":["cssVars","BUTTON_COLOR_MAP","BUTTON_SIZE_MAP","TEXT_SIZE_MAP","TEXT_COLOR_MAP","ICON_SIZE_MAP","ICON_COLOR_MAP","ICON_VARIANT_MAP","ButtonContext","React","deriveState","params","Root","as","variant","size","color","stateProp","active","type","disabled","className","children","style","props","derivedState","state","useDeterminateState","styleProp","otherProps","useStyleEngine","derivedAs","layout","childrenArray","child","_a","jsx","jsxs","Stack","clsx","Spinner","Icon","icon","alt","ariaHidden","internal_iconType","context","iconProps","a11yProps","TelegraphIcon","Text","weight","derivedColor","TelegraphText","Default","leadingIcon","trailingIcon","combinedLeadingIcon","Button"],"mappings":"8TAcaA,EAAoD,CAC/D,0BAA2B,CACzB,OAAQ,eACR,MAAO,sCAAA,EAET,wBAAyB,CACvB,OAAQ,6BACR,MAAO,sCAAA,EAET,wBAAyB,CACvB,OAAQ,6BACR,MAAO,sCAAA,EAET,yBAA0B,CACxB,OAAQ,8BACR,MAAO,sCAAA,EAET,gBAAiB,CACf,OAAQ,iCACR,MAAO,sBAAA,CAEX,EAEaC,EAAmB,CAC9B,MAAO,CACL,QAAS,CACP,gBAAiB,UACjB,sBA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,GAAGC,EACH,GAAGD,EACH,GAAGvB,CAAA,CAAA,CAGV,EASM0B,EAAO,CAAwB,CACnC,GAAArC,EACA,MAAAG,EACA,KAAAD,EACA,OAAAoC,EAAS,SACT,MAAA5B,EACA,GAAGC,CACL,IAAoB,CAClB,MAAMsB,EAAUrC,EAAM,WAAWD,CAAa,EACxC4C,EACJpC,GACAZ,EAAe0C,EAAQ,OAAO,EAC5BA,EAAQ,QAAU,WAAa,WAAaA,EAAQ,KACtD,EACF,OACEV,EAAAA,IAACiB,EAAAA,KAAA,CACC,GAAKxC,GAAM,OACX,MAAOuC,EACP,KAAMrC,GAAQZ,EAAc2C,EAAQ,IAAI,EACxC,OAAAK,EACA,oBAAqB,GACrB,mBAAgB,GAChB,yBAAwBC,EACxB,MAAO,CACL,eAAgB,OAChB,WAAY,SACZ,GAAG7B,CAAA,EAEJ,GAAGC,CAAA,CAAA,CAGV,EAmBM8B,EAAU,CAAwB,CACtC,YAAAC,EACA,aAAAC,EACA,KAAAd,EACA,SAAApB,EACA,GAAGE,CACL,IAAuB,CACrB,MAAMiC,EAAsBF,GAAeb,EAC3C,OACEL,EAAAA,KAACzB,EAAA,CAAM,GAAGY,EACP,SAAA,CAAAiC,GACCrB,EAAAA,IAACK,EAAA,CAAM,GAAGgB,EAAqB,kBAAkB,UAAU,EAE5DnC,GAAYc,EAAAA,IAACc,EAAA,CAAM,SAAA5B,CAAA,CAAS,EAC5BkC,GAAgBpB,EAAAA,IAACK,EAAA,CAAM,GAAGe,EAAc,kBAAkB,UAAA,CAAW,CAAA,EACxE,CAEJ,EAEA,OAAO,OAAOF,EAAS,CACrB,KAAA1C,EACA,KAAA6B,EACA,KAAAS,CACF,CAAC,EAED,MAAMQ,EAASJ"}
|
package/dist/css/default.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.tgph-button{--tgph-button-hover-shadow: none;--tgph-button-focus-shadow: none;--tgph-button-active-shadow: none;--tgph-button-hover-text-color: none;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;box-sizing:border-box;font-family:inherit;transition:background-color .2s ease-in-out,color .2s ease-in-out,box-shadow .2s ease-in-out;text-decoration:none}.tgph-button [data-button-text],.tgph-button [data-button-icon]{transition:color .2s ease-in-out}.tgph-button:hover{box-shadow:var(--tgph-button-hover-shadow)}.tgph-button:not([data-tgph-button-state=disabled]):hover [data-button-text]{--color: var(--tgph-button-hover-text-color) !important}.tgph-button:not([data-tgph-button-state=disabled]):hover [data-button-icon]{--color: var(--tgph-button-hover-text-color) !important}.tgph-button:focus{box-shadow:var(--tgph-button-focus-shadow)}.tgph-button[data-tgph-button-state=active]{box-shadow:var(--tgph-button-active-shadow);background-color:var(--active_backgroundColor)}.tgph-button[data-tgph-button-state=disabled][data-tgph-button-variant=solid],.tgph-button[data-tgph-button-state=disabled][data-tgph-button-variant=soft],.tgph-button[data-tgph-button-state=disabled][data-tgph-button-variant=outline]{background-color:var(--tgph-gray-3)}.tgph-button[data-tgph-button-state=disabled][data-tgph-button-variant=ghost]{background-color:var(--tgph-transparent)}.tgph-button:disabled{cursor:not-allowed}.tgph-button[data-tgph-button-state=disabled]:hover{background-color:revert}
|
|
1
|
+
.tgph-button{--tgph-button-hover-shadow: none;--tgph-button-focus-shadow: none;--tgph-button-active-shadow: none;--tgph-button-hover-text-color: none;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;box-sizing:border-box;font-family:inherit;transition:background-color .2s ease-in-out,color .2s ease-in-out,box-shadow .2s ease-in-out;text-decoration:none}.tgph-button [data-button-text],.tgph-button [data-button-icon]{transition:color .2s ease-in-out}.tgph-button:hover{box-shadow:var(--tgph-button-hover-shadow)}.tgph-button:not([data-tgph-button-state=disabled]):hover [data-button-text]{--color: var(--tgph-button-hover-text-color) !important}.tgph-button:not([data-tgph-button-state=disabled]):hover [data-button-icon]{--color: var(--tgph-button-hover-text-color) !important}.tgph-button:focus{box-shadow:var(--tgph-button-focus-shadow)}.tgph-button[data-tgph-button-state=active]{box-shadow:var(--tgph-button-active-shadow);background-color:var(--active_backgroundColor)}.tgph-button[data-tgph-button-state=disabled][data-tgph-button-variant=solid],.tgph-button[data-tgph-button-state=disabled][data-tgph-button-variant=soft],.tgph-button[data-tgph-button-state=disabled][data-tgph-button-variant=outline]{background-color:var(--tgph-gray-3)}.tgph-button[data-tgph-button-state=disabled][data-tgph-button-variant=ghost]{background-color:var(--tgph-transparent)}.tgph-button:disabled{cursor:not-allowed}.tgph-button[data-tgph-button-state=disabled]:hover{background-color:revert}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsxs as w, jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import { useDeterminateState as
|
|
3
|
-
import { Icon as
|
|
4
|
-
import { Stack as
|
|
5
|
-
import { useStyleEngine as
|
|
6
|
-
import { Text as
|
|
7
|
-
import
|
|
8
|
-
import { LoaderCircle as B } from "lucide-react";
|
|
2
|
+
import { useDeterminateState as P } from "@telegraph/helpers";
|
|
3
|
+
import { Icon as R, Spinner as B } from "@telegraph/icon";
|
|
4
|
+
import { Stack as L } from "@telegraph/layout";
|
|
5
|
+
import { useStyleEngine as M } from "@telegraph/style-engine";
|
|
6
|
+
import { Text as N } from "@telegraph/typography";
|
|
7
|
+
import j from "clsx";
|
|
9
8
|
import b from "react";
|
|
10
|
-
const
|
|
9
|
+
const z = {
|
|
11
10
|
default_buttonShadowColor: {
|
|
12
11
|
cssVar: "--box-shadow",
|
|
13
12
|
value: "inset 0 0 0 1px var(--tgph-VARIABLE)"
|
|
@@ -28,7 +27,7 @@ const M = {
|
|
|
28
27
|
cssVar: "--tgph-button-hover-text-color",
|
|
29
28
|
value: "var(--tgph-VARIABLE)"
|
|
30
29
|
}
|
|
31
|
-
},
|
|
30
|
+
}, D = {
|
|
32
31
|
solid: {
|
|
33
32
|
default: {
|
|
34
33
|
backgroundColor: "gray-12",
|
|
@@ -277,7 +276,7 @@ const M = {
|
|
|
277
276
|
hover_textColor: "purple-11"
|
|
278
277
|
}
|
|
279
278
|
}
|
|
280
|
-
},
|
|
279
|
+
}, Z = {
|
|
281
280
|
default: {
|
|
282
281
|
0: {
|
|
283
282
|
w: "auto",
|
|
@@ -338,12 +337,12 @@ const M = {
|
|
|
338
337
|
rounded: "3"
|
|
339
338
|
}
|
|
340
339
|
}
|
|
341
|
-
},
|
|
340
|
+
}, U = {
|
|
342
341
|
0: "0",
|
|
343
342
|
1: "1",
|
|
344
343
|
2: "2",
|
|
345
344
|
3: "3"
|
|
346
|
-
},
|
|
345
|
+
}, X = {
|
|
347
346
|
solid: {
|
|
348
347
|
default: "white",
|
|
349
348
|
gray: "white",
|
|
@@ -388,12 +387,12 @@ const M = {
|
|
|
388
387
|
purple: "purple",
|
|
389
388
|
disabled: "disabled"
|
|
390
389
|
}
|
|
391
|
-
},
|
|
390
|
+
}, f = {
|
|
392
391
|
0: "0",
|
|
393
392
|
1: "1",
|
|
394
393
|
2: "2",
|
|
395
394
|
3: "3"
|
|
396
|
-
},
|
|
395
|
+
}, x = {
|
|
397
396
|
solid: {
|
|
398
397
|
default: "white",
|
|
399
398
|
gray: "white",
|
|
@@ -438,7 +437,7 @@ const M = {
|
|
|
438
437
|
purple: "purple",
|
|
439
438
|
disabled: "disabled"
|
|
440
439
|
}
|
|
441
|
-
},
|
|
440
|
+
}, S = {
|
|
442
441
|
default: "secondary",
|
|
443
442
|
"icon-only": "primary"
|
|
444
443
|
}, v = b.createContext({
|
|
@@ -448,36 +447,36 @@ const M = {
|
|
|
448
447
|
state: "default",
|
|
449
448
|
layout: "default",
|
|
450
449
|
active: !1
|
|
451
|
-
}), $ = (o) => o.disabled ? "disabled" : o.state === "loading" ? "loading" : o.active ? "active" : o.state,
|
|
450
|
+
}), $ = (o) => o.disabled ? "disabled" : o.state === "loading" ? "loading" : o.active ? "active" : o.state, m = ({
|
|
452
451
|
as: o,
|
|
453
452
|
variant: r = "solid",
|
|
454
|
-
size:
|
|
453
|
+
size: t = "2",
|
|
455
454
|
color: e = "default",
|
|
456
455
|
state: l = "default",
|
|
457
|
-
active:
|
|
456
|
+
active: a = !1,
|
|
458
457
|
type: n = "button",
|
|
459
458
|
disabled: c,
|
|
460
459
|
className: u,
|
|
461
460
|
children: g,
|
|
462
|
-
style:
|
|
463
|
-
...
|
|
461
|
+
style: _,
|
|
462
|
+
...T
|
|
464
463
|
}) => {
|
|
465
|
-
const
|
|
466
|
-
value:
|
|
464
|
+
const V = $({ state: l, disabled: c, active: a }), C = P({
|
|
465
|
+
value: V,
|
|
467
466
|
determinateValue: "loading",
|
|
468
467
|
minDurationMs: 1200
|
|
469
|
-
}), { styleProp:
|
|
468
|
+
}), { styleProp: E, otherProps: O } = M({
|
|
470
469
|
props: {
|
|
471
|
-
...
|
|
472
|
-
style:
|
|
470
|
+
...D[r][e],
|
|
471
|
+
style: _
|
|
473
472
|
},
|
|
474
|
-
cssVars:
|
|
475
|
-
}), k = c || !o ? "button" : o,
|
|
473
|
+
cssVars: z
|
|
474
|
+
}), k = c || !o ? "button" : o, h = b.useMemo(() => {
|
|
476
475
|
var y;
|
|
477
476
|
const s = b.Children.toArray(g);
|
|
478
477
|
if ((s == null ? void 0 : s.length) === 1 && b.isValidElement(s[0])) {
|
|
479
|
-
const
|
|
480
|
-
if ((y =
|
|
478
|
+
const i = s[0];
|
|
479
|
+
if ((y = i == null ? void 0 : i.props) != null && y.icon)
|
|
481
480
|
return "icon-only";
|
|
482
481
|
}
|
|
483
482
|
return "default";
|
|
@@ -485,32 +484,33 @@ const M = {
|
|
|
485
484
|
return /* @__PURE__ */ d(
|
|
486
485
|
v.Provider,
|
|
487
486
|
{
|
|
488
|
-
value: { variant: r, size:
|
|
487
|
+
value: { variant: r, size: t, color: e, state: C, layout: h, active: a },
|
|
489
488
|
children: /* @__PURE__ */ w(
|
|
490
|
-
|
|
489
|
+
L,
|
|
491
490
|
{
|
|
492
491
|
as: k,
|
|
493
|
-
className:
|
|
492
|
+
className: j("tgph-button", u),
|
|
494
493
|
display: "inline-flex",
|
|
495
494
|
align: "center",
|
|
496
495
|
justify: "center",
|
|
497
|
-
...
|
|
498
|
-
style:
|
|
496
|
+
...Z[h][t],
|
|
497
|
+
style: E,
|
|
499
498
|
"data-tgph-button": !0,
|
|
500
|
-
"data-tgph-button-layout":
|
|
499
|
+
"data-tgph-button-layout": h,
|
|
501
500
|
"data-tgph-button-state": C,
|
|
502
501
|
"data-tgph-button-variant": r,
|
|
503
502
|
"data-tgph-button-color": e,
|
|
504
503
|
disabled: C === "disabled" || C === "loading",
|
|
505
504
|
...k === "button" && { type: n },
|
|
505
|
+
...O,
|
|
506
506
|
...T,
|
|
507
|
-
...m,
|
|
508
507
|
children: [
|
|
509
508
|
C === "loading" && /* @__PURE__ */ d(
|
|
510
|
-
|
|
509
|
+
B,
|
|
511
510
|
{
|
|
512
|
-
|
|
513
|
-
|
|
511
|
+
size: f[t],
|
|
512
|
+
color: x[r][e],
|
|
513
|
+
variant: S[h],
|
|
514
514
|
"data-tgph-button-loading-icon": !0
|
|
515
515
|
}
|
|
516
516
|
),
|
|
@@ -520,47 +520,47 @@ const M = {
|
|
|
520
520
|
)
|
|
521
521
|
}
|
|
522
522
|
);
|
|
523
|
-
},
|
|
523
|
+
}, p = ({
|
|
524
524
|
size: o,
|
|
525
525
|
color: r,
|
|
526
|
-
variant:
|
|
526
|
+
variant: t,
|
|
527
527
|
icon: e,
|
|
528
528
|
alt: l,
|
|
529
|
-
"aria-hidden":
|
|
529
|
+
"aria-hidden": a,
|
|
530
530
|
internal_iconType: n,
|
|
531
531
|
...c
|
|
532
532
|
}) => {
|
|
533
533
|
const u = b.useContext(v), g = {
|
|
534
|
-
size: o ??
|
|
535
|
-
color: r ??
|
|
536
|
-
variant:
|
|
537
|
-
},
|
|
534
|
+
size: o ?? f[u.size],
|
|
535
|
+
color: r ?? x[u.variant][u.state === "disabled" ? "disabled" : u.color],
|
|
536
|
+
variant: t ?? S[u.layout]
|
|
537
|
+
}, _ = l ? { alt: l } : { "aria-hidden": a };
|
|
538
538
|
return u.state === "loading" && n === "leading" ? null : /* @__PURE__ */ d(
|
|
539
|
-
|
|
539
|
+
R,
|
|
540
540
|
{
|
|
541
541
|
icon: e,
|
|
542
542
|
"data-button-icon": !0,
|
|
543
543
|
"data-button-icon-color": g.color,
|
|
544
|
-
...
|
|
544
|
+
..._,
|
|
545
545
|
...g,
|
|
546
546
|
...c
|
|
547
547
|
}
|
|
548
548
|
);
|
|
549
|
-
},
|
|
549
|
+
}, A = ({
|
|
550
550
|
as: o,
|
|
551
551
|
color: r,
|
|
552
|
-
size:
|
|
552
|
+
size: t,
|
|
553
553
|
weight: e = "medium",
|
|
554
554
|
style: l,
|
|
555
|
-
...
|
|
555
|
+
...a
|
|
556
556
|
}) => {
|
|
557
|
-
const n = b.useContext(v), c = r ??
|
|
557
|
+
const n = b.useContext(v), c = r ?? X[n.variant][n.state === "disabled" ? "disabled" : n.color];
|
|
558
558
|
return /* @__PURE__ */ d(
|
|
559
|
-
|
|
559
|
+
N,
|
|
560
560
|
{
|
|
561
561
|
as: o || "span",
|
|
562
562
|
color: c,
|
|
563
|
-
size:
|
|
563
|
+
size: t ?? U[n.size],
|
|
564
564
|
weight: e,
|
|
565
565
|
internal_optionalAs: !0,
|
|
566
566
|
"data-button-text": !0,
|
|
@@ -570,30 +570,30 @@ const M = {
|
|
|
570
570
|
whiteSpace: "nowrap",
|
|
571
571
|
...l
|
|
572
572
|
},
|
|
573
|
-
...
|
|
573
|
+
...a
|
|
574
574
|
}
|
|
575
575
|
);
|
|
576
|
-
},
|
|
576
|
+
}, I = ({
|
|
577
577
|
leadingIcon: o,
|
|
578
578
|
trailingIcon: r,
|
|
579
|
-
icon:
|
|
579
|
+
icon: t,
|
|
580
580
|
children: e,
|
|
581
581
|
...l
|
|
582
582
|
}) => {
|
|
583
|
-
const
|
|
584
|
-
return /* @__PURE__ */ w(
|
|
585
|
-
|
|
586
|
-
e && /* @__PURE__ */ d(
|
|
587
|
-
r && /* @__PURE__ */ d(
|
|
583
|
+
const a = o || t;
|
|
584
|
+
return /* @__PURE__ */ w(m, { ...l, children: [
|
|
585
|
+
a && /* @__PURE__ */ d(p, { ...a, internal_iconType: "leading" }),
|
|
586
|
+
e && /* @__PURE__ */ d(A, { children: e }),
|
|
587
|
+
r && /* @__PURE__ */ d(p, { ...r, internal_iconType: "trailing" })
|
|
588
588
|
] });
|
|
589
589
|
};
|
|
590
|
-
Object.assign(
|
|
591
|
-
Root:
|
|
592
|
-
Icon:
|
|
593
|
-
Text:
|
|
590
|
+
Object.assign(I, {
|
|
591
|
+
Root: m,
|
|
592
|
+
Icon: p,
|
|
593
|
+
Text: A
|
|
594
594
|
});
|
|
595
|
-
const
|
|
595
|
+
const Y = I;
|
|
596
596
|
export {
|
|
597
|
-
|
|
597
|
+
Y as Button
|
|
598
598
|
};
|
|
599
599
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Button/Button.constants.ts","../../src/Button/Button.tsx"],"sourcesContent":["import type { tokens } from \"@telegraph/style-engine\";\nimport type { CssVarProp } from \"@telegraph/style-engine\";\n\n// Styles for controlling the \"border\" on the outline variant\n// of the button. We use a shadow so we don't need apply a border\n// to all other buttons to make them the same height.\nexport type BaseStyleProps = {\n default_buttonShadowColor: keyof typeof tokens.color;\n hover_buttonShadowColor: keyof typeof tokens.color;\n focus_buttonShadowColor: keyof typeof tokens.color;\n active_buttonShadowColor: keyof typeof tokens.color;\n hover_textColor?: keyof typeof tokens.color;\n};\n\nexport const cssVars: Record<keyof BaseStyleProps, CssVarProp> = {\n default_buttonShadowColor: {\n cssVar: \"--box-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n hover_buttonShadowColor: {\n cssVar: \"--tgph-button-hover-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n focus_buttonShadowColor: {\n cssVar: \"--tgph-button-focus-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n active_buttonShadowColor: {\n cssVar: \"--tgph-button-active-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n hover_textColor: {\n cssVar: \"--tgph-button-hover-text-color\",\n value: \"var(--tgph-VARIABLE)\",\n },\n} as const;\n\nexport const BUTTON_COLOR_MAP = {\n solid: {\n default: {\n backgroundColor: \"gray-12\",\n hover_backgroundColor: \"gray-11\",\n focus_backgroundColor: \"gray-10\",\n active_backgroundColor: \"gray-10\",\n hover_textColor: \"white\",\n },\n accent: {\n backgroundColor: \"accent-9\",\n hover_backgroundColor: \"accent-10\",\n focus_backgroundColor: \"accent-11\",\n active_backgroundColor: \"accent-11\",\n hover_textColor: \"white\",\n },\n red: {\n backgroundColor: \"red-9\",\n hover_backgroundColor: \"red-10\",\n focus_backgroundColor: \"red-11\",\n active_backgroundColor: \"red-11\",\n hover_textColor: \"white\",\n },\n gray: {\n backgroundColor: \"gray-9\",\n hover_backgroundColor: \"gray-10\",\n focus_backgroundColor: \"gray-11\",\n active_backgroundColor: \"gray-11\",\n hover_textColor: \"white\",\n },\n green: {\n backgroundColor: \"green-9\",\n hover_backgroundColor: \"green-10\",\n focus_backgroundColor: \"green-11\",\n active_backgroundColor: \"green-11\",\n hover_textColor: \"white\",\n },\n blue: {\n backgroundColor: \"blue-9\",\n hover_backgroundColor: \"blue-10\",\n focus_backgroundColor: \"blue-11\",\n active_backgroundColor: \"blue-11\",\n hover_textColor: \"white\",\n },\n yellow: {\n backgroundColor: \"yellow-9\",\n hover_backgroundColor: \"yellow-10\",\n focus_backgroundColor: \"yellow-11\",\n active_backgroundColor: \"yellow-11\",\n hover_textColor: \"white\",\n },\n purple: {\n backgroundColor: \"purple-9\",\n hover_backgroundColor: \"purple-10\",\n focus_backgroundColor: \"purple-11\",\n active_backgroundColor: \"purple-11\",\n hover_textColor: \"white\",\n },\n },\n soft: {\n default: {\n backgroundColor: \"gray-3\",\n hover_backgroundColor: \"gray-4\",\n focus_backgroundColor: \"gray-5\",\n active_backgroundColor: \"gray-5\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"gray-3\",\n hover_backgroundColor: \"gray-4\",\n focus_backgroundColor: \"gray-5\",\n active_backgroundColor: \"gray-5\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"red-3\",\n hover_backgroundColor: \"red-4\",\n focus_backgroundColor: \"red-5\",\n active_backgroundColor: \"red-5\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"accent-3\",\n hover_backgroundColor: \"accent-4\",\n focus_backgroundColor: \"accent-5\",\n active_backgroundColor: \"accent-5\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"green-3\",\n hover_backgroundColor: \"green-4\",\n focus_backgroundColor: \"green-5\",\n active_backgroundColor: \"green-5\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"blue-3\",\n hover_backgroundColor: \"blue-4\",\n focus_backgroundColor: \"blue-5\",\n active_backgroundColor: \"blue-5\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"yellow-3\",\n hover_backgroundColor: \"yellow-4\",\n focus_backgroundColor: \"yellow-5\",\n active_backgroundColor: \"yellow-5\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"purple-3\",\n hover_backgroundColor: \"purple-4\",\n focus_backgroundColor: \"purple-5\",\n active_backgroundColor: \"purple-5\",\n hover_textColor: \"purple-11\",\n },\n },\n outline: {\n default: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"gray-2\",\n default_buttonShadowColor: \"gray-6\",\n hover_buttonShadowColor: \"gray-7\",\n focus_buttonShadowColor: \"gray-8\",\n active_buttonShadowColor: \"gray-8\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"gray-2\",\n default_buttonShadowColor: \"gray-6\",\n hover_buttonShadowColor: \"gray-7\",\n focus_buttonShadowColor: \"gray-8\",\n active_buttonShadowColor: \"gray-8\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"red-2\",\n default_buttonShadowColor: \"red-6\",\n hover_buttonShadowColor: \"red-7\",\n focus_buttonShadowColor: \"red-8\",\n active_buttonShadowColor: \"red-8\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"accent-2\",\n default_buttonShadowColor: \"accent-6\",\n hover_buttonShadowColor: \"accent-7\",\n focus_buttonShadowColor: \"accent-8\",\n active_buttonShadowColor: \"accent-8\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"green-2\",\n default_buttonShadowColor: \"green-6\",\n hover_buttonShadowColor: \"green-7\",\n focus_buttonShadowColor: \"green-8\",\n active_buttonShadowColor: \"green-8\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"blue-2\",\n default_buttonShadowColor: \"blue-6\",\n hover_buttonShadowColor: \"blue-7\",\n focus_buttonShadowColor: \"blue-8\",\n active_buttonShadowColor: \"blue-8\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"yellow-2\",\n default_buttonShadowColor: \"yellow-6\",\n hover_buttonShadowColor: \"yellow-7\",\n focus_buttonShadowColor: \"yellow-8\",\n active_buttonShadowColor: \"yellow-8\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"purple-2\",\n default_buttonShadowColor: \"purple-6\",\n hover_buttonShadowColor: \"purple-7\",\n focus_buttonShadowColor: \"purple-8\",\n active_buttonShadowColor: \"purple-8\",\n hover_textColor: \"purple-11\",\n },\n },\n ghost: {\n default: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"gray-3\",\n focus_backgroundColor: \"gray-4\",\n active_backgroundColor: \"gray-4\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"gray-3\",\n focus_backgroundColor: \"gray-4\",\n active_backgroundColor: \"gray-4\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"red-3\",\n focus_backgroundColor: \"red-4\",\n active_backgroundColor: \"red-4\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"accent-3\",\n focus_backgroundColor: \"accent-4\",\n active_backgroundColor: \"accent-4\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"green-3\",\n focus_backgroundColor: \"green-4\",\n active_backgroundColor: \"green-4\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"blue-3\",\n focus_backgroundColor: \"blue-4\",\n active_backgroundColor: \"blue-4\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"yellow-3\",\n focus_backgroundColor: \"yellow-4\",\n active_backgroundColor: \"yellow-4\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"purple-3\",\n focus_backgroundColor: \"purple-4\",\n active_backgroundColor: \"purple-4\",\n hover_textColor: \"purple-11\",\n },\n },\n} as const;\n\nexport const BUTTON_SIZE_MAP = {\n default: {\n \"0\": {\n w: \"auto\",\n h: \"5\",\n gap: \"0_5\",\n px: \"1\",\n rounded: \"2\",\n },\n \"1\": {\n w: \"auto\",\n h: \"6\",\n gap: \"1\",\n px: \"1_5\",\n rounded: \"2\",\n },\n \"2\": {\n w: \"auto\",\n h: \"8\",\n gap: \"1_5\",\n px: \"2\",\n rounded: \"2\",\n },\n \"3\": {\n w: \"auto\",\n h: \"10\",\n gap: \"2\",\n px: \"3\",\n rounded: \"3\",\n },\n },\n \"icon-only\": {\n \"0\": {\n w: \"5\",\n h: \"5\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"1\": {\n w: \"6\",\n h: \"6\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"2\": {\n w: \"8\",\n h: \"8\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"3\": {\n w: \"10\",\n h: \"10\",\n gap: \"0\",\n px: \"0\",\n rounded: \"3\",\n },\n },\n} as const;\n\nexport const TEXT_SIZE_MAP = {\n \"0\": \"0\",\n \"1\": \"1\",\n \"2\": \"2\",\n \"3\": \"3\",\n} as const;\n\nexport const TEXT_COLOR_MAP = {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n green: \"white\",\n blue: \"white\",\n yellow: \"white\",\n purple: \"white\",\n disabled: \"disabled\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n outline: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n ghost: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n} as const;\n\nexport const ICON_SIZE_MAP = {\n \"0\": \"0\",\n \"1\": \"1\",\n \"2\": \"2\",\n \"3\": \"3\",\n} as const;\n\nexport const ICON_COLOR_MAP = {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n green: \"white\",\n blue: \"white\",\n yellow: \"white\",\n purple: \"white\",\n disabled: \"disabled\",\n },\n soft: {\n default: \"default\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n outline: {\n default: \"default\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n ghost: {\n default: \"gray\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n} as const;\n\nexport const ICON_VARIANT_MAP = {\n default: \"secondary\",\n \"icon-only\": \"primary\",\n} as const;\n\nexport type ButtonVariant = keyof typeof BUTTON_COLOR_MAP;\nexport type ButtonColor = keyof (typeof BUTTON_COLOR_MAP)[ButtonVariant];\nexport type ButtonSize = keyof (typeof BUTTON_SIZE_MAP)[\"default\"];\n","import {\n type PolymorphicProps,\n type PolymorphicPropsWithTgphRef,\n RemappedOmit,\n type Required,\n type TgphComponentProps,\n type TgphElement,\n useDeterminateState,\n} from \"@telegraph/helpers\";\nimport { Icon as TelegraphIcon } from \"@telegraph/icon\";\nimport { Stack } from \"@telegraph/layout\";\nimport { useStyleEngine } from \"@telegraph/style-engine\";\nimport { Text as TelegraphText } from \"@telegraph/typography\";\nimport clsx from \"clsx\";\nimport { LoaderCircle } from \"lucide-react\";\nimport React from \"react\";\n\nimport {\n BUTTON_COLOR_MAP,\n BUTTON_SIZE_MAP,\n type ButtonColor,\n type ButtonSize,\n type ButtonVariant,\n ICON_COLOR_MAP,\n ICON_SIZE_MAP,\n ICON_VARIANT_MAP,\n TEXT_COLOR_MAP,\n TEXT_SIZE_MAP,\n cssVars,\n} from \"./Button.constants\";\n\ntype RootBaseProps = {\n variant?: ButtonVariant;\n color?: ButtonColor;\n size?: ButtonSize;\n state?: \"default\" | \"loading\";\n active?: boolean;\n};\n\ntype InternalProps = {\n layout: \"default\" | \"icon-only\";\n color: Required<RootBaseProps>[\"color\"];\n state: Required<RootBaseProps>[\"state\"] | \"disabled\" | \"active\";\n};\n\ntype RootProps<T extends TgphElement> = Omit<\n TgphComponentProps<typeof Stack>,\n \"tgphRef\"\n> &\n PolymorphicPropsWithTgphRef<T, HTMLButtonElement> &\n RootBaseProps;\n\nconst ButtonContext = React.createContext<\n Required<Omit<RootBaseProps, \"color\" | \"as\" | \"state\"> & InternalProps>\n>({\n variant: \"solid\",\n size: \"2\",\n color: \"default\",\n state: \"default\",\n layout: \"default\",\n active: false,\n});\n\ntype DeriveStateParams = {\n state: Required<RootBaseProps>[\"state\"];\n disabled?: boolean;\n active?: boolean;\n};\n\n// Derive the state of the button based on the html button props in\nconst deriveState = (params: DeriveStateParams): InternalProps[\"state\"] => {\n if (params.disabled) return \"disabled\";\n if (params.state === \"loading\") return \"loading\";\n if (params.active) return \"active\";\n return params.state;\n};\n\nconst Root = <T extends TgphElement>({\n as,\n variant = \"solid\",\n size = \"2\",\n color = \"default\",\n state: stateProp = \"default\",\n active = false,\n type = \"button\",\n disabled,\n className,\n children,\n style,\n ...props\n}: RootProps<T>) => {\n const derivedState = deriveState({ state: stateProp, disabled, active });\n const state = useDeterminateState<DefaultProps<T>[\"state\"]>({\n value: derivedState,\n determinateValue: \"loading\",\n minDurationMs: 1200,\n });\n\n const { styleProp, otherProps } = useStyleEngine({\n props: {\n ...BUTTON_COLOR_MAP[variant][color],\n style,\n },\n cssVars,\n });\n\n // If the button is in a disabled state, we don't want any clicks to fire.\n // To do this reliably, we convert the element back to a button if it is\n // disabled. We do this so we can use the native button element's disabled\n // state to prevent clicks.\n // We also want to trivially pass in \"button\" if no \"as\" prop is provided\n const derivedAs = disabled || !as ? \"button\" : as;\n\n const layout = React.useMemo<InternalProps[\"layout\"]>(() => {\n const childrenArray = React.Children.toArray(children);\n if (childrenArray?.length === 1 && React.isValidElement(childrenArray[0])) {\n const child = childrenArray[0] as\n | React.ReactComponentElement<typeof Icon>\n | {\n props: {\n icon: undefined;\n };\n };\n if (child?.props?.icon) {\n return \"icon-only\";\n }\n }\n return \"default\";\n }, [children]);\n\n return (\n <ButtonContext.Provider\n value={{ variant, size, color, state, layout, active }}\n >\n <Stack\n as={derivedAs}\n className={clsx(\"tgph-button\", className)}\n display=\"inline-flex\"\n align=\"center\"\n justify=\"center\"\n {...BUTTON_SIZE_MAP[layout][size]}\n style={styleProp}\n data-tgph-button\n data-tgph-button-layout={layout}\n data-tgph-button-state={state}\n data-tgph-button-variant={variant}\n data-tgph-button-color={color}\n disabled={state === \"disabled\" || state === \"loading\"}\n {...(derivedAs === \"button\" && { type })} // Only pass in type if we are a button\n {...otherProps}\n {...props}\n >\n {state === \"loading\" && (\n <Icon\n icon={LoaderCircle}\n aria-hidden={true}\n data-tgph-button-loading-icon\n />\n )}\n {children}\n </Stack>\n </ButtonContext.Provider>\n );\n};\n\ntype IconProps<T extends TgphElement> = TgphComponentProps<\n typeof TelegraphIcon<T>\n> & {\n internal_iconType?: \"leading\" | \"trailing\";\n};\n\nconst Icon = <T extends TgphElement>({\n size,\n color,\n variant,\n icon,\n alt,\n \"aria-hidden\": ariaHidden,\n internal_iconType,\n ...props\n}: IconProps<T>) => {\n const context = React.useContext(ButtonContext);\n\n const iconProps = {\n size: size ?? ICON_SIZE_MAP[context.size],\n color:\n color ??\n ICON_COLOR_MAP[context.variant][\n context.state === \"disabled\" ? \"disabled\" : context.color\n ],\n variant: variant ?? ICON_VARIANT_MAP[context.layout],\n };\n\n const a11yProps = !alt ? { \"aria-hidden\": ariaHidden } : { alt };\n\n // If the button is set to loading and this icon is identified as leading,\n // we don't want to render this icon and instead the loading icon which\n // is managed in the root component. We choose to render the loading icon\n // in the root component so that it displays when there is no icon already\n // inside of the button.\n if (context.state === \"loading\" && internal_iconType === \"leading\") {\n return null;\n }\n\n return (\n <TelegraphIcon\n icon={icon}\n data-button-icon\n data-button-icon-color={iconProps.color}\n {...a11yProps}\n {...iconProps}\n {...props}\n />\n );\n};\n\ntype TextProps<T extends TgphElement> = RemappedOmit<\n TgphComponentProps<typeof TelegraphText<T>>,\n \"as\"\n> & {\n as?: T;\n};\n\nconst Text = <T extends TgphElement>({\n as,\n color,\n size,\n weight = \"medium\",\n style,\n ...props\n}: TextProps<T>) => {\n const context = React.useContext(ButtonContext);\n const derivedColor =\n color ??\n TEXT_COLOR_MAP[context.variant][\n context.state === \"disabled\" ? \"disabled\" : context.color\n ];\n return (\n <TelegraphText\n as={(as || \"span\") as T}\n color={derivedColor}\n size={size ?? TEXT_SIZE_MAP[context.size]}\n weight={weight}\n internal_optionalAs={true}\n data-button-text\n data-button-text-color={derivedColor}\n style={{\n textDecoration: \"none\",\n whiteSpace: \"nowrap\",\n ...style,\n }}\n {...props}\n />\n );\n};\n\ntype DefaultIconProps = React.ComponentProps<typeof Icon>;\n\ntype BaseDefaultProps =\n | {\n leadingIcon?: DefaultIconProps;\n trailingIcon?: DefaultIconProps;\n icon?: never;\n }\n | {\n icon?: DefaultIconProps;\n leadingIcon?: never;\n trailingIcon?: never;\n };\ntype DefaultProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Root> &\n BaseDefaultProps;\n\nconst Default = <T extends TgphElement>({\n leadingIcon,\n trailingIcon,\n icon,\n children,\n ...props\n}: DefaultProps<T>) => {\n const combinedLeadingIcon = leadingIcon || icon;\n return (\n <Root {...props}>\n {combinedLeadingIcon && (\n <Icon {...combinedLeadingIcon} internal_iconType=\"leading\" />\n )}\n {children && <Text>{children}</Text>}\n {trailingIcon && <Icon {...trailingIcon} internal_iconType=\"trailing\" />}\n </Root>\n );\n};\n\nObject.assign(Default, {\n Root,\n Icon,\n Text,\n});\n\nconst Button = Default as typeof Default & {\n Root: typeof Root;\n Icon: typeof Icon;\n Text: typeof Text;\n};\n\nexport { Button };\n"],"names":["cssVars","BUTTON_COLOR_MAP","BUTTON_SIZE_MAP","TEXT_SIZE_MAP","TEXT_COLOR_MAP","ICON_SIZE_MAP","ICON_COLOR_MAP","ICON_VARIANT_MAP","ButtonContext","React","deriveState","params","Root","as","variant","size","color","stateProp","active","type","disabled","className","children","style","props","derivedState","state","useDeterminateState","styleProp","otherProps","useStyleEngine","derivedAs","layout","childrenArray","child","_a","jsx","jsxs","Stack","clsx","Icon","LoaderCircle","icon","alt","ariaHidden","internal_iconType","context","iconProps","a11yProps","TelegraphIcon","Text","weight","derivedColor","TelegraphText","Default","leadingIcon","trailingIcon","combinedLeadingIcon","Button"],"mappings":";;;;;;;;;AAcO,MAAMA,IAAoD;AAAA,EAC/D,2BAA2B;AAAA,IACzB,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAET,yBAAyB;AAAA,IACvB,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAET,yBAAyB;AAAA,IACvB,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAET,0BAA0B;AAAA,IACxB,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAET,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAEX,GAEaC,IAAmB;AAAA,EAC9B,OAAO;AAAA,IACL,SAAS;AAAA,MACP,iBAAiB;AAAA,MACjB,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,MACvB,wBAAwB;AAAA,MACxB,iBAAiB;AAAA,IAAA;AAAA,IAEnB,QAAQ;AAAA,MACN,iBAAiB;AAAA,MACjB,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,MACvB,wBAAwB;AAAA,MACxB,iBAAiB;AAAA,IAAA;AAAA,IAEnB,KAAK;AAAA,MACH,iBAAiB;AAAA,MACjB,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,MACvB,wBAAwB;AAAA,MACxB,iBAAiB;AAAA,IAAA;AAAA,IAEnB,MAAM;AAAA,MACJ,iBAAiB;AAAA,MACjB,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,MACvB,wBAAwB;AAAA,MACxB,iBAAiB;AAAA,IAAA;AAAA,IAEnB,OAAO;AAAA,MACL,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/Button/Button.tsx"],"sourcesContent":["import type { tokens } from \"@telegraph/style-engine\";\nimport type { CssVarProp } from \"@telegraph/style-engine\";\n\n// Styles for controlling the \"border\" on the outline variant\n// of the button. We use a shadow so we don't need apply a border\n// to all other buttons to make them the same height.\nexport type BaseStyleProps = {\n default_buttonShadowColor: keyof typeof tokens.color;\n hover_buttonShadowColor: keyof typeof tokens.color;\n focus_buttonShadowColor: keyof typeof tokens.color;\n active_buttonShadowColor: keyof typeof tokens.color;\n hover_textColor?: keyof typeof tokens.color;\n};\n\nexport const cssVars: Record<keyof BaseStyleProps, CssVarProp> = {\n default_buttonShadowColor: {\n cssVar: \"--box-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n hover_buttonShadowColor: {\n cssVar: \"--tgph-button-hover-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n focus_buttonShadowColor: {\n cssVar: \"--tgph-button-focus-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n active_buttonShadowColor: {\n cssVar: \"--tgph-button-active-shadow\",\n value: \"inset 0 0 0 1px var(--tgph-VARIABLE)\",\n },\n hover_textColor: {\n cssVar: \"--tgph-button-hover-text-color\",\n value: \"var(--tgph-VARIABLE)\",\n },\n} as const;\n\nexport const BUTTON_COLOR_MAP = {\n solid: {\n default: {\n backgroundColor: \"gray-12\",\n hover_backgroundColor: \"gray-11\",\n focus_backgroundColor: \"gray-10\",\n active_backgroundColor: \"gray-10\",\n hover_textColor: \"white\",\n },\n accent: {\n backgroundColor: \"accent-9\",\n hover_backgroundColor: \"accent-10\",\n focus_backgroundColor: \"accent-11\",\n active_backgroundColor: \"accent-11\",\n hover_textColor: \"white\",\n },\n red: {\n backgroundColor: \"red-9\",\n hover_backgroundColor: \"red-10\",\n focus_backgroundColor: \"red-11\",\n active_backgroundColor: \"red-11\",\n hover_textColor: \"white\",\n },\n gray: {\n backgroundColor: \"gray-9\",\n hover_backgroundColor: \"gray-10\",\n focus_backgroundColor: \"gray-11\",\n active_backgroundColor: \"gray-11\",\n hover_textColor: \"white\",\n },\n green: {\n backgroundColor: \"green-9\",\n hover_backgroundColor: \"green-10\",\n focus_backgroundColor: \"green-11\",\n active_backgroundColor: \"green-11\",\n hover_textColor: \"white\",\n },\n blue: {\n backgroundColor: \"blue-9\",\n hover_backgroundColor: \"blue-10\",\n focus_backgroundColor: \"blue-11\",\n active_backgroundColor: \"blue-11\",\n hover_textColor: \"white\",\n },\n yellow: {\n backgroundColor: \"yellow-9\",\n hover_backgroundColor: \"yellow-10\",\n focus_backgroundColor: \"yellow-11\",\n active_backgroundColor: \"yellow-11\",\n hover_textColor: \"white\",\n },\n purple: {\n backgroundColor: \"purple-9\",\n hover_backgroundColor: \"purple-10\",\n focus_backgroundColor: \"purple-11\",\n active_backgroundColor: \"purple-11\",\n hover_textColor: \"white\",\n },\n },\n soft: {\n default: {\n backgroundColor: \"gray-3\",\n hover_backgroundColor: \"gray-4\",\n focus_backgroundColor: \"gray-5\",\n active_backgroundColor: \"gray-5\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"gray-3\",\n hover_backgroundColor: \"gray-4\",\n focus_backgroundColor: \"gray-5\",\n active_backgroundColor: \"gray-5\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"red-3\",\n hover_backgroundColor: \"red-4\",\n focus_backgroundColor: \"red-5\",\n active_backgroundColor: \"red-5\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"accent-3\",\n hover_backgroundColor: \"accent-4\",\n focus_backgroundColor: \"accent-5\",\n active_backgroundColor: \"accent-5\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"green-3\",\n hover_backgroundColor: \"green-4\",\n focus_backgroundColor: \"green-5\",\n active_backgroundColor: \"green-5\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"blue-3\",\n hover_backgroundColor: \"blue-4\",\n focus_backgroundColor: \"blue-5\",\n active_backgroundColor: \"blue-5\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"yellow-3\",\n hover_backgroundColor: \"yellow-4\",\n focus_backgroundColor: \"yellow-5\",\n active_backgroundColor: \"yellow-5\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"purple-3\",\n hover_backgroundColor: \"purple-4\",\n focus_backgroundColor: \"purple-5\",\n active_backgroundColor: \"purple-5\",\n hover_textColor: \"purple-11\",\n },\n },\n outline: {\n default: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"gray-2\",\n default_buttonShadowColor: \"gray-6\",\n hover_buttonShadowColor: \"gray-7\",\n focus_buttonShadowColor: \"gray-8\",\n active_buttonShadowColor: \"gray-8\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"gray-2\",\n default_buttonShadowColor: \"gray-6\",\n hover_buttonShadowColor: \"gray-7\",\n focus_buttonShadowColor: \"gray-8\",\n active_buttonShadowColor: \"gray-8\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"red-2\",\n default_buttonShadowColor: \"red-6\",\n hover_buttonShadowColor: \"red-7\",\n focus_buttonShadowColor: \"red-8\",\n active_buttonShadowColor: \"red-8\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"accent-2\",\n default_buttonShadowColor: \"accent-6\",\n hover_buttonShadowColor: \"accent-7\",\n focus_buttonShadowColor: \"accent-8\",\n active_buttonShadowColor: \"accent-8\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"green-2\",\n default_buttonShadowColor: \"green-6\",\n hover_buttonShadowColor: \"green-7\",\n focus_buttonShadowColor: \"green-8\",\n active_buttonShadowColor: \"green-8\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"blue-2\",\n default_buttonShadowColor: \"blue-6\",\n hover_buttonShadowColor: \"blue-7\",\n focus_buttonShadowColor: \"blue-8\",\n active_buttonShadowColor: \"blue-8\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"yellow-2\",\n default_buttonShadowColor: \"yellow-6\",\n hover_buttonShadowColor: \"yellow-7\",\n focus_buttonShadowColor: \"yellow-8\",\n active_buttonShadowColor: \"yellow-8\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"surface-1\",\n hover_backgroundColor: \"purple-2\",\n default_buttonShadowColor: \"purple-6\",\n hover_buttonShadowColor: \"purple-7\",\n focus_buttonShadowColor: \"purple-8\",\n active_buttonShadowColor: \"purple-8\",\n hover_textColor: \"purple-11\",\n },\n },\n ghost: {\n default: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"gray-3\",\n focus_backgroundColor: \"gray-4\",\n active_backgroundColor: \"gray-4\",\n hover_textColor: \"gray-12\",\n },\n gray: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"gray-3\",\n focus_backgroundColor: \"gray-4\",\n active_backgroundColor: \"gray-4\",\n hover_textColor: \"gray-12\",\n },\n red: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"red-3\",\n focus_backgroundColor: \"red-4\",\n active_backgroundColor: \"red-4\",\n hover_textColor: \"red-11\",\n },\n accent: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"accent-3\",\n focus_backgroundColor: \"accent-4\",\n active_backgroundColor: \"accent-4\",\n hover_textColor: \"accent-11\",\n },\n green: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"green-3\",\n focus_backgroundColor: \"green-4\",\n active_backgroundColor: \"green-4\",\n hover_textColor: \"green-11\",\n },\n blue: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"blue-3\",\n focus_backgroundColor: \"blue-4\",\n active_backgroundColor: \"blue-4\",\n hover_textColor: \"blue-11\",\n },\n yellow: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"yellow-3\",\n focus_backgroundColor: \"yellow-4\",\n active_backgroundColor: \"yellow-4\",\n hover_textColor: \"yellow-11\",\n },\n purple: {\n backgroundColor: \"transparent\",\n hover_backgroundColor: \"purple-3\",\n focus_backgroundColor: \"purple-4\",\n active_backgroundColor: \"purple-4\",\n hover_textColor: \"purple-11\",\n },\n },\n} as const;\n\nexport const BUTTON_SIZE_MAP = {\n default: {\n \"0\": {\n w: \"auto\",\n h: \"5\",\n gap: \"0_5\",\n px: \"1\",\n rounded: \"2\",\n },\n \"1\": {\n w: \"auto\",\n h: \"6\",\n gap: \"1\",\n px: \"1_5\",\n rounded: \"2\",\n },\n \"2\": {\n w: \"auto\",\n h: \"8\",\n gap: \"1_5\",\n px: \"2\",\n rounded: \"2\",\n },\n \"3\": {\n w: \"auto\",\n h: \"10\",\n gap: \"2\",\n px: \"3\",\n rounded: \"3\",\n },\n },\n \"icon-only\": {\n \"0\": {\n w: \"5\",\n h: \"5\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"1\": {\n w: \"6\",\n h: \"6\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"2\": {\n w: \"8\",\n h: \"8\",\n gap: \"0\",\n px: \"0\",\n rounded: \"2\",\n },\n \"3\": {\n w: \"10\",\n h: \"10\",\n gap: \"0\",\n px: \"0\",\n rounded: \"3\",\n },\n },\n} as const;\n\nexport const TEXT_SIZE_MAP = {\n \"0\": \"0\",\n \"1\": \"1\",\n \"2\": \"2\",\n \"3\": \"3\",\n} as const;\n\nexport const TEXT_COLOR_MAP = {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n green: \"white\",\n blue: \"white\",\n yellow: \"white\",\n purple: \"white\",\n disabled: \"disabled\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n outline: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n ghost: {\n default: \"default\",\n gray: \"gray\",\n red: \"red\",\n accent: \"accent\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n} as const;\n\nexport const ICON_SIZE_MAP = {\n \"0\": \"0\",\n \"1\": \"1\",\n \"2\": \"2\",\n \"3\": \"3\",\n} as const;\n\nexport const ICON_COLOR_MAP = {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n green: \"white\",\n blue: \"white\",\n yellow: \"white\",\n purple: \"white\",\n disabled: \"disabled\",\n },\n soft: {\n default: \"default\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n outline: {\n default: \"default\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n ghost: {\n default: \"gray\",\n accent: \"accent\",\n gray: \"gray\",\n red: \"red\",\n green: \"green\",\n blue: \"blue\",\n yellow: \"yellow\",\n purple: \"purple\",\n disabled: \"disabled\",\n },\n} as const;\n\nexport const ICON_VARIANT_MAP = {\n default: \"secondary\",\n \"icon-only\": \"primary\",\n} as const;\n\nexport type ButtonVariant = keyof typeof BUTTON_COLOR_MAP;\nexport type ButtonColor = keyof (typeof BUTTON_COLOR_MAP)[ButtonVariant];\nexport type ButtonSize = keyof (typeof BUTTON_SIZE_MAP)[\"default\"];\n","import {\n type PolymorphicProps,\n type PolymorphicPropsWithTgphRef,\n RemappedOmit,\n type Required,\n type TgphComponentProps,\n type TgphElement,\n useDeterminateState,\n} from \"@telegraph/helpers\";\nimport { Spinner, Icon as TelegraphIcon } from \"@telegraph/icon\";\nimport { Stack } from \"@telegraph/layout\";\nimport { useStyleEngine } from \"@telegraph/style-engine\";\nimport { Text as TelegraphText } from \"@telegraph/typography\";\nimport clsx from \"clsx\";\nimport React from \"react\";\n\nimport {\n BUTTON_COLOR_MAP,\n BUTTON_SIZE_MAP,\n type ButtonColor,\n type ButtonSize,\n type ButtonVariant,\n ICON_COLOR_MAP,\n ICON_SIZE_MAP,\n ICON_VARIANT_MAP,\n TEXT_COLOR_MAP,\n TEXT_SIZE_MAP,\n cssVars,\n} from \"./Button.constants\";\n\ntype RootBaseProps = {\n variant?: ButtonVariant;\n color?: ButtonColor;\n size?: ButtonSize;\n state?: \"default\" | \"loading\";\n active?: boolean;\n};\n\ntype InternalProps = {\n layout: \"default\" | \"icon-only\";\n color: Required<RootBaseProps>[\"color\"];\n state: Required<RootBaseProps>[\"state\"] | \"disabled\" | \"active\";\n};\n\ntype RootProps<T extends TgphElement> = Omit<\n TgphComponentProps<typeof Stack>,\n \"tgphRef\"\n> &\n PolymorphicPropsWithTgphRef<T, HTMLButtonElement> &\n RootBaseProps;\n\nconst ButtonContext = React.createContext<\n Required<Omit<RootBaseProps, \"color\" | \"as\" | \"state\"> & InternalProps>\n>({\n variant: \"solid\",\n size: \"2\",\n color: \"default\",\n state: \"default\",\n layout: \"default\",\n active: false,\n});\n\ntype DeriveStateParams = {\n state: Required<RootBaseProps>[\"state\"];\n disabled?: boolean;\n active?: boolean;\n};\n\n// Derive the state of the button based on the html button props in\nconst deriveState = (params: DeriveStateParams): InternalProps[\"state\"] => {\n if (params.disabled) return \"disabled\";\n if (params.state === \"loading\") return \"loading\";\n if (params.active) return \"active\";\n return params.state;\n};\n\nconst Root = <T extends TgphElement>({\n as,\n variant = \"solid\",\n size = \"2\",\n color = \"default\",\n state: stateProp = \"default\",\n active = false,\n type = \"button\",\n disabled,\n className,\n children,\n style,\n ...props\n}: RootProps<T>) => {\n const derivedState = deriveState({ state: stateProp, disabled, active });\n const state = useDeterminateState<DefaultProps<T>[\"state\"]>({\n value: derivedState,\n determinateValue: \"loading\",\n minDurationMs: 1200,\n });\n\n const { styleProp, otherProps } = useStyleEngine({\n props: {\n ...BUTTON_COLOR_MAP[variant][color],\n style,\n },\n cssVars,\n });\n\n // If the button is in a disabled state, we don't want any clicks to fire.\n // To do this reliably, we convert the element back to a button if it is\n // disabled. We do this so we can use the native button element's disabled\n // state to prevent clicks.\n // We also want to trivially pass in \"button\" if no \"as\" prop is provided\n const derivedAs = disabled || !as ? \"button\" : as;\n\n const layout = React.useMemo<InternalProps[\"layout\"]>(() => {\n const childrenArray = React.Children.toArray(children);\n if (childrenArray?.length === 1 && React.isValidElement(childrenArray[0])) {\n const child = childrenArray[0] as\n | React.ReactComponentElement<typeof Icon>\n | {\n props: {\n icon: undefined;\n };\n };\n if (child?.props?.icon) {\n return \"icon-only\";\n }\n }\n return \"default\";\n }, [children]);\n\n return (\n <ButtonContext.Provider\n value={{ variant, size, color, state, layout, active }}\n >\n <Stack\n as={derivedAs}\n className={clsx(\"tgph-button\", className)}\n display=\"inline-flex\"\n align=\"center\"\n justify=\"center\"\n {...BUTTON_SIZE_MAP[layout][size]}\n style={styleProp}\n data-tgph-button\n data-tgph-button-layout={layout}\n data-tgph-button-state={state}\n data-tgph-button-variant={variant}\n data-tgph-button-color={color}\n disabled={state === \"disabled\" || state === \"loading\"}\n {...(derivedAs === \"button\" && { type })} // Only pass in type if we are a button\n {...otherProps}\n {...props}\n >\n {state === \"loading\" && (\n <Spinner\n size={ICON_SIZE_MAP[size]}\n color={ICON_COLOR_MAP[variant][color]}\n variant={ICON_VARIANT_MAP[layout]}\n data-tgph-button-loading-icon\n />\n )}\n {children}\n </Stack>\n </ButtonContext.Provider>\n );\n};\n\ntype IconProps<T extends TgphElement> = TgphComponentProps<\n typeof TelegraphIcon<T>\n> & {\n internal_iconType?: \"leading\" | \"trailing\";\n};\n\nconst Icon = <T extends TgphElement>({\n size,\n color,\n variant,\n icon,\n alt,\n \"aria-hidden\": ariaHidden,\n internal_iconType,\n ...props\n}: IconProps<T>) => {\n const context = React.useContext(ButtonContext);\n\n const iconProps = {\n size: size ?? ICON_SIZE_MAP[context.size],\n color:\n color ??\n ICON_COLOR_MAP[context.variant][\n context.state === \"disabled\" ? \"disabled\" : context.color\n ],\n variant: variant ?? ICON_VARIANT_MAP[context.layout],\n };\n\n const a11yProps = !alt ? { \"aria-hidden\": ariaHidden } : { alt };\n\n // If the button is set to loading and this icon is identified as leading,\n // we don't want to render this icon and instead the loading icon which\n // is managed in the root component. We choose to render the loading icon\n // in the root component so that it displays when there is no icon already\n // inside of the button.\n if (context.state === \"loading\" && internal_iconType === \"leading\") {\n return null;\n }\n\n return (\n <TelegraphIcon\n icon={icon}\n data-button-icon\n data-button-icon-color={iconProps.color}\n {...a11yProps}\n {...iconProps}\n {...props}\n />\n );\n};\n\ntype TextProps<T extends TgphElement> = RemappedOmit<\n TgphComponentProps<typeof TelegraphText<T>>,\n \"as\"\n> & {\n as?: T;\n};\n\nconst Text = <T extends TgphElement>({\n as,\n color,\n size,\n weight = \"medium\",\n style,\n ...props\n}: TextProps<T>) => {\n const context = React.useContext(ButtonContext);\n const derivedColor =\n color ??\n TEXT_COLOR_MAP[context.variant][\n context.state === \"disabled\" ? \"disabled\" : context.color\n ];\n return (\n <TelegraphText\n as={(as || \"span\") as T}\n color={derivedColor}\n size={size ?? TEXT_SIZE_MAP[context.size]}\n weight={weight}\n internal_optionalAs={true}\n data-button-text\n data-button-text-color={derivedColor}\n style={{\n textDecoration: \"none\",\n whiteSpace: \"nowrap\",\n ...style,\n }}\n {...props}\n />\n );\n};\n\ntype DefaultIconProps = React.ComponentProps<typeof Icon>;\n\ntype BaseDefaultProps =\n | {\n leadingIcon?: DefaultIconProps;\n trailingIcon?: DefaultIconProps;\n icon?: never;\n }\n | {\n icon?: DefaultIconProps;\n leadingIcon?: never;\n trailingIcon?: never;\n };\ntype DefaultProps<T extends TgphElement> = PolymorphicProps<T> &\n TgphComponentProps<typeof Root> &\n BaseDefaultProps;\n\nconst Default = <T extends TgphElement>({\n leadingIcon,\n trailingIcon,\n icon,\n children,\n ...props\n}: DefaultProps<T>) => {\n const combinedLeadingIcon = leadingIcon || icon;\n return (\n <Root {...props}>\n {combinedLeadingIcon && (\n <Icon {...combinedLeadingIcon} internal_iconType=\"leading\" />\n )}\n {children && <Text>{children}</Text>}\n {trailingIcon && <Icon {...trailingIcon} internal_iconType=\"trailing\" />}\n </Root>\n );\n};\n\nObject.assign(Default, {\n Root,\n Icon,\n Text,\n});\n\nconst Button = Default as typeof Default & {\n Root: typeof Root;\n Icon: typeof Icon;\n Text: typeof Text;\n};\n\nexport { Button };\n"],"names":["cssVars","BUTTON_COLOR_MAP","BUTTON_SIZE_MAP","TEXT_SIZE_MAP","TEXT_COLOR_MAP","ICON_SIZE_MAP","ICON_COLOR_MAP","ICON_VARIANT_MAP","ButtonContext","React","deriveState","params","Root","as","variant","size","color","stateProp","active","type","disabled","className","children","style","props","derivedState","state","useDeterminateState","styleProp","otherProps","useStyleEngine","derivedAs","layout","childrenArray","child","_a","jsx","jsxs","Stack","clsx","Spinner","Icon","icon","alt","ariaHidden","internal_iconType","context","iconProps","a11yProps","TelegraphIcon","Text","weight","derivedColor","TelegraphText","Default","leadingIcon","trailingIcon","combinedLeadingIcon","Button"],"mappings":";;;;;;;;AAcO,MAAMA,IAAoD;AAAA,EAC/D,2BAA2B;AAAA,IACzB,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAET,yBAAyB;AAAA,IACvB,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAET,yBAAyB;AAAA,IACvB,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAET,0BAA0B;AAAA,IACxB,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAAA,EAET,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,OAAO;AAA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J,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGV,GAmBM8B,IAAU,CAAwB;AAAA,EACtC,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,MAAAd;AAAA,EACA,UAAApB;AAAA,EACA,GAAGE;AACL,MAAuB;AACrB,QAAMiC,IAAsBF,KAAeb;AAC3C,SACE,gBAAAL,EAACzB,GAAA,EAAM,GAAGY,GACP,UAAA;AAAA,IAAAiC,KACC,gBAAArB,EAACK,GAAA,EAAM,GAAGgB,GAAqB,mBAAkB,WAAU;AAAA,IAE5DnC,KAAY,gBAAAc,EAACc,GAAA,EAAM,UAAA5B,EAAA,CAAS;AAAA,IAC5BkC,KAAgB,gBAAApB,EAACK,GAAA,EAAM,GAAGe,GAAc,mBAAkB,WAAA,CAAW;AAAA,EAAA,GACxE;AAEJ;AAEA,OAAO,OAAOF,GAAS;AAAA,EACrB,MAAA1C;AAAA,EACA,MAAA6B;AAAA,EACA,MAAAS;AACF,CAAC;AAED,MAAMQ,IAASJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,YAAY,EAEZ,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,2BAA2B,EAChC,YAAY,EAEZ,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAW,IAAI,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,IAAI,IAAI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K,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAE1D,KAAK,gBAAgB,GACjB;IACE,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,GACD;IACE,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB,CAAC;AACN,KAAK,YAAY,CAAC,CAAC,SAAS,WAAW,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAC5D,kBAAkB,CAAC,OAAO,IAAI,CAAC,GAC/B,gBAAgB,CAAC;AAEnB,QAAA,MAAM,OAAO,GAAI,CAAC,SAAS,WAAW,EAAE,yDAMrC,YAAY,CAAC,CAAC,CAAC,4CAWjB,CAAC;AAQF,QAAA,MAAM,MAAM,EAAc,OAAO,OAAO,GAAG;IACzC,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,IAAI,EAAE,OAAO,IAAI,CAAC;CACnB,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telegraph/button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Button component in Telegraph",
|
|
5
5
|
"repository": "https://github.com/knocklabs/telegraph/tree/main/packages/button",
|
|
6
6
|
"author": "@knocklabs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@telegraph/helpers": "^0.0.13",
|
|
36
|
-
"@telegraph/icon": "^0.
|
|
36
|
+
"@telegraph/icon": "^0.3.0",
|
|
37
37
|
"@telegraph/layout": "^0.2.3",
|
|
38
38
|
"@telegraph/style-engine": "^0.1.16",
|
|
39
39
|
"@telegraph/typography": "^0.1.25",
|