@telegraph/tag 0.0.10 → 0.0.12
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 +19 -0
- package/README.md +3 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +23 -29
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/Tag/Tag.d.ts +4 -4
- package/dist/types/Tag/Tag.d.ts.map +1 -1
- package/dist/types/Tag/Tag.stories.d.ts +5 -1
- package/dist/types/Tag/Tag.stories.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @telegraph/tag
|
|
2
2
|
|
|
3
|
+
## 0.0.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`492be94`](https://github.com/knocklabs/telegraph/commit/492be943f4b403e9d590449a3af60f3d495d1f46)]:
|
|
8
|
+
- @telegraph/button@0.0.15
|
|
9
|
+
|
|
10
|
+
## 0.0.11
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#92](https://github.com/knocklabs/telegraph/pull/92) [`efbea6a`](https://github.com/knocklabs/telegraph/commit/efbea6a62e1f783a6dc3d2799a0aaab1a34d5e90) Thanks [@kylemcd](https://github.com/kylemcd)! - Updates to support lucide icon
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`efbea6a`](https://github.com/knocklabs/telegraph/commit/efbea6a62e1f783a6dc3d2799a0aaab1a34d5e90)]:
|
|
17
|
+
- @telegraph/button@0.0.14
|
|
18
|
+
- @telegraph/icon@0.0.8
|
|
19
|
+
- @telegraph/helpers@0.0.1
|
|
20
|
+
- @telegraph/typography@0.0.10
|
|
21
|
+
|
|
3
22
|
## 0.0.10
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -147,11 +147,11 @@ import { Tag } from '@telegraph/tag'
|
|
|
147
147
|
|
|
148
148
|
```
|
|
149
149
|
import { Tag } from "@telegraph/tag"
|
|
150
|
-
import {
|
|
150
|
+
import { Lucide } from '@telegraph/icon'
|
|
151
151
|
|
|
152
152
|
<Tag.Root color="blue" variant="solid" size="2">
|
|
153
|
-
<Tag.Icon icon={
|
|
153
|
+
<Tag.Icon icon={Lucide.Add} alt="Create"/>
|
|
154
154
|
<Tag.Text>Text</Tag.Text>
|
|
155
|
-
<Tag.Button icon={{ icon:
|
|
155
|
+
<Tag.Button icon={{ icon: Lucide.X, alt: "remove"}} onClick={() => {}}/>
|
|
156
156
|
</Tag.Root>
|
|
157
157
|
```
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),j=require("@telegraph/button"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),j=require("@telegraph/button"),u=require("@telegraph/icon"),R=require("@telegraph/typography"),s=require("clsx"),n=require("react"),m={Root:{1:"h-6",2:"h-8"}},i={Root:{solid:{default:"bg-gray-9",accent:"bg-accent-9",gray:"bg-gray-9",red:"bg-red-9",blue:"bg-blue-9",green:"bg-green-9",yellow:"bg-yellow-9",purple:"bg-purple-9"},soft:{default:"bg-gray-3",accent:"bg-accent-3",gray:"bg-gray-3",red:"bg-red-3",blue:"bg-blue-3",green:"bg-green-3",yellow:"bg-yellow-3",purple:"bg-purple-3"}},Icon:{solid:{default:"white",gray:"white",red:"white",accent:"white",blue:"white",green:"white",yellow:"white",purple:"white"},soft:{default:"default",gray:"gray",accent:"accent",red:"red",blue:"blue",green:"green",yellow:"yellow",purple:"purple"}},Text:{solid:{default:"white",gray:"white",accent:"white",red:"white",blue:"white",green:"white",yellow:"white",purple:"white"},soft:{default:"default",gray:"gray",accent:"accent",red:"red",blue:"blue",green:"green",yellow:"yellow",purple:"purple"}},Button:{solid:{default:"gray",gray:"gray",accent:"accent",red:"red",blue:"blue",green:"green",yellow:"yellow",purple:"purple"},soft:{default:"gray",gray:"gray",accent:"accent",red:"red",blue:"blue",green:"green",yellow:"yellow",purple:"purple"}}},d=n.createContext({size:"1",color:"default",variant:"soft"}),b=n.forwardRef(({size:t="1",color:r="default",variant:l="soft",className:e,...a},c)=>o.jsx(d.Provider,{value:{size:t,color:r,variant:l},children:o.jsx("span",{className:s.clsx("inline-flex items-center rounded-3 pl-2",m.Root[t],i.Root[l][r],e),...a,ref:c,"data-tag":!0})})),f=n.forwardRef(({as:t="span",className:r,...l},e)=>{const a=n.useContext(d);return o.jsx(R.Text,{as:t,size:a.size,color:i.Text[a.variant][a.color],className:s.clsx("rounded-tl-0 rounded-bl-0 mr-2",r),...l,ref:e})}),g=n.forwardRef(({className:t,...r},l)=>{const e=n.useContext(d);return o.jsx(j.Button,{size:e.size,color:i.Button[e.variant][e.color],variant:e.variant,icon:{icon:u.Lucide.X,alt:"close"},className:s.clsx("rounded-tl-0 rounded-bl-0",t),...r,ref:l})}),y=n.forwardRef(({className:t,...r},l)=>{const e=n.useContext(d);return o.jsx(u.Icon,{size:e.size,color:i.Icon[e.variant][e.color],className:s.clsx("rounded-tl-0 rounded-bl-0 mr-1",t),...r,ref:l})}),p=n.forwardRef(({color:t="default",size:r="1",variant:l="soft",icon:e,onRemove:a,onCopy:c,children:w,...x},h)=>o.jsxs(b,{color:t,size:r,variant:l,...x,ref:h,children:[e&&o.jsx(y,{...e}),o.jsx(f,{as:"span",children:w}),a&&o.jsx(g,{onClick:a,icon:{icon:u.Lucide.Copy,alt:"Copy Text"}}),c&&o.jsx(g,{onClick:c,icon:{icon:u.Lucide.X,alt:"Remove"}})]}));Object.assign(p,{Root:b,Button:g,Text:f,Icon:y});const C=p;exports.Tag=C;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Tag/Tag.constants.ts","../../src/Tag/Tag.tsx"],"sourcesContent":["export const SIZE = {\n Root: {\n \"1\": \"h-6\",\n \"2\": \"h-8\",\n },\n} as const;\n\nexport const COLOR = {\n Root: {\n solid: {\n default: \"bg-gray-9\",\n accent: \"bg-accent-9\",\n gray: \"bg-gray-9\",\n red: \"bg-red-9\",\n blue: \"bg-blue-9\",\n green: \"bg-green-9\",\n yellow: \"bg-yellow-9\",\n purple: \"bg-purple-9\",\n },\n soft: {\n default: \"bg-gray-3\",\n accent: \"bg-accent-3\",\n gray: \"bg-gray-3\",\n red: \"bg-red-3\",\n blue: \"bg-blue-3\",\n green: \"bg-green-3\",\n yellow: \"bg-yellow-3\",\n purple: \"bg-purple-3\",\n },\n },\n Icon: {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n blue: \"white\",\n green: \"white\",\n yellow: \"white\",\n purple: \"white\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n Text: {\n solid: {\n default: \"white\",\n gray: \"white\",\n accent: \"white\",\n red: \"white\",\n blue: \"white\",\n green: \"white\",\n yellow: \"white\",\n purple: \"white\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n Button: {\n solid: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n soft: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n} as const;\n","import { Button as TelegraphButton } from \"@telegraph/button\";\nimport type { Optional, Required } from \"@telegraph/helpers\";\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Tag/Tag.constants.ts","../../src/Tag/Tag.tsx"],"sourcesContent":["export const SIZE = {\n Root: {\n \"1\": \"h-6\",\n \"2\": \"h-8\",\n },\n} as const;\n\nexport const COLOR = {\n Root: {\n solid: {\n default: \"bg-gray-9\",\n accent: \"bg-accent-9\",\n gray: \"bg-gray-9\",\n red: \"bg-red-9\",\n blue: \"bg-blue-9\",\n green: \"bg-green-9\",\n yellow: \"bg-yellow-9\",\n purple: \"bg-purple-9\",\n },\n soft: {\n default: \"bg-gray-3\",\n accent: \"bg-accent-3\",\n gray: \"bg-gray-3\",\n red: \"bg-red-3\",\n blue: \"bg-blue-3\",\n green: \"bg-green-3\",\n yellow: \"bg-yellow-3\",\n purple: \"bg-purple-3\",\n },\n },\n Icon: {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n blue: \"white\",\n green: \"white\",\n yellow: \"white\",\n purple: \"white\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n Text: {\n solid: {\n default: \"white\",\n gray: \"white\",\n accent: \"white\",\n red: \"white\",\n blue: \"white\",\n green: \"white\",\n yellow: \"white\",\n purple: \"white\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n Button: {\n solid: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n soft: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n} as const;\n","import { Button as TelegraphButton } from \"@telegraph/button\";\nimport type { Optional, Required } from \"@telegraph/helpers\";\nimport { Lucide, Icon as TelegraphIcon } from \"@telegraph/icon\";\nimport { Text as TelegraphText } from \"@telegraph/typography\";\nimport { clsx } from \"clsx\";\nimport React from \"react\";\n\nimport { COLOR, SIZE } from \"./Tag.constants\";\n\ntype RootBaseProps = {\n size?: \"1\" | \"2\";\n color?: keyof (typeof COLOR.Root)[\"soft\"];\n variant?: keyof typeof COLOR.Root;\n};\n\ntype RootProps = React.HTMLAttributes<RootRef> & RootBaseProps;\n\ntype RootRef = HTMLSpanElement;\n\nconst TagContext = React.createContext<Required<RootBaseProps>>({\n size: \"1\",\n color: \"default\",\n variant: \"soft\",\n});\n\nconst Root = React.forwardRef<RootRef, RootProps>(\n (\n { size = \"1\", color = \"default\", variant = \"soft\", className, ...props },\n forwardedRef,\n ) => {\n return (\n <TagContext.Provider value={{ size, color, variant }}>\n <span\n className={clsx(\n \"inline-flex items-center rounded-3 pl-2\",\n SIZE.Root[size],\n COLOR.Root[variant][color],\n className,\n )}\n {...props}\n ref={forwardedRef}\n data-tag\n />\n </TagContext.Provider>\n );\n },\n);\n\ntype TextProps = Optional<React.ComponentProps<typeof TelegraphText>, \"as\">;\n\ntype TextRef = React.ElementRef<typeof TelegraphText>;\n\nconst Text = React.forwardRef<TextRef, TextProps>(\n ({ as = \"span\", className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphText\n as={as}\n size={context.size}\n color={COLOR.Text[context.variant][context.color]}\n className={clsx(\"rounded-tl-0 rounded-bl-0 mr-2\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype ButtonProps = React.ComponentProps<typeof TelegraphButton.Root>;\ntype ButtonRef = React.ElementRef<typeof TelegraphButton.Root>;\n\nconst Button = React.forwardRef<ButtonRef, ButtonProps>(\n ({ className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphButton\n size={context.size}\n color={COLOR.Button[context.variant][context.color]}\n variant={context.variant}\n icon={{ icon: Lucide.X, alt: \"close\" }}\n className={clsx(\"rounded-tl-0 rounded-bl-0\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype IconProps = React.ComponentProps<typeof TelegraphIcon>;\ntype IconRef = React.ElementRef<typeof TelegraphIcon>;\n\nconst Icon = React.forwardRef<IconRef, IconProps>(\n ({ className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphIcon\n size={context.size}\n color={COLOR.Icon[context.variant][context.color]}\n className={clsx(\"rounded-tl-0 rounded-bl-0 mr-1\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype DefaultProps = React.ComponentProps<typeof Root> & {\n icon?: React.ComponentProps<typeof TelegraphIcon>;\n onCopy?: () => void;\n onRemove?: () => void;\n};\ntype DefaultRef = React.ElementRef<typeof Root>;\n\nconst Default = React.forwardRef<DefaultRef, DefaultProps>(\n (\n {\n color = \"default\",\n size = \"1\",\n variant = \"soft\",\n icon,\n onRemove,\n onCopy,\n children,\n ...props\n },\n ref,\n ) => {\n return (\n <Root color={color} size={size} variant={variant} {...props} ref={ref}>\n {icon && <Icon {...icon} />}\n <Text as=\"span\">{children}</Text>\n {onRemove && (\n <Button\n onClick={onRemove}\n icon={{ icon: Lucide.Copy, alt: \"Copy Text\" }}\n />\n )}\n {onCopy && (\n <Button onClick={onCopy} icon={{ icon: Lucide.X, alt: \"Remove\" }} />\n )}\n </Root>\n );\n },\n);\n\nObject.assign(Default, {\n Root,\n Button,\n Text,\n Icon,\n});\n\nconst Tag = Default as typeof Default & {\n Root: typeof Root;\n Button: typeof Button;\n Text: typeof Text;\n Icon: typeof Icon;\n};\n\nexport { Tag };\n"],"names":["SIZE","COLOR","TagContext","React","Root","size","color","variant","className","props","forwardedRef","jsx","clsx","Text","as","context","TelegraphText","Button","TelegraphButton","Lucide","Icon","TelegraphIcon","Default","icon","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,EAAM,KAAKc,EAAQ,OAAO,EAAEA,EAAQ,KAAK,EAChD,UAAWH,EAAAA,KAAK,iCAAkCJ,CAAS,EAC1D,GAAGC,EACJ,IAAKC,CAAA,CAAA,CAGX,CACF,EASMY,EAAUnB,EAAM,WACpB,CACE,CACE,MAAAG,EAAQ,UACR,KAAAD,EAAO,IACP,QAAAE,EAAU,OAAA,KACVgB,EACA,SAAAC,EACA,OAAAC,EACA,SAAAC,EACA,GAAGjB,GAELkB,WAGGvB,EAAK,CAAA,MAAAE,EAAc,KAAAD,EAAY,QAAAE,EAAmB,GAAGE,EAAO,IAAAkB,EAC1D,SAAA,CAAQJ,GAAAZ,EAAAA,IAACS,EAAM,CAAA,GAAGG,CAAM,CAAA,EACxBZ,EAAAA,IAAAE,EAAA,CAAK,GAAG,OAAQ,SAAAa,CAAS,CAAA,EACzBF,GACCb,EAAA,IAACM,EAAA,CACC,QAASO,EACT,KAAM,CAAE,KAAML,EAAAA,OAAO,KAAM,IAAK,WAAY,CAAA,CAC9C,EAEDM,GACCd,EAAAA,IAACM,EAAO,CAAA,QAASQ,EAAQ,KAAM,CAAE,KAAMN,EAAAA,OAAO,EAAG,IAAK,QAAY,CAAA,CAAA,CAEtE,CAAA,CAAA,CAGN,EAEA,OAAO,OAAOG,EAAS,CACrB,KAAAlB,EACA,OAAAa,EACA,KAAAJ,EACA,KAAAO,CACF,CAAC,EAED,MAAMQ,EAAMN"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as l, jsxs as x } from "react/jsx-runtime";
|
|
2
2
|
import { Button as R } from "@telegraph/button";
|
|
3
|
-
import {
|
|
4
|
-
import { Text as
|
|
3
|
+
import { Lucide as g, Icon as C } from "@telegraph/icon";
|
|
4
|
+
import { Text as T } from "@telegraph/typography";
|
|
5
5
|
import { clsx as u } from "clsx";
|
|
6
6
|
import n from "react";
|
|
7
|
-
const
|
|
7
|
+
const v = {
|
|
8
8
|
Root: {
|
|
9
9
|
1: "h-6",
|
|
10
10
|
2: "h-8"
|
|
11
11
|
}
|
|
12
|
-
},
|
|
12
|
+
}, d = {
|
|
13
13
|
Root: {
|
|
14
14
|
solid: {
|
|
15
15
|
default: "bg-gray-9",
|
|
@@ -98,18 +98,18 @@ const z = {
|
|
|
98
98
|
purple: "purple"
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
},
|
|
101
|
+
}, s = n.createContext({
|
|
102
102
|
size: "1",
|
|
103
103
|
color: "default",
|
|
104
104
|
variant: "soft"
|
|
105
105
|
}), f = n.forwardRef(
|
|
106
|
-
({ size: t = "1", color: r = "default", variant: o = "soft", className: e, ...a }, c) => /* @__PURE__ */ l(
|
|
106
|
+
({ size: t = "1", color: r = "default", variant: o = "soft", className: e, ...a }, c) => /* @__PURE__ */ l(s.Provider, { value: { size: t, color: r, variant: o }, children: /* @__PURE__ */ l(
|
|
107
107
|
"span",
|
|
108
108
|
{
|
|
109
109
|
className: u(
|
|
110
110
|
"inline-flex items-center rounded-3 pl-2",
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
v.Root[t],
|
|
112
|
+
d.Root[o][r],
|
|
113
113
|
e
|
|
114
114
|
),
|
|
115
115
|
...a,
|
|
@@ -119,29 +119,29 @@ const z = {
|
|
|
119
119
|
) })
|
|
120
120
|
), p = n.forwardRef(
|
|
121
121
|
({ as: t = "span", className: r, ...o }, e) => {
|
|
122
|
-
const a = n.useContext(
|
|
122
|
+
const a = n.useContext(s);
|
|
123
123
|
return /* @__PURE__ */ l(
|
|
124
|
-
|
|
124
|
+
T,
|
|
125
125
|
{
|
|
126
126
|
as: t,
|
|
127
127
|
size: a.size,
|
|
128
|
-
color:
|
|
128
|
+
color: d.Text[a.variant][a.color],
|
|
129
129
|
className: u("rounded-tl-0 rounded-bl-0 mr-2", r),
|
|
130
130
|
...o,
|
|
131
131
|
ref: e
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
|
-
),
|
|
135
|
+
), i = n.forwardRef(
|
|
136
136
|
({ className: t, ...r }, o) => {
|
|
137
|
-
const e = n.useContext(
|
|
137
|
+
const e = n.useContext(s);
|
|
138
138
|
return /* @__PURE__ */ l(
|
|
139
139
|
R,
|
|
140
140
|
{
|
|
141
141
|
size: e.size,
|
|
142
|
-
color:
|
|
142
|
+
color: d.Button[e.variant][e.color],
|
|
143
143
|
variant: e.variant,
|
|
144
|
-
icon: { icon:
|
|
144
|
+
icon: { icon: g.X, alt: "close" },
|
|
145
145
|
className: u("rounded-tl-0 rounded-bl-0", t),
|
|
146
146
|
...r,
|
|
147
147
|
ref: o
|
|
@@ -150,12 +150,12 @@ const z = {
|
|
|
150
150
|
}
|
|
151
151
|
), w = n.forwardRef(
|
|
152
152
|
({ className: t, ...r }, o) => {
|
|
153
|
-
const e = n.useContext(
|
|
153
|
+
const e = n.useContext(s);
|
|
154
154
|
return /* @__PURE__ */ l(
|
|
155
155
|
C,
|
|
156
156
|
{
|
|
157
157
|
size: e.size,
|
|
158
|
-
color:
|
|
158
|
+
color: d.Icon[e.variant][e.color],
|
|
159
159
|
className: u("rounded-tl-0 rounded-bl-0 mr-1", t),
|
|
160
160
|
...r,
|
|
161
161
|
ref: o
|
|
@@ -176,29 +176,23 @@ const z = {
|
|
|
176
176
|
e && /* @__PURE__ */ l(w, { ...e }),
|
|
177
177
|
/* @__PURE__ */ l(p, { as: "span", children: y }),
|
|
178
178
|
a && /* @__PURE__ */ l(
|
|
179
|
-
|
|
179
|
+
i,
|
|
180
180
|
{
|
|
181
181
|
onClick: a,
|
|
182
|
-
icon: { icon:
|
|
182
|
+
icon: { icon: g.Copy, alt: "Copy Text" }
|
|
183
183
|
}
|
|
184
184
|
),
|
|
185
|
-
c && /* @__PURE__ */ l(
|
|
186
|
-
g,
|
|
187
|
-
{
|
|
188
|
-
onClick: c,
|
|
189
|
-
icon: { icon: T, alt: "Remove" }
|
|
190
|
-
}
|
|
191
|
-
)
|
|
185
|
+
c && /* @__PURE__ */ l(i, { onClick: c, icon: { icon: g.X, alt: "Remove" } })
|
|
192
186
|
] })
|
|
193
187
|
);
|
|
194
188
|
Object.assign(b, {
|
|
195
189
|
Root: f,
|
|
196
|
-
Button:
|
|
190
|
+
Button: i,
|
|
197
191
|
Text: p,
|
|
198
192
|
Icon: w
|
|
199
193
|
});
|
|
200
|
-
const
|
|
194
|
+
const $ = b;
|
|
201
195
|
export {
|
|
202
|
-
|
|
196
|
+
$ as Tag
|
|
203
197
|
};
|
|
204
198
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Tag/Tag.constants.ts","../../src/Tag/Tag.tsx"],"sourcesContent":["export const SIZE = {\n Root: {\n \"1\": \"h-6\",\n \"2\": \"h-8\",\n },\n} as const;\n\nexport const COLOR = {\n Root: {\n solid: {\n default: \"bg-gray-9\",\n accent: \"bg-accent-9\",\n gray: \"bg-gray-9\",\n red: \"bg-red-9\",\n blue: \"bg-blue-9\",\n green: \"bg-green-9\",\n yellow: \"bg-yellow-9\",\n purple: \"bg-purple-9\",\n },\n soft: {\n default: \"bg-gray-3\",\n accent: \"bg-accent-3\",\n gray: \"bg-gray-3\",\n red: \"bg-red-3\",\n blue: \"bg-blue-3\",\n green: \"bg-green-3\",\n yellow: \"bg-yellow-3\",\n purple: \"bg-purple-3\",\n },\n },\n Icon: {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n blue: \"white\",\n green: \"white\",\n yellow: \"white\",\n purple: \"white\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n Text: {\n solid: {\n default: \"white\",\n gray: \"white\",\n accent: \"white\",\n red: \"white\",\n blue: \"white\",\n green: \"white\",\n yellow: \"white\",\n purple: \"white\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n Button: {\n solid: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n soft: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n} as const;\n","import { Button as TelegraphButton } from \"@telegraph/button\";\nimport type { Optional, Required } from \"@telegraph/helpers\";\nimport {\n Icon as TelegraphIcon,\n closeSharp,\n copyOutline,\n} from \"@telegraph/icon\";\nimport { Text as TelegraphText } from \"@telegraph/typography\";\nimport { clsx } from \"clsx\";\nimport React from \"react\";\n\nimport { COLOR, SIZE } from \"./Tag.constants\";\n\ntype RootBaseProps = {\n size?: \"1\" | \"2\";\n color?: keyof (typeof COLOR.Root)[\"soft\"];\n variant?: keyof typeof COLOR.Root;\n};\n\ntype RootProps = React.HTMLAttributes<RootRef> & RootBaseProps;\n\ntype RootRef = HTMLSpanElement;\n\nconst TagContext = React.createContext<Required<RootBaseProps>>({\n size: \"1\",\n color: \"default\",\n variant: \"soft\",\n});\n\nconst Root = React.forwardRef<RootRef, RootProps>(\n (\n { size = \"1\", color = \"default\", variant = \"soft\", className, ...props },\n forwardedRef,\n ) => {\n return (\n <TagContext.Provider value={{ size, color, variant }}>\n <span\n className={clsx(\n \"inline-flex items-center rounded-3 pl-2\",\n SIZE.Root[size],\n COLOR.Root[variant][color],\n className,\n )}\n {...props}\n ref={forwardedRef}\n data-tag\n />\n </TagContext.Provider>\n );\n },\n);\n\ntype TextProps = Optional<React.ComponentProps<typeof TelegraphText>, \"as\">;\n\ntype TextRef = React.ElementRef<typeof TelegraphText>;\n\nconst Text = React.forwardRef<TextRef, TextProps>(\n ({ as = \"span\", className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphText\n as={as}\n size={context.size}\n color={COLOR.Text[context.variant][context.color]}\n className={clsx(\"rounded-tl-0 rounded-bl-0 mr-2\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype ButtonProps = React.ComponentProps<typeof TelegraphButton.Root>;\ntype ButtonRef = React.ElementRef<typeof TelegraphButton.Root>;\n\nconst Button = React.forwardRef<ButtonRef, ButtonProps>(\n ({ className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphButton\n size={context.size}\n color={COLOR.Button[context.variant][context.color]}\n variant={context.variant}\n icon={{ icon: closeSharp, alt: \"close\" }}\n className={clsx(\"rounded-tl-0 rounded-bl-0\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype IconProps = React.ComponentProps<typeof TelegraphIcon>;\ntype IconRef = React.ElementRef<typeof TelegraphIcon>;\n\nconst Icon = React.forwardRef<IconRef, IconProps>(\n ({ className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphIcon\n size={context.size}\n color={COLOR.Icon[context.variant][context.color]}\n className={clsx(\"rounded-tl-0 rounded-bl-0 mr-1\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype DefaultProps = React.ComponentProps<typeof Root> & {\n icon?: React.ComponentProps<typeof TelegraphIcon>;\n onCopy?: () => void;\n onRemove?: () => void;\n};\ntype DefaultRef = React.ElementRef<typeof Root>;\n\nconst Default = React.forwardRef<DefaultRef, DefaultProps>(\n (\n {\n color = \"default\",\n size = \"1\",\n variant = \"soft\",\n icon,\n onRemove,\n onCopy,\n children,\n ...props\n },\n ref,\n ) => {\n return (\n <Root color={color} size={size} variant={variant} {...props} ref={ref}>\n {icon && <Icon {...icon} />}\n <Text as=\"span\">{children}</Text>\n {onRemove && (\n <Button\n onClick={onRemove}\n icon={{ icon: closeSharp, alt: \"Copy Text\" }}\n />\n )}\n {onCopy && (\n <Button\n onClick={onCopy}\n icon={{ icon: copyOutline, alt: \"Remove\" }}\n />\n )}\n </Root>\n );\n },\n);\n\nObject.assign(Default, {\n Root,\n Button,\n Text,\n Icon,\n});\n\nconst Tag = Default as typeof Default & {\n Root: typeof Root;\n Button: typeof Button;\n Text: typeof Text;\n Icon: typeof Icon;\n};\n\nexport { Tag };\n"],"names":["SIZE","COLOR","TagContext","React","Root","size","color","variant","className","props","forwardedRef","jsx","clsx","Text","as","context","TelegraphText","Button","TelegraphButton","closeSharp","Icon","TelegraphIcon","Default","icon","onRemove","onCopy","children","ref","copyOutline","Tag"],"mappings":";;;;;;AAAO,MAAMA,IAAO;AAAA,EAClB,MAAM;AAAA,IACJ,GAAK;AAAA,IACL,GAAK;AAAA,EACP;AACF,GAEaC,IAAQ;AAAA,EACnB,MAAM;AAAA,IACJ,OAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM;AAAA,MACN,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EACA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H,EAAK,kCAAkCJ,CAAS;AAAA,QAC1D,GAAGC;AAAA,QACJ,KAAKC;AAAA,MAAA;AAAA,IAAA;AAAA,EAGX;AACF,GASMY,IAAUnB,EAAM;AAAA,EACpB,CACE;AAAA,IACE,OAAAG,IAAQ;AAAA,IACR,MAAAD,IAAO;AAAA,IACP,SAAAE,IAAU;AAAA,IACV,MAAAgB;AAAA,IACA,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGjB;AAAA,KAELkB,wBAGGvB,GAAK,EAAA,OAAAE,GAAc,MAAAD,GAAY,SAAAE,GAAmB,GAAGE,GAAO,KAAAkB,GAC1D,UAAA;AAAA,IAAQJ,KAAA,gBAAAZ,EAACS,GAAM,EAAA,GAAGG,EAAM,CAAA;AAAA,IACxB,gBAAAZ,EAAAE,GAAA,EAAK,IAAG,QAAQ,UAAAa,EAAS,CAAA;AAAA,IACzBF,KACC,gBAAAb;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,SAASO;AAAA,QACT,MAAM,EAAE,MAAML,GAAY,KAAK,YAAY;AAAA,MAAA;AAAA,IAC7C;AAAA,IAEDM,KACC,gBAAAd;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,SAASQ;AAAA,QACT,MAAM,EAAE,MAAMG,GAAa,KAAK,SAAS;AAAA,MAAA;AAAA,IAC3C;AAAA,EAEJ,EAAA,CAAA;AAGN;AAEA,OAAO,OAAON,GAAS;AAAA,EACrB,MAAAlB;AAAA,EACA,QAAAa;AAAA,EACA,MAAAJ;AAAA,EACA,MAAAO;AACF,CAAC;AAED,MAAMS,IAAMP;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Tag/Tag.constants.ts","../../src/Tag/Tag.tsx"],"sourcesContent":["export const SIZE = {\n Root: {\n \"1\": \"h-6\",\n \"2\": \"h-8\",\n },\n} as const;\n\nexport const COLOR = {\n Root: {\n solid: {\n default: \"bg-gray-9\",\n accent: \"bg-accent-9\",\n gray: \"bg-gray-9\",\n red: \"bg-red-9\",\n blue: \"bg-blue-9\",\n green: \"bg-green-9\",\n yellow: \"bg-yellow-9\",\n purple: \"bg-purple-9\",\n },\n soft: {\n default: \"bg-gray-3\",\n accent: \"bg-accent-3\",\n gray: \"bg-gray-3\",\n red: \"bg-red-3\",\n blue: \"bg-blue-3\",\n green: \"bg-green-3\",\n yellow: \"bg-yellow-3\",\n purple: \"bg-purple-3\",\n },\n },\n Icon: {\n solid: {\n default: \"white\",\n gray: \"white\",\n red: \"white\",\n accent: \"white\",\n blue: \"white\",\n green: \"white\",\n yellow: \"white\",\n purple: \"white\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n Text: {\n solid: {\n default: \"white\",\n gray: \"white\",\n accent: \"white\",\n red: \"white\",\n blue: \"white\",\n green: \"white\",\n yellow: \"white\",\n purple: \"white\",\n },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n Button: {\n solid: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n soft: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n purple: \"purple\",\n },\n },\n} as const;\n","import { Button as TelegraphButton } from \"@telegraph/button\";\nimport type { Optional, Required } from \"@telegraph/helpers\";\nimport { Lucide, Icon as TelegraphIcon } from \"@telegraph/icon\";\nimport { Text as TelegraphText } from \"@telegraph/typography\";\nimport { clsx } from \"clsx\";\nimport React from \"react\";\n\nimport { COLOR, SIZE } from \"./Tag.constants\";\n\ntype RootBaseProps = {\n size?: \"1\" | \"2\";\n color?: keyof (typeof COLOR.Root)[\"soft\"];\n variant?: keyof typeof COLOR.Root;\n};\n\ntype RootProps = React.HTMLAttributes<RootRef> & RootBaseProps;\n\ntype RootRef = HTMLSpanElement;\n\nconst TagContext = React.createContext<Required<RootBaseProps>>({\n size: \"1\",\n color: \"default\",\n variant: \"soft\",\n});\n\nconst Root = React.forwardRef<RootRef, RootProps>(\n (\n { size = \"1\", color = \"default\", variant = \"soft\", className, ...props },\n forwardedRef,\n ) => {\n return (\n <TagContext.Provider value={{ size, color, variant }}>\n <span\n className={clsx(\n \"inline-flex items-center rounded-3 pl-2\",\n SIZE.Root[size],\n COLOR.Root[variant][color],\n className,\n )}\n {...props}\n ref={forwardedRef}\n data-tag\n />\n </TagContext.Provider>\n );\n },\n);\n\ntype TextProps = Optional<React.ComponentProps<typeof TelegraphText>, \"as\">;\n\ntype TextRef = React.ElementRef<typeof TelegraphText>;\n\nconst Text = React.forwardRef<TextRef, TextProps>(\n ({ as = \"span\", className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphText\n as={as}\n size={context.size}\n color={COLOR.Text[context.variant][context.color]}\n className={clsx(\"rounded-tl-0 rounded-bl-0 mr-2\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype ButtonProps = React.ComponentProps<typeof TelegraphButton.Root>;\ntype ButtonRef = React.ElementRef<typeof TelegraphButton.Root>;\n\nconst Button = React.forwardRef<ButtonRef, ButtonProps>(\n ({ className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphButton\n size={context.size}\n color={COLOR.Button[context.variant][context.color]}\n variant={context.variant}\n icon={{ icon: Lucide.X, alt: \"close\" }}\n className={clsx(\"rounded-tl-0 rounded-bl-0\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype IconProps = React.ComponentProps<typeof TelegraphIcon>;\ntype IconRef = React.ElementRef<typeof TelegraphIcon>;\n\nconst Icon = React.forwardRef<IconRef, IconProps>(\n ({ className, ...props }, forwardedRef) => {\n const context = React.useContext(TagContext);\n return (\n <TelegraphIcon\n size={context.size}\n color={COLOR.Icon[context.variant][context.color]}\n className={clsx(\"rounded-tl-0 rounded-bl-0 mr-1\", className)}\n {...props}\n ref={forwardedRef}\n />\n );\n },\n);\n\ntype DefaultProps = React.ComponentProps<typeof Root> & {\n icon?: React.ComponentProps<typeof TelegraphIcon>;\n onCopy?: () => void;\n onRemove?: () => void;\n};\ntype DefaultRef = React.ElementRef<typeof Root>;\n\nconst Default = React.forwardRef<DefaultRef, DefaultProps>(\n (\n {\n color = \"default\",\n size = \"1\",\n variant = \"soft\",\n icon,\n onRemove,\n onCopy,\n children,\n ...props\n },\n ref,\n ) => {\n return (\n <Root color={color} size={size} variant={variant} {...props} ref={ref}>\n {icon && <Icon {...icon} />}\n <Text as=\"span\">{children}</Text>\n {onRemove && (\n <Button\n onClick={onRemove}\n icon={{ icon: Lucide.Copy, alt: \"Copy Text\" }}\n />\n )}\n {onCopy && (\n <Button onClick={onCopy} icon={{ icon: Lucide.X, alt: \"Remove\" }} />\n )}\n </Root>\n );\n },\n);\n\nObject.assign(Default, {\n Root,\n Button,\n Text,\n Icon,\n});\n\nconst Tag = Default as typeof Default & {\n Root: typeof Root;\n Button: typeof Button;\n Text: typeof Text;\n Icon: typeof Icon;\n};\n\nexport { Tag };\n"],"names":["SIZE","COLOR","TagContext","React","Root","size","color","variant","className","props","forwardedRef","jsx","clsx","Text","as","context","TelegraphText","Button","TelegraphButton","Lucide","Icon","TelegraphIcon","Default","icon","onRemove","onCopy","children","ref","Tag"],"mappings":";;;;;;AAAO,MAAMA,IAAO;AAAA,EAClB,MAAM;AAAA,IACJ,GAAK;AAAA,IACL,GAAK;AAAA,EACP;AACF,GAEaC,IAAQ;AAAA,EACnB,MAAM;AAAA,IACJ,OAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO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AAAA,QACT,MAAM,EAAE,MAAML,EAAO,MAAM,KAAK,YAAY;AAAA,MAAA;AAAA,IAC9C;AAAA,IAEDM,KACC,gBAAAd,EAACM,GAAO,EAAA,SAASQ,GAAQ,MAAM,EAAE,MAAMN,EAAO,GAAG,KAAK,SAAY,EAAA,CAAA;AAAA,EAEtE,EAAA,CAAA;AAGN;AAEA,OAAO,OAAOG,GAAS;AAAA,EACrB,MAAAlB;AAAA,EACA,QAAAa;AAAA,EACA,MAAAJ;AAAA,EACA,MAAAO;AACF,CAAC;AAED,MAAMQ,IAAMN;"}
|
package/dist/types/Tag/Tag.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Icon as TelegraphIcon } from "@telegraph/icon";
|
|
1
|
+
import { Lucide, Icon as TelegraphIcon } from "@telegraph/icon";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { COLOR } from "./Tag.constants";
|
|
4
4
|
type RootBaseProps = {
|
|
@@ -29,13 +29,13 @@ declare const Button: React.ForwardRefExoticComponent<Omit<import("@telegraph/he
|
|
|
29
29
|
} & {
|
|
30
30
|
ref?: (string | React.Ref<HTMLButtonElement>) | undefined;
|
|
31
31
|
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
32
|
-
declare const Icon: React.ForwardRefExoticComponent<Omit<
|
|
33
|
-
icon:
|
|
32
|
+
declare const Icon: React.ForwardRefExoticComponent<Omit<{
|
|
33
|
+
icon: React.ForwardRefExoticComponent<Omit<Lucide.LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
34
34
|
alt: string;
|
|
35
35
|
size?: "1" | "2" | "0" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
|
|
36
36
|
variant?: "primary" | "secondary" | undefined;
|
|
37
37
|
color?: "white" | "default" | "gray" | "accent" | "red" | "blue" | "green" | "yellow" | "purple" | "beige" | "disabled" | undefined;
|
|
38
|
-
} & React.RefAttributes<
|
|
38
|
+
} & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<SVGSVGElement>, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
39
39
|
type DefaultProps = React.ComponentProps<typeof Root> & {
|
|
40
40
|
icon?: React.ComponentProps<typeof TelegraphIcon>;
|
|
41
41
|
onCopy?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["../../../src/Tag/Tag.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["../../../src/Tag/Tag.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAQ,MAAM,iBAAiB,CAAC;AAE9C,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,MAAM,OAAO,KAAK,CAAC,IAAI,CAAC;CACnC,CAAC;AAYF,QAAA,MAAM,IAAI,+HAqBT,CAAC;AAMF,QAAA,MAAM,IAAI;;;;;;;;;;;;wPAcT,CAAC;AAKF,QAAA,MAAM,MAAM;;;;;;;;mDAeX,CAAC;AAKF,QAAA,MAAM,IAAI;;;;;;2HAaT,CAAC;AAEF,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG;IACtD,IAAI,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AA0CF,QAAA,MAAM,GAAG;UACD,WAAW;YACT,aAAa;UACf,WAAW;UACX,WAAW;CAClB,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
3
|
import { Tag as TelegraphTag } from "./Tag";
|
|
3
4
|
declare const meta: Meta<typeof TelegraphTag>;
|
|
4
5
|
export default meta;
|
|
5
|
-
type
|
|
6
|
+
type StorybookTagType = Omit<React.ComponentProps<typeof TelegraphTag>, "icon"> & {
|
|
7
|
+
icon?: string;
|
|
8
|
+
};
|
|
9
|
+
type Story = StoryObj<StorybookTagType>;
|
|
6
10
|
export declare const Tag: Story;
|
|
7
11
|
//# sourceMappingURL=Tag.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.stories.d.ts","sourceRoot":"","sources":["../../../src/Tag/Tag.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Tag.stories.d.ts","sourceRoot":"","sources":["../../../src/Tag/Tag.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,OAAO,CAAC;AAK5C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,YAAY,CAwCnC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,gBAAgB,GAAG,IAAI,CAC1B,KAAK,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,EACzC,MAAM,CACP,GAAG;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,KAAK,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAExC,eAAO,MAAM,GAAG,EAAE,KAoBjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telegraph/tag",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"repository": "https://github.com/knocklabs/telegraph/tree/main/packages/tag",
|
|
5
5
|
"author": "@knocklabs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"preview": "vite preview"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@telegraph/button": "^0.0.
|
|
37
|
+
"@telegraph/button": "^0.0.15",
|
|
38
38
|
"@telegraph/helpers": "^0.0.1",
|
|
39
|
-
"@telegraph/icon": "^0.0.
|
|
39
|
+
"@telegraph/icon": "^0.0.8",
|
|
40
40
|
"@telegraph/typography": "^0.0.10",
|
|
41
41
|
"clsx": "^2.1.0"
|
|
42
42
|
},
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"@knocklabs/eslint-config": "^0.0.3",
|
|
45
45
|
"@knocklabs/prettier-config": "^0.0.1",
|
|
46
46
|
"@knocklabs/typescript-config": "^0.0.2",
|
|
47
|
-
"@telegraph/postcss-config": "^0.0.
|
|
48
|
-
"@telegraph/tailwind-config": "^0.0.
|
|
49
|
-
"@telegraph/vite-config": "^0.0.
|
|
47
|
+
"@telegraph/postcss-config": "^0.0.13",
|
|
48
|
+
"@telegraph/tailwind-config": "^0.0.11",
|
|
49
|
+
"@telegraph/vite-config": "^0.0.9",
|
|
50
50
|
"@telegraph/vitest-config": "^0.0.6",
|
|
51
51
|
"@types/react": "^18.2.48",
|
|
52
52
|
"eslint": "^8.56.0",
|
|
53
53
|
"react": "^18.2.0",
|
|
54
54
|
"react-dom": "^18.2.0",
|
|
55
55
|
"typescript": "^5.3.3",
|
|
56
|
-
"vite": "^5.
|
|
56
|
+
"vite": "^5.1.7",
|
|
57
57
|
"vitest": "^1.2.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|