@telegraph/tag 0.0.1
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 +10 -0
- package/README.md +153 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/css/default.css +1 -0
- package/dist/esm/index.mjs +196 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/Tag/Tag.constants.d.ts +89 -0
- package/dist/types/Tag/Tag.constants.d.ts.map +1 -0
- package/dist/types/Tag/Tag.d.ts +41 -0
- package/dist/types/Tag/Tag.d.ts.map +1 -0
- package/dist/types/Tag/index.d.ts +2 -0
- package/dist/types/Tag/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +62 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @telegraph/tag
|
|
2
|
+
|
|
3
|
+
## 0.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#58](https://github.com/knocklabs/telegraph/pull/58) [`8a5298e`](https://github.com/knocklabs/telegraph/commit/8a5298e344c55dfa38553f1df09f17d90aa78951) Thanks [@kylemcd](https://github.com/kylemcd)! - telegraph component and supporting updates
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`8a5298e`](https://github.com/knocklabs/telegraph/commit/8a5298e344c55dfa38553f1df09f17d90aa78951)]:
|
|
10
|
+
- @telegraph/button@0.0.5
|
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@telegraph/tag)
|
|
4
|
+
|
|
5
|
+
# @telegraph/tag
|
|
6
|
+
> A tag component with optional interactive button
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Installation Instructions
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install @telegraph/tag
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Add stylesheet
|
|
17
|
+
Pick one:
|
|
18
|
+
|
|
19
|
+
Via CSS (preferred):
|
|
20
|
+
```
|
|
21
|
+
@import "@telegraph/tag"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Via Javascript:
|
|
25
|
+
```
|
|
26
|
+
import "@telegraph/tag/default.css"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> Then, include `className="tgph"` on the farthest parent element wrapping the telegraph components
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Basic Usage
|
|
34
|
+
Shorthand tag component that adheres to the telegraph design system
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
import { Tag } from "@telegraph/tag"
|
|
38
|
+
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
<Tag>Tag</Tag>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Props
|
|
45
|
+
|
|
46
|
+
| Name | Type | Default | Options |
|
|
47
|
+
| ---- | -----| ------- | ------- |
|
|
48
|
+
| size | string | "1" | "1" "2" |
|
|
49
|
+
| color | string | "default" | "default", "gray", "red", "accent", "blue", "green", "yellow" |
|
|
50
|
+
| variant | string | "soft" | "soft", "solid"|
|
|
51
|
+
| icon | [Icon Props](https://github.com/knocklabs/telegraph/tree/main/packages/icon#props) | `undefined` | |
|
|
52
|
+
| onRemove | () => {} | `undefined` | |
|
|
53
|
+
| onCopy | () => {} | `undefined` | |
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Advanced Usage
|
|
57
|
+
Individual parts of the tag component that can be composed in configurations different from the default telegraph design system styles. This can be used to create modifications to one-off tag components without the need to modify the tag exported from this package.
|
|
58
|
+
|
|
59
|
+
#### `<Tag.Root/>`
|
|
60
|
+
Wraps the Tag children components and relays props to them.
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
import { Tag } from '@telegraph/tag'
|
|
64
|
+
|
|
65
|
+
...
|
|
66
|
+
|
|
67
|
+
<Tag.Root></Tag.Root>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Props
|
|
71
|
+
|
|
72
|
+
| Name | Type | Default | Options |
|
|
73
|
+
| ---- | -----| ------- | ------- |
|
|
74
|
+
| size | string | "1" | "1" "2" |
|
|
75
|
+
| color | string | "default" | "default", "gray", "red", "accent", "blue", "green", "yellow" |
|
|
76
|
+
| variant | string | "soft" | "soft", "solid"|
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
#### `<Tag.Text/>`
|
|
81
|
+
A component built on top of the Text component from [@telegraph/typography](https://github.com/knocklabs/telegraph/tree/main/packages/typography) with translated props to adhere to the telegraph design system
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
import { Tag } from '@telegraph/tag'
|
|
85
|
+
|
|
86
|
+
...
|
|
87
|
+
|
|
88
|
+
<Tag.Text>Text</Tag.Text>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
##### Props
|
|
92
|
+
|
|
93
|
+
> See [text props](https://github.com/knocklabs/telegraph/tree/main/packages/typography)
|
|
94
|
+
|
|
95
|
+
#### `<Tag.Button/>`
|
|
96
|
+
A component build on top of the Button component from [@telegraph/button](https://github.com/knocklabs/telegraph/tree/main/packages/button)
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
import { Tag } from '@telegraph/tag'
|
|
100
|
+
|
|
101
|
+
...
|
|
102
|
+
|
|
103
|
+
<Tag.Button/>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### Props
|
|
107
|
+
|
|
108
|
+
> See [button props](https://github.com/knocklabs/telegraph/tree/main/packages/icon#props)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
#### `<Tag.Text/>`
|
|
112
|
+
A component built on top of the Text component from [@telegraph/typography](https://github.com/knocklabs/telegraph/tree/main/packages/typography) with translated props to adhere to the telegraph design system
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
import { Tag } from '@telegraph/tag'
|
|
116
|
+
|
|
117
|
+
...
|
|
118
|
+
|
|
119
|
+
<Tag.Text>Text</Tag.Text>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
##### Props
|
|
123
|
+
|
|
124
|
+
> See [text props](https://github.com/knocklabs/telegraph/tree/main/packages/typography)
|
|
125
|
+
|
|
126
|
+
#### `<Tag.Icon/>`
|
|
127
|
+
A component build on top of the Icon component from [@telegraph/icon](https://github.com/knocklabs/telegraph/tree/main/packages/icon)
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
import { Tag } from '@telegraph/tag'
|
|
131
|
+
|
|
132
|
+
...
|
|
133
|
+
|
|
134
|
+
<Tag.Icon icon={addSharp} alt="create"/>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### Props
|
|
138
|
+
|
|
139
|
+
> See [icon props](https://github.com/knocklabs/telegraph/tree/main/packages/icon)
|
|
140
|
+
|
|
141
|
+
#### An example of composing an advanced Tag
|
|
142
|
+
```
|
|
143
|
+
import { Tag } from "@telegraph/tag"
|
|
144
|
+
import { addSharp, closeSharp } from '@telegraph/icon'
|
|
145
|
+
|
|
146
|
+
<Tag.Root color="blue" variant="solid" size="2">
|
|
147
|
+
<Tag.Icon icon={addSharp} alt="Create"/>
|
|
148
|
+
<Tag.Text>Text</Tag.Text>
|
|
149
|
+
<Tag.Button icon={{ icon: removeSharp, alt: "remove"}} onClick={() => {}}/>
|
|
150
|
+
</Tag.Root>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),R=require("@telegraph/button"),s=require("@telegraph/icon"),m=require("@telegraph/typography"),u=require("clsx"),n=require("react"),p={Root:{1:"h-6",2:"h-8"}},d={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"},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"}},Icon:{solid:{default:"white",gray:"white",red:"white",accent:"white",blue:"white",green:"white",yellow:"white"},soft:{default:"default",gray:"gray",accent:"accent",red:"red",blue:"blue",green:"green",yellow:"yellow"}},Text:{solid:{default:"white",gray:"white",accent:"white",red:"white",blue:"white",green:"white",yellow:"white"},soft:{default:"default",gray:"gray",accent:"accent",red:"red",blue:"blue",green:"green",yellow:"yellow"}},Button:{solid:{default:"gray",gray:"gray",accent:"accent",red:"red",blue:"blue",green:"green",yellow:"yellow"},soft:{default:"gray",gray:"gray",accent:"accent",red:"red",blue:"blue",green:"green",yellow:"yellow"}}},i=n.createContext({size:"1",color:"default",variant:"soft"}),f=n.forwardRef(({size:t="1",color:r="default",variant:o="soft",className:e,...a},c)=>l.jsx(i.Provider,{value:{size:t,color:r,variant:o},children:l.jsx("span",{className:u.clsx("inline-flex items-center rounded-3 pl-2",p.Root[t],d.Root[o][r],e),...a,ref:c,"data-tag":!0})})),y=n.forwardRef(({as:t="span",className:r,...o},e)=>{const a=n.useContext(i);return l.jsx(m.Text,{as:t,size:a.size,color:d.Text[a.variant][a.color],className:u.clsx("rounded-tl-0 rounded-bl-0 mr-2",r),...o,ref:e})}),g=n.forwardRef(({className:t,...r},o)=>{const e=n.useContext(i);return l.jsx(R.Button,{size:e.size,color:d.Button[e.variant][e.color],variant:e.variant,icon:{icon:s.closeSharp,alt:"close"},className:u.clsx("rounded-tl-0 rounded-bl-0",t),...r,ref:o})}),b=n.forwardRef(({className:t,...r},o)=>{const e=n.useContext(i);return l.jsx(s.Icon,{size:e.size,color:d.Icon[e.variant][e.color],className:u.clsx("rounded-tl-0 rounded-bl-0 mr-1",t),...r,ref:o})}),w=n.forwardRef(({color:t="default",size:r="1",variant:o="soft",icon:e,onRemove:a,onCopy:c,children:x,...h},j)=>l.jsxs(f,{color:t,size:r,variant:o,...h,ref:j,children:[e&&l.jsx(b,{...e}),l.jsx(y,{children:x}),a&&l.jsx(g,{onClick:a,icon:{icon:s.closeSharp,alt:"Copy Text"}}),c&&l.jsx(g,{onClick:c,icon:{icon:s.copyOutline,alt:"Remove"}})]}));Object.assign(w,{Root:f,Button:g,Text:y,Icon:b});const T=w;exports.Tag=T;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 },\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 },\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 },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\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 },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\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 },\n soft: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n },\n },\n} as const;\n","import { Button as TelegraphButton } from \"@telegraph/button\";\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?: React.ComponentProps<typeof TelegraphButton>[\"color\"] & \"default\";\n variant?: \"soft\" | \"solid\";\n};\n\ntype RootProps = React.HTMLAttributes<RootRef> & RootBaseProps;\n\ntype RootRef = HTMLSpanElement;\n\nconst TagContext = React.createContext<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 = Omit<React.ComponentProps<typeof TelegraphText>, \"as\"> & {\n as: React.ComponentProps<typeof TelegraphText>[\"as\"];\n};\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 text: string;\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>{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":"yPAAaA,EAAO,CAClB,KAAM,CACJ,EAAK,MACL,EAAK,KACP,CACF,EAEaC,EAAQ,CACnB,KAAM,CACJ,MAAO,CACL,QAAS,YACT,OAAQ,cACR,KAAM,YACN,IAAK,WACL,KAAM,YACN,MAAO,aACP,OAAQ,aACV,EACA,KAAM,CACJ,QAAS,YACT,OAAQ,cACR,KAAM,YACN,IAAK,WACL,KAAM,YACN,MAAO,aACP,OAAQ,aACV,CACF,EACA,KAAM,CACJ,MAAO,CACL,QAAS,QACT,KAAM,QACN,IAAK,QACL,OAAQ,QACR,KAAM,QACN,MAAO,QACP,OAAQ,OACV,EACA,KAAM,CACJ,QAAS,UACT,KAAM,OACN,OAAQ,SACR,IAAK,MACL,KAAM,OACN,MAAO,QACP,OAAQ,QACV,CACF,EACA,KAAM,CACJ,MAAO,CACL,QAAS,QACT,KAAM,QACN,OAAQ,QACR,IAAK,QACL,KAAM,QACN,MAAO,QACP,OAAQ,OACV,EACA,KAAM,CACJ,QAAS,UACT,KAAM,OACN,OAAQ,SACR,IAAK,MACL,KAAM,OACN,MAAO,QACP,OAAQ,QACV,CACF,EACA,OAAQ,CACN,MAAO,CACL,QAAS,OACT,KAAM,OACN,OAAQ,SACR,IAAK,MACL,KAAM,OACN,MAAO,QACP,OAAQ,QACV,EACA,KAAM,CACJ,QAAS,OACT,KAAM,OACN,OAAQ,SACR,IAAK,MACL,KAAM,OACN,MAAO,QACP,OAAQ,QACV,CACF,CACF,EClEMC,EAAaC,EAAM,cAA6B,CACpD,KAAM,IACN,MAAO,UACP,QAAS,MACX,CAAC,EAEKC,EAAOD,EAAM,WACjB,CACE,CAAE,KAAAE,EAAO,IAA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AAAS,EAAA,IAACU,EAAA,KAAA,CACC,KAAMN,EAAQ,KACd,MAAOd,EAAM,KAAKc,EAAQ,OAAO,EAAEA,EAAQ,KAAK,EAChD,UAAWH,EAAAA,KAAK,iCAAkCJ,CAAS,EAC1D,GAAGC,EACJ,IAAKC,CAAA,CAAA,CAGX,CACF,EAUMY,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,EACzBZ,MAACE,GAAM,SAAAa,EAAS,EACfF,GACCb,EAAA,IAACM,EAAA,CACC,QAASO,EACT,KAAM,CAAE,KAAML,aAAY,IAAK,WAAY,CAAA,CAC7C,EAEDM,GACCd,EAAA,IAACM,EAAA,CACC,QAASQ,EACT,KAAM,CAAE,KAAMG,cAAa,IAAK,QAAS,CAAA,CAC3C,CAEJ,CAAA,CAAA,CAGN,EAEA,OAAO,OAAON,EAAS,CACrB,KAAAlB,EACA,OAAAa,EACA,KAAAJ,EACA,KAAAO,CACF,CAAC,EAED,MAAMS,EAAMP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.tgph :is(.mr-1){margin-right:var(--tgph-spacing-1)}.tgph :is(.mr-2){margin-right:var(--tgph-spacing-2)}.tgph :is(.inline-flex){display:inline-flex}.tgph :is(.h-6){height:var(--tgph-spacing-6)}.tgph :is(.h-8){height:var(--tgph-spacing-8)}.tgph :is(.items-center){align-items:center}.tgph :is(.rounded-3){border-radius:var(--tgph-rounded-3)}.tgph :is(.rounded-bl-0){border-bottom-left-radius:var(--tgph-rounded-0)}.tgph :is(.rounded-tl-0){border-top-left-radius:var(--tgph-rounded-0)}.tgph :is(.bg-accent-3){background-color:var(--tgph-accent-3)}.tgph :is(.bg-accent-9){background-color:var(--tgph-accent-9)}.tgph :is(.bg-blue-3){background-color:var(--tgph-blue-3)}.tgph :is(.bg-blue-9){background-color:var(--tgph-blue-9)}.tgph :is(.bg-gray-3){background-color:var(--tgph-gray-3)}.tgph :is(.bg-gray-9){background-color:var(--tgph-gray-9)}.tgph :is(.bg-green-3){background-color:var(--tgph-green-3)}.tgph :is(.bg-green-9){background-color:var(--tgph-green-9)}.tgph :is(.bg-red-3){background-color:var(--tgph-red-3)}.tgph :is(.bg-red-9){background-color:var(--tgph-red-9)}.tgph :is(.bg-yellow-3){background-color:var(--tgph-yellow-3)}.tgph :is(.bg-yellow-9){background-color:var(--tgph-yellow-9)}.tgph :is(.pl-2){padding-left:var(--tgph-spacing-2)}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { jsx as l, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { Button as R } from "@telegraph/button";
|
|
3
|
+
import { closeSharp as i, Icon as C, copyOutline as T } from "@telegraph/icon";
|
|
4
|
+
import { Text as v } from "@telegraph/typography";
|
|
5
|
+
import { clsx as d } from "clsx";
|
|
6
|
+
import n from "react";
|
|
7
|
+
const z = {
|
|
8
|
+
Root: {
|
|
9
|
+
1: "h-6",
|
|
10
|
+
2: "h-8"
|
|
11
|
+
}
|
|
12
|
+
}, s = {
|
|
13
|
+
Root: {
|
|
14
|
+
solid: {
|
|
15
|
+
default: "bg-gray-9",
|
|
16
|
+
accent: "bg-accent-9",
|
|
17
|
+
gray: "bg-gray-9",
|
|
18
|
+
red: "bg-red-9",
|
|
19
|
+
blue: "bg-blue-9",
|
|
20
|
+
green: "bg-green-9",
|
|
21
|
+
yellow: "bg-yellow-9"
|
|
22
|
+
},
|
|
23
|
+
soft: {
|
|
24
|
+
default: "bg-gray-3",
|
|
25
|
+
accent: "bg-accent-3",
|
|
26
|
+
gray: "bg-gray-3",
|
|
27
|
+
red: "bg-red-3",
|
|
28
|
+
blue: "bg-blue-3",
|
|
29
|
+
green: "bg-green-3",
|
|
30
|
+
yellow: "bg-yellow-3"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
Icon: {
|
|
34
|
+
solid: {
|
|
35
|
+
default: "white",
|
|
36
|
+
gray: "white",
|
|
37
|
+
red: "white",
|
|
38
|
+
accent: "white",
|
|
39
|
+
blue: "white",
|
|
40
|
+
green: "white",
|
|
41
|
+
yellow: "white"
|
|
42
|
+
},
|
|
43
|
+
soft: {
|
|
44
|
+
default: "default",
|
|
45
|
+
gray: "gray",
|
|
46
|
+
accent: "accent",
|
|
47
|
+
red: "red",
|
|
48
|
+
blue: "blue",
|
|
49
|
+
green: "green",
|
|
50
|
+
yellow: "yellow"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
Text: {
|
|
54
|
+
solid: {
|
|
55
|
+
default: "white",
|
|
56
|
+
gray: "white",
|
|
57
|
+
accent: "white",
|
|
58
|
+
red: "white",
|
|
59
|
+
blue: "white",
|
|
60
|
+
green: "white",
|
|
61
|
+
yellow: "white"
|
|
62
|
+
},
|
|
63
|
+
soft: {
|
|
64
|
+
default: "default",
|
|
65
|
+
gray: "gray",
|
|
66
|
+
accent: "accent",
|
|
67
|
+
red: "red",
|
|
68
|
+
blue: "blue",
|
|
69
|
+
green: "green",
|
|
70
|
+
yellow: "yellow"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
Button: {
|
|
74
|
+
solid: {
|
|
75
|
+
default: "gray",
|
|
76
|
+
gray: "gray",
|
|
77
|
+
accent: "accent",
|
|
78
|
+
red: "red",
|
|
79
|
+
blue: "blue",
|
|
80
|
+
green: "green",
|
|
81
|
+
yellow: "yellow"
|
|
82
|
+
},
|
|
83
|
+
soft: {
|
|
84
|
+
default: "gray",
|
|
85
|
+
gray: "gray",
|
|
86
|
+
accent: "accent",
|
|
87
|
+
red: "red",
|
|
88
|
+
blue: "blue",
|
|
89
|
+
green: "green",
|
|
90
|
+
yellow: "yellow"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, u = n.createContext({
|
|
94
|
+
size: "1",
|
|
95
|
+
color: "default",
|
|
96
|
+
variant: "soft"
|
|
97
|
+
}), f = n.forwardRef(
|
|
98
|
+
({ size: t = "1", color: o = "default", variant: r = "soft", className: e, ...a }, c) => /* @__PURE__ */ l(u.Provider, { value: { size: t, color: o, variant: r }, children: /* @__PURE__ */ l(
|
|
99
|
+
"span",
|
|
100
|
+
{
|
|
101
|
+
className: d(
|
|
102
|
+
"inline-flex items-center rounded-3 pl-2",
|
|
103
|
+
z.Root[t],
|
|
104
|
+
s.Root[r][o],
|
|
105
|
+
e
|
|
106
|
+
),
|
|
107
|
+
...a,
|
|
108
|
+
ref: c,
|
|
109
|
+
"data-tag": !0
|
|
110
|
+
}
|
|
111
|
+
) })
|
|
112
|
+
), w = n.forwardRef(
|
|
113
|
+
({ as: t = "span", className: o, ...r }, e) => {
|
|
114
|
+
const a = n.useContext(u);
|
|
115
|
+
return /* @__PURE__ */ l(
|
|
116
|
+
v,
|
|
117
|
+
{
|
|
118
|
+
as: t,
|
|
119
|
+
size: a.size,
|
|
120
|
+
color: s.Text[a.variant][a.color],
|
|
121
|
+
className: d("rounded-tl-0 rounded-bl-0 mr-2", o),
|
|
122
|
+
...r,
|
|
123
|
+
ref: e
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
), g = n.forwardRef(
|
|
128
|
+
({ className: t, ...o }, r) => {
|
|
129
|
+
const e = n.useContext(u);
|
|
130
|
+
return /* @__PURE__ */ l(
|
|
131
|
+
R,
|
|
132
|
+
{
|
|
133
|
+
size: e.size,
|
|
134
|
+
color: s.Button[e.variant][e.color],
|
|
135
|
+
variant: e.variant,
|
|
136
|
+
icon: { icon: i, alt: "close" },
|
|
137
|
+
className: d("rounded-tl-0 rounded-bl-0", t),
|
|
138
|
+
...o,
|
|
139
|
+
ref: r
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
), y = n.forwardRef(
|
|
144
|
+
({ className: t, ...o }, r) => {
|
|
145
|
+
const e = n.useContext(u);
|
|
146
|
+
return /* @__PURE__ */ l(
|
|
147
|
+
C,
|
|
148
|
+
{
|
|
149
|
+
size: e.size,
|
|
150
|
+
color: s.Icon[e.variant][e.color],
|
|
151
|
+
className: d("rounded-tl-0 rounded-bl-0 mr-1", t),
|
|
152
|
+
...o,
|
|
153
|
+
ref: r
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
), b = n.forwardRef(
|
|
158
|
+
({
|
|
159
|
+
color: t = "default",
|
|
160
|
+
size: o = "1",
|
|
161
|
+
variant: r = "soft",
|
|
162
|
+
icon: e,
|
|
163
|
+
onRemove: a,
|
|
164
|
+
onCopy: c,
|
|
165
|
+
children: h,
|
|
166
|
+
...m
|
|
167
|
+
}, x) => /* @__PURE__ */ p(f, { color: t, size: o, variant: r, ...m, ref: x, children: [
|
|
168
|
+
e && /* @__PURE__ */ l(y, { ...e }),
|
|
169
|
+
/* @__PURE__ */ l(w, { children: h }),
|
|
170
|
+
a && /* @__PURE__ */ l(
|
|
171
|
+
g,
|
|
172
|
+
{
|
|
173
|
+
onClick: a,
|
|
174
|
+
icon: { icon: i, alt: "Copy Text" }
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
c && /* @__PURE__ */ l(
|
|
178
|
+
g,
|
|
179
|
+
{
|
|
180
|
+
onClick: c,
|
|
181
|
+
icon: { icon: T, alt: "Remove" }
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
] })
|
|
185
|
+
);
|
|
186
|
+
Object.assign(b, {
|
|
187
|
+
Root: f,
|
|
188
|
+
Button: g,
|
|
189
|
+
Text: w,
|
|
190
|
+
Icon: y
|
|
191
|
+
});
|
|
192
|
+
const k = b;
|
|
193
|
+
export {
|
|
194
|
+
k as Tag
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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 },\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 },\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 },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\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 },\n soft: {\n default: \"default\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\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 },\n soft: {\n default: \"gray\",\n gray: \"gray\",\n accent: \"accent\",\n red: \"red\",\n blue: \"blue\",\n green: \"green\",\n yellow: \"yellow\",\n },\n },\n} as const;\n","import { Button as TelegraphButton } from \"@telegraph/button\";\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?: React.ComponentProps<typeof TelegraphButton>[\"color\"] & \"default\";\n variant?: \"soft\" | \"solid\";\n};\n\ntype RootProps = React.HTMLAttributes<RootRef> & RootBaseProps;\n\ntype RootRef = HTMLSpanElement;\n\nconst TagContext = React.createContext<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 = Omit<React.ComponentProps<typeof TelegraphText>, \"as\"> & {\n as: React.ComponentProps<typeof TelegraphText>[\"as\"];\n};\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 text: string;\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>{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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,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;"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare const SIZE: {
|
|
2
|
+
readonly Root: {
|
|
3
|
+
readonly "1": "h-6";
|
|
4
|
+
readonly "2": "h-8";
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export declare const COLOR: {
|
|
8
|
+
readonly Root: {
|
|
9
|
+
readonly solid: {
|
|
10
|
+
readonly default: "bg-gray-9";
|
|
11
|
+
readonly accent: "bg-accent-9";
|
|
12
|
+
readonly gray: "bg-gray-9";
|
|
13
|
+
readonly red: "bg-red-9";
|
|
14
|
+
readonly blue: "bg-blue-9";
|
|
15
|
+
readonly green: "bg-green-9";
|
|
16
|
+
readonly yellow: "bg-yellow-9";
|
|
17
|
+
};
|
|
18
|
+
readonly soft: {
|
|
19
|
+
readonly default: "bg-gray-3";
|
|
20
|
+
readonly accent: "bg-accent-3";
|
|
21
|
+
readonly gray: "bg-gray-3";
|
|
22
|
+
readonly red: "bg-red-3";
|
|
23
|
+
readonly blue: "bg-blue-3";
|
|
24
|
+
readonly green: "bg-green-3";
|
|
25
|
+
readonly yellow: "bg-yellow-3";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
readonly Icon: {
|
|
29
|
+
readonly solid: {
|
|
30
|
+
readonly default: "white";
|
|
31
|
+
readonly gray: "white";
|
|
32
|
+
readonly red: "white";
|
|
33
|
+
readonly accent: "white";
|
|
34
|
+
readonly blue: "white";
|
|
35
|
+
readonly green: "white";
|
|
36
|
+
readonly yellow: "white";
|
|
37
|
+
};
|
|
38
|
+
readonly soft: {
|
|
39
|
+
readonly default: "default";
|
|
40
|
+
readonly gray: "gray";
|
|
41
|
+
readonly accent: "accent";
|
|
42
|
+
readonly red: "red";
|
|
43
|
+
readonly blue: "blue";
|
|
44
|
+
readonly green: "green";
|
|
45
|
+
readonly yellow: "yellow";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
readonly Text: {
|
|
49
|
+
readonly solid: {
|
|
50
|
+
readonly default: "white";
|
|
51
|
+
readonly gray: "white";
|
|
52
|
+
readonly accent: "white";
|
|
53
|
+
readonly red: "white";
|
|
54
|
+
readonly blue: "white";
|
|
55
|
+
readonly green: "white";
|
|
56
|
+
readonly yellow: "white";
|
|
57
|
+
};
|
|
58
|
+
readonly soft: {
|
|
59
|
+
readonly default: "default";
|
|
60
|
+
readonly gray: "gray";
|
|
61
|
+
readonly accent: "accent";
|
|
62
|
+
readonly red: "red";
|
|
63
|
+
readonly blue: "blue";
|
|
64
|
+
readonly green: "green";
|
|
65
|
+
readonly yellow: "yellow";
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly Button: {
|
|
69
|
+
readonly solid: {
|
|
70
|
+
readonly default: "gray";
|
|
71
|
+
readonly gray: "gray";
|
|
72
|
+
readonly accent: "accent";
|
|
73
|
+
readonly red: "red";
|
|
74
|
+
readonly blue: "blue";
|
|
75
|
+
readonly green: "green";
|
|
76
|
+
readonly yellow: "yellow";
|
|
77
|
+
};
|
|
78
|
+
readonly soft: {
|
|
79
|
+
readonly default: "gray";
|
|
80
|
+
readonly gray: "gray";
|
|
81
|
+
readonly accent: "accent";
|
|
82
|
+
readonly red: "red";
|
|
83
|
+
readonly blue: "blue";
|
|
84
|
+
readonly green: "green";
|
|
85
|
+
readonly yellow: "yellow";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=Tag.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.constants.d.ts","sourceRoot":"","sources":["../../../src/Tag/Tag.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI;;;;;CAKP,CAAC;AAEX,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiFR,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Button as TelegraphButton } from "@telegraph/button";
|
|
2
|
+
import { Icon as TelegraphIcon } from "@telegraph/icon";
|
|
3
|
+
import { Text as TelegraphText } from "@telegraph/typography";
|
|
4
|
+
import React from "react";
|
|
5
|
+
type RootBaseProps = {
|
|
6
|
+
size?: "1" | "2";
|
|
7
|
+
color?: React.ComponentProps<typeof TelegraphButton>["color"] & "default";
|
|
8
|
+
variant?: "soft" | "solid";
|
|
9
|
+
};
|
|
10
|
+
declare const Root: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & RootBaseProps & React.RefAttributes<HTMLSpanElement>>;
|
|
11
|
+
type TextProps = Omit<React.ComponentProps<typeof TelegraphText>, "as"> & {
|
|
12
|
+
as: React.ComponentProps<typeof TelegraphText>["as"];
|
|
13
|
+
};
|
|
14
|
+
declare const Text: React.ForwardRefExoticComponent<Omit<TextProps, "ref"> & React.RefAttributes<HTMLParagraphElement & HTMLSpanElement & HTMLDivElement & HTMLLabelElement & HTMLPreElement>>;
|
|
15
|
+
declare const Button: React.ForwardRefExoticComponent<Omit<{
|
|
16
|
+
variant?: "soft" | "solid" | "outline" | "ghost" | undefined;
|
|
17
|
+
size?: "1" | "2" | "3" | undefined;
|
|
18
|
+
color?: "gray" | "accent" | "red" | "blue" | "green" | "yellow" | undefined;
|
|
19
|
+
state?: "default" | "disabled" | "loading" | "error" | "success" | "warning" | undefined;
|
|
20
|
+
} & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
declare const Icon: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLSpanElement> & {
|
|
22
|
+
icon: string;
|
|
23
|
+
alt: string;
|
|
24
|
+
size?: "1" | "2" | "0" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
|
|
25
|
+
variant?: "primary" | "secondary" | undefined;
|
|
26
|
+
color?: "white" | "default" | "gray" | "accent" | "red" | "blue" | "green" | "yellow" | "beige" | "disabled" | undefined;
|
|
27
|
+
} & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
28
|
+
type DefaultProps = React.ComponentProps<typeof Root> & {
|
|
29
|
+
text: string;
|
|
30
|
+
icon?: React.ComponentProps<typeof TelegraphIcon>;
|
|
31
|
+
onCopy?: () => void;
|
|
32
|
+
onRemove?: () => void;
|
|
33
|
+
};
|
|
34
|
+
declare const Tag: React.ForwardRefExoticComponent<Omit<DefaultProps, "ref"> & React.RefAttributes<HTMLSpanElement>> & {
|
|
35
|
+
Root: typeof Root;
|
|
36
|
+
Button: typeof Button;
|
|
37
|
+
Text: typeof Text;
|
|
38
|
+
Icon: typeof Icon;
|
|
39
|
+
};
|
|
40
|
+
export { Tag };
|
|
41
|
+
//# sourceMappingURL=Tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["../../../src/Tag/Tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EACL,IAAI,IAAI,aAAa,EAGtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE9D,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Root":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telegraph/tag",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"repository": "https://github.com/knocklabs/telegraph/tree/main/packages/tag",
|
|
5
|
+
"author": "@knocklabs",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/cjs/index.js",
|
|
8
|
+
"module": "dist/esm/index.mjs",
|
|
9
|
+
"types": "dist/types/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/esm/index.mjs",
|
|
13
|
+
"require": "./dist/cjs/index.js",
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"default": "./dist/css/default.css"
|
|
16
|
+
},
|
|
17
|
+
"./default.css": "./dist/css/default.css"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"prettier": "@knocklabs/prettier-config",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"clean": "rm -rf dist",
|
|
26
|
+
"dev": "vite build --watch --emptyOutDir false",
|
|
27
|
+
"build": "yarn clean && vite build",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest",
|
|
30
|
+
"coverage": "vitest run --coverage",
|
|
31
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
32
|
+
"format": "prettier \"src/**/*.{js,ts,tsx}\" --write",
|
|
33
|
+
"format:check": "prettier \"src/**/*.{js,ts,tsx}\" --check",
|
|
34
|
+
"preview": "vite preview"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@telegraph/button": "^0.0.5",
|
|
38
|
+
"@telegraph/icon": "^0.0.4",
|
|
39
|
+
"@telegraph/typography": "^0.0.8",
|
|
40
|
+
"clsx": "^2.1.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@knocklabs/eslint-config": "^0.0.3",
|
|
44
|
+
"@knocklabs/prettier-config": "^0.0.1",
|
|
45
|
+
"@knocklabs/typescript-config": "^0.0.2",
|
|
46
|
+
"@telegraph/postcss-config": "^0.0.9",
|
|
47
|
+
"@telegraph/tailwind-config": "^0.0.10",
|
|
48
|
+
"@telegraph/vite-config": "^0.0.8",
|
|
49
|
+
"@telegraph/vitest-config": "^0.0.6",
|
|
50
|
+
"@types/react": "^18.2.48",
|
|
51
|
+
"eslint": "^8.56.0",
|
|
52
|
+
"react": "^18.2.0",
|
|
53
|
+
"react-dom": "^18.2.0",
|
|
54
|
+
"typescript": "^5.3.3",
|
|
55
|
+
"vite": "^5.0.12",
|
|
56
|
+
"vitest": "^1.2.2"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"react": "^18.2.0",
|
|
60
|
+
"react-dom": "^18.2.0"
|
|
61
|
+
}
|
|
62
|
+
}
|