@sproutsocial/seeds-react-token 1.5.7 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +19 -0
- package/dist/esm/index.js +125 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +127 -19
- package/dist/index.js.map +1 -1
- package/dist/token.css +160 -0
- package/package.json +9 -9
- package/postcss.config.js +6 -0
- package/src/Token.stories.tsx +12 -0
- package/src/Token.tsx +8 -68
- package/src/TokenHybrid.tsx +97 -0
- package/src/TokenTailwind.tsx +117 -0
- package/src/__tests__/displayName.test.tsx +11 -0
- package/src/__tests__/features.test.tsx +15 -0
- package/src/css.d.ts +1 -0
- package/src/token.css +160 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
yarn run v1.22.22
|
|
2
|
-
$ tsup --dts
|
|
2
|
+
$ tsup --dts && cp src/token.css dist/token.css
|
|
3
3
|
[34mCLI[39m Building entry: src/index.ts
|
|
4
4
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
5
|
[34mCLI[39m tsup v8.5.0
|
|
@@ -8,14 +8,14 @@ $ tsup --dts
|
|
|
8
8
|
[34mCLI[39m Cleaning output folder
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m11.87 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m17.20 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 78ms
|
|
14
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m8.79 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m17.06 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 78ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.
|
|
21
|
-
Done in 5.
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 4586ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.44 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.44 KB[39m
|
|
21
|
+
Done in 5.98s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-token
|
|
2
2
|
|
|
3
|
+
## 1.5.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [85f9728]
|
|
8
|
+
- Updated dependencies [fa7d859]
|
|
9
|
+
- @sproutsocial/seeds-react-theme@4.2.0
|
|
10
|
+
- @sproutsocial/seeds-react-box@1.1.23
|
|
11
|
+
- @sproutsocial/seeds-react-hooks@3.2.4
|
|
12
|
+
- @sproutsocial/seeds-react-icon@2.4.2
|
|
13
|
+
- @sproutsocial/seeds-react-mixins@4.3.9
|
|
14
|
+
- @sproutsocial/seeds-react-visually-hidden@1.0.24
|
|
15
|
+
|
|
16
|
+
## 1.5.8
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 0e113bc: Migrate progress, token, select, spot-illustration, and collapsible to the Button hybrid Tailwind pattern. Each component now ships a CSS-class implementation routed alongside the styled-components path. Component CSS is wrapped in `@layer components` so Tailwind utility classes win the cascade and can override component styles via `className`. `Collapsible.Panel` now forwards `className` onto the panel root so utility overrides reach the styled element.
|
|
21
|
+
|
|
3
22
|
## 1.5.7
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// src/Token.tsx
|
|
2
2
|
import "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
3
|
+
|
|
4
|
+
// src/TokenHybrid.tsx
|
|
5
|
+
import "react";
|
|
6
|
+
import { mergeRefs as mergeRefs2 } from "@sproutsocial/seeds-react-utilities";
|
|
7
|
+
import { useTextContent as useTextContent2 } from "@sproutsocial/seeds-react-hooks";
|
|
8
|
+
import Box2 from "@sproutsocial/seeds-react-box";
|
|
9
|
+
import Icon2 from "@sproutsocial/seeds-react-icon";
|
|
10
|
+
import { VisuallyHidden as VisuallyHidden2 } from "@sproutsocial/seeds-react-visually-hidden";
|
|
11
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
8
12
|
|
|
9
13
|
// src/styles.ts
|
|
10
14
|
import styled from "styled-components";
|
|
@@ -102,9 +106,31 @@ var Container = styled.button`
|
|
|
102
106
|
`;
|
|
103
107
|
var styles_default = Container;
|
|
104
108
|
|
|
105
|
-
// src/
|
|
109
|
+
// src/TokenTailwind.tsx
|
|
110
|
+
import "react";
|
|
111
|
+
import { mergeRefs } from "@sproutsocial/seeds-react-utilities";
|
|
112
|
+
import { useTextContent } from "@sproutsocial/seeds-react-hooks";
|
|
113
|
+
import Box from "@sproutsocial/seeds-react-box";
|
|
114
|
+
import Icon from "@sproutsocial/seeds-react-icon";
|
|
115
|
+
import { VisuallyHidden } from "@sproutsocial/seeds-react-visually-hidden";
|
|
106
116
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
107
|
-
|
|
117
|
+
function cn(...inputs) {
|
|
118
|
+
const classes = [];
|
|
119
|
+
for (const input of inputs) {
|
|
120
|
+
if (!input) continue;
|
|
121
|
+
if (typeof input === "string") {
|
|
122
|
+
classes.push(input);
|
|
123
|
+
} else if (typeof input === "object") {
|
|
124
|
+
for (const [key, value] of Object.entries(input)) {
|
|
125
|
+
if (value) {
|
|
126
|
+
classes.push(key);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return classes.join(" ");
|
|
132
|
+
}
|
|
133
|
+
var TokenTailwind = ({
|
|
108
134
|
children,
|
|
109
135
|
closeable = true,
|
|
110
136
|
onClick,
|
|
@@ -115,21 +141,32 @@ var Token = ({
|
|
|
115
141
|
disabled = false,
|
|
116
142
|
palette = "neutral",
|
|
117
143
|
innerRef = null,
|
|
144
|
+
as,
|
|
145
|
+
className,
|
|
118
146
|
...rest
|
|
119
147
|
}) => {
|
|
120
148
|
const textContainer = useTextContent("");
|
|
149
|
+
const isInteractive = closeable || !!onClick;
|
|
150
|
+
const Element = as ?? (isInteractive ? "button" : "div");
|
|
151
|
+
const classes = cn(
|
|
152
|
+
"seeds-token",
|
|
153
|
+
{
|
|
154
|
+
"seeds-token-closeable": isInteractive,
|
|
155
|
+
"seeds-token-blue": palette === "blue",
|
|
156
|
+
"seeds-token-disabled": disabled,
|
|
157
|
+
"seeds-token-invalid": !valid,
|
|
158
|
+
"seeds-token-warning": hasWarning,
|
|
159
|
+
"seeds-token-generated": isGenerated
|
|
160
|
+
},
|
|
161
|
+
className
|
|
162
|
+
);
|
|
121
163
|
return /* @__PURE__ */ jsxs(
|
|
122
|
-
|
|
164
|
+
Element,
|
|
123
165
|
{
|
|
124
166
|
ref: mergeRefs(textContainer, innerRef),
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
palette,
|
|
129
|
-
type: closeable || onClick ? "button" : void 0,
|
|
130
|
-
as: closeable || onClick ? "button" : "div",
|
|
131
|
-
closeable: closeable || !!onClick,
|
|
132
|
-
disabled,
|
|
167
|
+
type: isInteractive ? "button" : void 0,
|
|
168
|
+
className: classes,
|
|
169
|
+
...isInteractive ? { disabled } : {},
|
|
133
170
|
onClick,
|
|
134
171
|
"data-qa-token": textContainer.current,
|
|
135
172
|
"data-qa-token-iscloseable": closeable === true,
|
|
@@ -159,7 +196,78 @@ var Token = ({
|
|
|
159
196
|
}
|
|
160
197
|
);
|
|
161
198
|
};
|
|
162
|
-
|
|
199
|
+
TokenTailwind.displayName = "TokenTailwind";
|
|
200
|
+
|
|
201
|
+
// src/TokenHybrid.tsx
|
|
202
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
203
|
+
var TokenStyled = ({
|
|
204
|
+
children,
|
|
205
|
+
closeable = true,
|
|
206
|
+
onClick,
|
|
207
|
+
qa,
|
|
208
|
+
valid = true,
|
|
209
|
+
hasWarning = false,
|
|
210
|
+
isGenerated = false,
|
|
211
|
+
disabled = false,
|
|
212
|
+
palette = "neutral",
|
|
213
|
+
innerRef = null,
|
|
214
|
+
...rest
|
|
215
|
+
}) => {
|
|
216
|
+
const textContainer = useTextContent2("");
|
|
217
|
+
return /* @__PURE__ */ jsxs2(
|
|
218
|
+
styles_default,
|
|
219
|
+
{
|
|
220
|
+
ref: mergeRefs2(textContainer, innerRef),
|
|
221
|
+
valid,
|
|
222
|
+
hasWarning,
|
|
223
|
+
isGenerated,
|
|
224
|
+
palette,
|
|
225
|
+
type: closeable || onClick ? "button" : void 0,
|
|
226
|
+
as: closeable || onClick ? "button" : "div",
|
|
227
|
+
closeable: closeable || !!onClick,
|
|
228
|
+
disabled,
|
|
229
|
+
onClick,
|
|
230
|
+
"data-qa-token": textContainer.current,
|
|
231
|
+
"data-qa-token-iscloseable": closeable === true,
|
|
232
|
+
"data-qa-token-isvalid": valid === true,
|
|
233
|
+
"data-qa-token-isdisabled": disabled === true,
|
|
234
|
+
...qa,
|
|
235
|
+
...rest,
|
|
236
|
+
children: [
|
|
237
|
+
!valid && /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
238
|
+
/* @__PURE__ */ jsx2(VisuallyHidden2, { as: "div", role: "status", children: "This is an invalid token" }),
|
|
239
|
+
/* @__PURE__ */ jsx2(
|
|
240
|
+
Icon2,
|
|
241
|
+
{
|
|
242
|
+
"aria-hidden": true,
|
|
243
|
+
pr: 300,
|
|
244
|
+
name: "circle-exclamation-solid",
|
|
245
|
+
size: "mini"
|
|
246
|
+
}
|
|
247
|
+
),
|
|
248
|
+
/* @__PURE__ */ jsx2(VisuallyHidden2, { children: "Invalid" })
|
|
249
|
+
] }),
|
|
250
|
+
closeable ? /* @__PURE__ */ jsxs2(Box2, { display: "flex", alignItems: "center", justifyContent: "space-between", children: [
|
|
251
|
+
/* @__PURE__ */ jsx2(Box2, { as: "span", display: "flex", alignItems: "center", children }),
|
|
252
|
+
/* @__PURE__ */ jsx2(Icon2, { "aria-hidden": true, pl: 300, name: "x-solid", size: "mini" })
|
|
253
|
+
] }) : children
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
};
|
|
258
|
+
var Token = (props) => {
|
|
259
|
+
if (hasStyledProps(props)) {
|
|
260
|
+
return /* @__PURE__ */ jsx2(TokenStyled, { ...props });
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ jsx2(TokenTailwind, { ...props });
|
|
263
|
+
};
|
|
264
|
+
var TokenHybrid_default = Token;
|
|
265
|
+
|
|
266
|
+
// src/Token.tsx
|
|
267
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
268
|
+
var Token2 = (props) => /* @__PURE__ */ jsx3(TokenHybrid_default, { ...props });
|
|
269
|
+
Token2.displayName = "Token";
|
|
270
|
+
var Token_default = Token2;
|
|
163
271
|
|
|
164
272
|
// src/TokenTypes.ts
|
|
165
273
|
import "react";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Token.tsx","../../src/styles.ts","../../src/TokenTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { mergeRefs } from \"@sproutsocial/seeds-react-utilities\";\nimport { useTextContent } from \"@sproutsocial/seeds-react-hooks\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport Container from \"./styles\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\nconst Token = ({\n children,\n closeable = true,\n onClick,\n qa,\n valid = true,\n hasWarning = false,\n isGenerated = false,\n disabled = false,\n palette = \"neutral\",\n innerRef = null,\n ...rest\n}: TypeTokenProps) => {\n const textContainer = useTextContent(\"\");\n\n return (\n <Container\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore some legacy ref type mismatch between divs\n ref={mergeRefs(textContainer, innerRef)}\n valid={valid}\n hasWarning={hasWarning}\n isGenerated={isGenerated}\n palette={palette}\n type={closeable || onClick ? \"button\" : undefined}\n as={closeable || onClick ? \"button\" : \"div\"}\n closeable={closeable || !!onClick}\n disabled={disabled}\n onClick={onClick}\n data-qa-token={textContainer.current}\n data-qa-token-iscloseable={closeable === true}\n data-qa-token-isvalid={valid === true}\n data-qa-token-isdisabled={disabled === true}\n {...qa}\n {...rest}\n >\n {!valid && (\n <>\n <VisuallyHidden as=\"div\" role=\"status\">\n This is an invalid token\n </VisuallyHidden>\n <Icon\n aria-hidden\n pr={300}\n name=\"circle-exclamation-solid\"\n size=\"mini\"\n />\n <VisuallyHidden>Invalid</VisuallyHidden>\n </>\n )}\n {closeable ? (\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Box as=\"span\" display=\"flex\" alignItems=\"center\">\n {children}\n </Box>\n <Icon aria-hidden pl={300} name=\"x-solid\" size=\"mini\" />\n </Box>\n ) : (\n children\n )}\n </Container>\n );\n};\n\nexport default Token;\n","import styled from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport { useInteractiveColor } from \"@sproutsocial/seeds-react-hooks\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\nconst Container = styled.button<TypeTokenProps>`\n position: relative;\n display: inline-flex;\n align-items: center;\n margin: 0;\n line-height: 1;\n outline: none;\n font-family: ${({ theme }) => theme.fontFamily};\n font-size: ${({ theme }) => theme.fontSizes[200]};\n line-height: 13px;\n font-weight: ${({ theme }) => theme.fontWeights.normal};\n border: 1px solid ${({ theme }) => theme.colors.container.border.base};\n border-radius: ${({ theme }) => theme.radii[500]};\n color: ${({ theme }) => theme.colors.text.body};\n background: ${({ theme }) => theme.colors.container.background.base};\n padding: ${({ theme }) => theme.space[200]} ${({ theme }) => theme.space[300]};\n transition: all ${({ theme }) => theme.duration.fast}\n ${({ theme }) => theme.easing.ease_inout};\n\n &:focus {\n ${focusRing}\n }\n\n ${({ closeable, theme }) =>\n closeable &&\n `\n cursor: pointer;\n &:hover,\n &:active {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.base)};\n }\n `}\n\n ${({ theme, palette }) =>\n palette === \"blue\" &&\n `\n background: ${theme.colors.container.background.decorative.blue};\n border: 1px solid ${theme.colors.container.border.decorative.blue};\n &:hover,\n &:active {\n cursor: pointer;\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.decorative.blue)};\n }\n `}\n\n ${({ disabled, theme }) =>\n disabled &&\n `\n opacity: 0.4;\n cursor: not-allowed;\n &:hover,\n &:active {\n box-shadow: none;\n border: 1px solid ${theme.colors.container.border.base};\n }\n `}\n \n ${({ valid, theme }) =>\n !valid &&\n `\n color: ${theme.colors.text.error};\n background: ${theme.colors.container.background.error};\n border: 1px solid ${theme.colors.container.border.error};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.error)};\n }\n `}\n\n ${({ hasWarning, theme }) =>\n hasWarning &&\n `\n background: ${theme.colors.container.background.warning};\n border: 1px solid ${theme.colors.container.border.warning};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.warning)};\n }\n `}\n\n ${({ isGenerated, theme }) =>\n isGenerated &&\n `\n background: ${theme.colors.container.background.ai_generated};\n border: 1px solid ${theme.colors.container.border.ai_generated};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.ai_generated)};\n }\n color: ${theme.colors.text.ai_generated};\n `}\n\n\t${COMMON}\n`;\n\nexport default Container;\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\ntype TypeQaProps = object;\n\nexport interface TypeTokenProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"button\">, \"color\"> {\n onClick?: React.EventHandler<React.SyntheticEvent>;\n children: React.ReactNode;\n qa?: TypeQaProps;\n\n /** Show the close icon in the token. Can be used with or without icon prop */\n closeable?: boolean;\n\n /** Indicates whether the token value is valid or not */\n valid?: boolean;\n\n /** Indicates whether the token has a related warning */\n hasWarning?: boolean;\n\n /** Indicates whether the token was generated by AI */\n isGenerated?: boolean;\n\n /** Indicates whether the token is disabled */\n disabled?: boolean;\n palette?: \"neutral\" | \"blue\";\n as?: TypeStyledComponentsCommonProps[\"as\"];\n\n /** Used to get a reference to the underlying element */\n innerRef?: React.Ref<HTMLElement>;\n}\n","import Token from \"./Token\";\n\nexport default Token;\nexport { Token };\nexport * from \"./TokenTypes\";\n"],"mappings":";AAAA,OAAuB;AACvB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,SAAS,sBAAsB;;;ACL/B,OAAO,YAAY;AACnB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AAGpC,IAAM,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAOR,CAAC,EAAE,MAAM,MAAM,MAAM,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E;AAAA,IAAC;AAAA;AAAA,MAGC,KAAK,UAAU,eAAe,QAAQ;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,aAAa,UAAU,WAAW;AAAA,MACxC,IAAI,aAAa,UAAU,WAAW;AAAA,MACtC,WAAW,aAAa,CAAC,CAAC;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,iBAAe,cAAc;AAAA,MAC7B,6BAA2B,cAAc;AAAA,MACzC,yBAAuB,UAAU;AAAA,MACjC,4BAA0B,aAAa;AAAA,MACtC,GAAG;AAAA,MACH,GAAG;AAAA,MAEH;AAAA,SAAC,SACA,iCACE;AAAA,8BAAC,kBAAe,IAAG,OAAM,MAAK,UAAS,sCAEvC;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,cACX,IAAI;AAAA,cACJ,MAAK;AAAA,cACL,MAAK;AAAA;AAAA,UACP;AAAA,UACA,oBAAC,kBAAe,qBAAO;AAAA,WACzB;AAAA,QAED,YACC,qBAAC,OAAI,SAAQ,QAAO,YAAW,UAAS,gBAAe,iBACrD;AAAA,8BAAC,OAAI,IAAG,QAAO,SAAQ,QAAO,YAAW,UACtC,UACH;AAAA,UACA,oBAAC,QAAK,eAAW,MAAC,IAAI,KAAK,MAAK,WAAU,MAAK,QAAO;AAAA,WACxD,IAEA;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,gBAAQ;;;AEzEf,OAAuB;;;ACEvB,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/Token.tsx","../../src/TokenHybrid.tsx","../../src/styles.ts","../../src/TokenTailwind.tsx","../../src/TokenTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport TokenHybrid from \"./TokenHybrid\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\n/**\n * Token component. Automatically routes between the Tailwind implementation\n * (preferred) and the styled-components implementation (for consumers using\n * system props or styled() extension).\n */\nconst Token = (props: TypeTokenProps) => <TokenHybrid {...props} />;\n\nToken.displayName = \"Token\";\n\nexport default Token;\n","/**\n * Hybrid Token Component\n * Automatically chooses between Tailwind and styled-components based on props.\n * Consumers passing styled-system props (e.g. `mb`, `width`, `bg`) get the\n * styled-components implementation; everyone else gets the Tailwind path.\n */\n\nimport * as React from \"react\";\nimport { mergeRefs } from \"@sproutsocial/seeds-react-utilities\";\nimport { useTextContent } from \"@sproutsocial/seeds-react-hooks\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport Container from \"./styles\";\nimport { TokenTailwind } from \"./TokenTailwind\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\n// Styled-components implementation — preserved verbatim from the original Token\n// so consumers using styled-system props get identical behaviour.\nconst TokenStyled = ({\n children,\n closeable = true,\n onClick,\n qa,\n valid = true,\n hasWarning = false,\n isGenerated = false,\n disabled = false,\n palette = \"neutral\",\n innerRef = null,\n ...rest\n}: TypeTokenProps) => {\n const textContainer = useTextContent(\"\");\n\n return (\n <Container\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore some legacy ref type mismatch between divs\n ref={mergeRefs(textContainer, innerRef)}\n valid={valid}\n hasWarning={hasWarning}\n isGenerated={isGenerated}\n palette={palette}\n type={closeable || onClick ? \"button\" : undefined}\n as={closeable || onClick ? \"button\" : \"div\"}\n closeable={closeable || !!onClick}\n disabled={disabled}\n onClick={onClick}\n data-qa-token={textContainer.current}\n data-qa-token-iscloseable={closeable === true}\n data-qa-token-isvalid={valid === true}\n data-qa-token-isdisabled={disabled === true}\n {...qa}\n {...rest}\n >\n {!valid && (\n <>\n <VisuallyHidden as=\"div\" role=\"status\">\n This is an invalid token\n </VisuallyHidden>\n <Icon\n aria-hidden\n pr={300}\n name=\"circle-exclamation-solid\"\n size=\"mini\"\n />\n <VisuallyHidden>Invalid</VisuallyHidden>\n </>\n )}\n {closeable ? (\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Box as=\"span\" display=\"flex\" alignItems=\"center\">\n {children}\n </Box>\n <Icon aria-hidden pl={300} name=\"x-solid\" size=\"mini\" />\n </Box>\n ) : (\n children\n )}\n </Container>\n );\n};\n\nconst Token = (props: TypeTokenProps) => {\n // hasStyledProps only inspects a fixed allowlist of styled-system prop names\n // (bg, color, m*, p*, width, flex*, …), so it is safe to pass the full props —\n // none of Token's own props collide with that list.\n if (hasStyledProps(props)) {\n return <TokenStyled {...props} />;\n }\n\n // Use Tailwind version (preferred - better performance)\n return <TokenTailwind {...props} />;\n};\n\nexport default Token;\n","import styled from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport { useInteractiveColor } from \"@sproutsocial/seeds-react-hooks\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\nconst Container = styled.button<TypeTokenProps>`\n position: relative;\n display: inline-flex;\n align-items: center;\n margin: 0;\n line-height: 1;\n outline: none;\n font-family: ${({ theme }) => theme.fontFamily};\n font-size: ${({ theme }) => theme.fontSizes[200]};\n line-height: 13px;\n font-weight: ${({ theme }) => theme.fontWeights.normal};\n border: 1px solid ${({ theme }) => theme.colors.container.border.base};\n border-radius: ${({ theme }) => theme.radii[500]};\n color: ${({ theme }) => theme.colors.text.body};\n background: ${({ theme }) => theme.colors.container.background.base};\n padding: ${({ theme }) => theme.space[200]} ${({ theme }) => theme.space[300]};\n transition: all ${({ theme }) => theme.duration.fast}\n ${({ theme }) => theme.easing.ease_inout};\n\n &:focus {\n ${focusRing}\n }\n\n ${({ closeable, theme }) =>\n closeable &&\n `\n cursor: pointer;\n &:hover,\n &:active {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.base)};\n }\n `}\n\n ${({ theme, palette }) =>\n palette === \"blue\" &&\n `\n background: ${theme.colors.container.background.decorative.blue};\n border: 1px solid ${theme.colors.container.border.decorative.blue};\n &:hover,\n &:active {\n cursor: pointer;\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.decorative.blue)};\n }\n `}\n\n ${({ disabled, theme }) =>\n disabled &&\n `\n opacity: 0.4;\n cursor: not-allowed;\n &:hover,\n &:active {\n box-shadow: none;\n border: 1px solid ${theme.colors.container.border.base};\n }\n `}\n \n ${({ valid, theme }) =>\n !valid &&\n `\n color: ${theme.colors.text.error};\n background: ${theme.colors.container.background.error};\n border: 1px solid ${theme.colors.container.border.error};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.error)};\n }\n `}\n\n ${({ hasWarning, theme }) =>\n hasWarning &&\n `\n background: ${theme.colors.container.background.warning};\n border: 1px solid ${theme.colors.container.border.warning};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.warning)};\n }\n `}\n\n ${({ isGenerated, theme }) =>\n isGenerated &&\n `\n background: ${theme.colors.container.background.ai_generated};\n border: 1px solid ${theme.colors.container.border.ai_generated};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.ai_generated)};\n }\n color: ${theme.colors.text.ai_generated};\n `}\n\n\t${COMMON}\n`;\n\nexport default Container;\n","/**\n * Tailwind CSS implementation of Token component\n * Uses Seeds token CSS classes from token.css\n */\n\nimport * as React from \"react\";\nimport { mergeRefs } from \"@sproutsocial/seeds-react-utilities\";\nimport { useTextContent } from \"@sproutsocial/seeds-react-hooks\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\n// Utility for merging class names properly\nfunction cn(\n ...inputs: (string | undefined | null | false | Record<string, boolean>)[]\n): string {\n const classes: string[] = [];\n\n for (const input of inputs) {\n if (!input) continue;\n\n if (typeof input === \"string\") {\n classes.push(input);\n } else if (typeof input === \"object\") {\n for (const [key, value] of Object.entries(input)) {\n if (value) {\n classes.push(key);\n }\n }\n }\n }\n\n return classes.join(\" \");\n}\n\nexport const TokenTailwind = ({\n children,\n closeable = true,\n onClick,\n qa,\n valid = true,\n hasWarning = false,\n isGenerated = false,\n disabled = false,\n palette = \"neutral\",\n innerRef = null,\n as,\n className,\n ...rest\n}: TypeTokenProps) => {\n const textContainer = useTextContent(\"\");\n\n const isInteractive = closeable || !!onClick;\n // Mirror the styled component: it is a styled.button rendered `as` a div when\n // the token is neither closeable nor clickable. A consumer-provided `as` still\n // wins, matching the original (where `as` arrived via {...rest} last).\n const Element = (as ?? (isInteractive ? \"button\" : \"div\")) as React.ElementType;\n\n const classes = cn(\n \"seeds-token\",\n {\n \"seeds-token-closeable\": isInteractive,\n \"seeds-token-blue\": palette === \"blue\",\n \"seeds-token-disabled\": disabled,\n \"seeds-token-invalid\": !valid,\n \"seeds-token-warning\": hasWarning,\n \"seeds-token-generated\": isGenerated,\n },\n className\n );\n\n return (\n <Element\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore some legacy ref type mismatch between divs\n ref={mergeRefs(textContainer, innerRef)}\n type={isInteractive ? \"button\" : undefined}\n className={classes}\n {...(isInteractive ? { disabled } : {})}\n onClick={onClick}\n data-qa-token={textContainer.current}\n data-qa-token-iscloseable={closeable === true}\n data-qa-token-isvalid={valid === true}\n data-qa-token-isdisabled={disabled === true}\n {...qa}\n {...rest}\n >\n {!valid && (\n <>\n <VisuallyHidden as=\"div\" role=\"status\">\n This is an invalid token\n </VisuallyHidden>\n <Icon\n aria-hidden\n pr={300}\n name=\"circle-exclamation-solid\"\n size=\"mini\"\n />\n <VisuallyHidden>Invalid</VisuallyHidden>\n </>\n )}\n {closeable ? (\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Box as=\"span\" display=\"flex\" alignItems=\"center\">\n {children}\n </Box>\n <Icon aria-hidden pl={300} name=\"x-solid\" size=\"mini\" />\n </Box>\n ) : (\n children\n )}\n </Element>\n );\n};\n\nTokenTailwind.displayName = \"TokenTailwind\";\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\ntype TypeQaProps = object;\n\nexport interface TypeTokenProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"button\">, \"color\"> {\n onClick?: React.EventHandler<React.SyntheticEvent>;\n children: React.ReactNode;\n qa?: TypeQaProps;\n\n /** Show the close icon in the token. Can be used with or without icon prop */\n closeable?: boolean;\n\n /** Indicates whether the token value is valid or not */\n valid?: boolean;\n\n /** Indicates whether the token has a related warning */\n hasWarning?: boolean;\n\n /** Indicates whether the token was generated by AI */\n isGenerated?: boolean;\n\n /** Indicates whether the token is disabled */\n disabled?: boolean;\n palette?: \"neutral\" | \"blue\";\n as?: TypeStyledComponentsCommonProps[\"as\"];\n\n /** Used to get a reference to the underlying element */\n innerRef?: React.Ref<HTMLElement>;\n}\n","import Token from \"./Token\";\n\nexport default Token;\nexport { Token };\nexport * from \"./TokenTypes\";\n"],"mappings":";AAAA,OAAuB;;;ACOvB,OAAuB;AACvB,SAAS,aAAAA,kBAAiB;AAC1B,SAAS,kBAAAC,uBAAsB;AAC/B,OAAOC,UAAS;AAChB,OAAOC,WAAU;AACjB,SAAS,kBAAAC,uBAAsB;AAC/B,SAAS,sBAAsB;;;ACb/B,OAAO,YAAY;AACnB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AAGpC,IAAM,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAOR,CAAC,EAAE,MAAM,MAAM,MAAM,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AA,YAACK;AAAA,YAAA;AAAA,cACC,eAAW;AAAA,cACX,IAAI;AAAA,cACJ,MAAK;AAAA,cACL,MAAK;AAAA;AAAA,UACP;AAAA,UACA,gBAAAL,KAACI,iBAAA,EAAe,qBAAO;AAAA,WACzB;AAAA,QAED,YACC,gBAAAH,MAACK,MAAA,EAAI,SAAQ,QAAO,YAAW,UAAS,gBAAe,iBACrD;AAAA,0BAAAN,KAACM,MAAA,EAAI,IAAG,QAAO,SAAQ,QAAO,YAAW,UACtC,UACH;AAAA,UACA,gBAAAN,KAACK,OAAA,EAAK,eAAW,MAAC,IAAI,KAAK,MAAK,WAAU,MAAK,QAAO;AAAA,WACxD,IAEA;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAM,QAAQ,CAAC,UAA0B;AAIvC,MAAI,eAAe,KAAK,GAAG;AACzB,WAAO,gBAAAL,KAAC,eAAa,GAAG,OAAO;AAAA,EACjC;AAGA,SAAO,gBAAAA,KAAC,iBAAe,GAAG,OAAO;AACnC;AAEA,IAAO,sBAAQ;;;ADvF0B,gBAAAO,YAAA;AAAzC,IAAMC,SAAQ,CAAC,UAA0B,gBAAAD,KAAC,uBAAa,GAAG,OAAO;AAEjEC,OAAM,cAAc;AAEpB,IAAO,gBAAQA;;;AIbf,OAAuB;;;ACEvB,IAAO,gBAAQ;","names":["mergeRefs","useTextContent","Box","Icon","VisuallyHidden","Fragment","jsx","jsxs","useTextContent","mergeRefs","VisuallyHidden","Icon","Box","jsx","Token"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,14 @@ interface TypeTokenProps extends TypeStyledComponentsCommonProps, TypeSystemComm
|
|
|
23
23
|
innerRef?: React.Ref<HTMLElement>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Token component. Automatically routes between the Tailwind implementation
|
|
28
|
+
* (preferred) and the styled-components implementation (for consumers using
|
|
29
|
+
* system props or styled() extension).
|
|
30
|
+
*/
|
|
31
|
+
declare const Token: {
|
|
32
|
+
(props: TypeTokenProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
27
35
|
|
|
28
36
|
export { Token, type TypeTokenProps, Token as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,14 @@ interface TypeTokenProps extends TypeStyledComponentsCommonProps, TypeSystemComm
|
|
|
23
23
|
innerRef?: React.Ref<HTMLElement>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Token component. Automatically routes between the Tailwind implementation
|
|
28
|
+
* (preferred) and the styled-components implementation (for consumers using
|
|
29
|
+
* system props or styled() extension).
|
|
30
|
+
*/
|
|
31
|
+
declare const Token: {
|
|
32
|
+
(props: TypeTokenProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
27
35
|
|
|
28
36
|
export { Token, type TypeTokenProps, Token as default };
|
package/dist/index.js
CHANGED
|
@@ -36,12 +36,16 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/Token.tsx
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
39
|
+
var React3 = require("react");
|
|
40
|
+
|
|
41
|
+
// src/TokenHybrid.tsx
|
|
42
|
+
var React2 = require("react");
|
|
43
|
+
var import_seeds_react_utilities2 = require("@sproutsocial/seeds-react-utilities");
|
|
44
|
+
var import_seeds_react_hooks3 = require("@sproutsocial/seeds-react-hooks");
|
|
45
|
+
var import_seeds_react_box2 = __toESM(require("@sproutsocial/seeds-react-box"));
|
|
46
|
+
var import_seeds_react_icon2 = __toESM(require("@sproutsocial/seeds-react-icon"));
|
|
47
|
+
var import_seeds_react_visually_hidden2 = require("@sproutsocial/seeds-react-visually-hidden");
|
|
48
|
+
var import_seeds_react_system_props2 = require("@sproutsocial/seeds-react-system-props");
|
|
45
49
|
|
|
46
50
|
// src/styles.ts
|
|
47
51
|
var import_styled_components = __toESM(require("styled-components"));
|
|
@@ -139,9 +143,31 @@ var Container = import_styled_components.default.button`
|
|
|
139
143
|
`;
|
|
140
144
|
var styles_default = Container;
|
|
141
145
|
|
|
142
|
-
// src/
|
|
146
|
+
// src/TokenTailwind.tsx
|
|
147
|
+
var React = require("react");
|
|
148
|
+
var import_seeds_react_utilities = require("@sproutsocial/seeds-react-utilities");
|
|
149
|
+
var import_seeds_react_hooks2 = require("@sproutsocial/seeds-react-hooks");
|
|
150
|
+
var import_seeds_react_box = __toESM(require("@sproutsocial/seeds-react-box"));
|
|
151
|
+
var import_seeds_react_icon = __toESM(require("@sproutsocial/seeds-react-icon"));
|
|
152
|
+
var import_seeds_react_visually_hidden = require("@sproutsocial/seeds-react-visually-hidden");
|
|
143
153
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
144
|
-
|
|
154
|
+
function cn(...inputs) {
|
|
155
|
+
const classes = [];
|
|
156
|
+
for (const input of inputs) {
|
|
157
|
+
if (!input) continue;
|
|
158
|
+
if (typeof input === "string") {
|
|
159
|
+
classes.push(input);
|
|
160
|
+
} else if (typeof input === "object") {
|
|
161
|
+
for (const [key, value] of Object.entries(input)) {
|
|
162
|
+
if (value) {
|
|
163
|
+
classes.push(key);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return classes.join(" ");
|
|
169
|
+
}
|
|
170
|
+
var TokenTailwind = ({
|
|
145
171
|
children,
|
|
146
172
|
closeable = true,
|
|
147
173
|
onClick,
|
|
@@ -152,21 +178,32 @@ var Token = ({
|
|
|
152
178
|
disabled = false,
|
|
153
179
|
palette = "neutral",
|
|
154
180
|
innerRef = null,
|
|
181
|
+
as,
|
|
182
|
+
className,
|
|
155
183
|
...rest
|
|
156
184
|
}) => {
|
|
157
185
|
const textContainer = (0, import_seeds_react_hooks2.useTextContent)("");
|
|
186
|
+
const isInteractive = closeable || !!onClick;
|
|
187
|
+
const Element = as ?? (isInteractive ? "button" : "div");
|
|
188
|
+
const classes = cn(
|
|
189
|
+
"seeds-token",
|
|
190
|
+
{
|
|
191
|
+
"seeds-token-closeable": isInteractive,
|
|
192
|
+
"seeds-token-blue": palette === "blue",
|
|
193
|
+
"seeds-token-disabled": disabled,
|
|
194
|
+
"seeds-token-invalid": !valid,
|
|
195
|
+
"seeds-token-warning": hasWarning,
|
|
196
|
+
"seeds-token-generated": isGenerated
|
|
197
|
+
},
|
|
198
|
+
className
|
|
199
|
+
);
|
|
158
200
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
159
|
-
|
|
201
|
+
Element,
|
|
160
202
|
{
|
|
161
203
|
ref: (0, import_seeds_react_utilities.mergeRefs)(textContainer, innerRef),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
palette,
|
|
166
|
-
type: closeable || onClick ? "button" : void 0,
|
|
167
|
-
as: closeable || onClick ? "button" : "div",
|
|
168
|
-
closeable: closeable || !!onClick,
|
|
169
|
-
disabled,
|
|
204
|
+
type: isInteractive ? "button" : void 0,
|
|
205
|
+
className: classes,
|
|
206
|
+
...isInteractive ? { disabled } : {},
|
|
170
207
|
onClick,
|
|
171
208
|
"data-qa-token": textContainer.current,
|
|
172
209
|
"data-qa-token-iscloseable": closeable === true,
|
|
@@ -196,10 +233,81 @@ var Token = ({
|
|
|
196
233
|
}
|
|
197
234
|
);
|
|
198
235
|
};
|
|
199
|
-
|
|
236
|
+
TokenTailwind.displayName = "TokenTailwind";
|
|
237
|
+
|
|
238
|
+
// src/TokenHybrid.tsx
|
|
239
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
240
|
+
var TokenStyled = ({
|
|
241
|
+
children,
|
|
242
|
+
closeable = true,
|
|
243
|
+
onClick,
|
|
244
|
+
qa,
|
|
245
|
+
valid = true,
|
|
246
|
+
hasWarning = false,
|
|
247
|
+
isGenerated = false,
|
|
248
|
+
disabled = false,
|
|
249
|
+
palette = "neutral",
|
|
250
|
+
innerRef = null,
|
|
251
|
+
...rest
|
|
252
|
+
}) => {
|
|
253
|
+
const textContainer = (0, import_seeds_react_hooks3.useTextContent)("");
|
|
254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
255
|
+
styles_default,
|
|
256
|
+
{
|
|
257
|
+
ref: (0, import_seeds_react_utilities2.mergeRefs)(textContainer, innerRef),
|
|
258
|
+
valid,
|
|
259
|
+
hasWarning,
|
|
260
|
+
isGenerated,
|
|
261
|
+
palette,
|
|
262
|
+
type: closeable || onClick ? "button" : void 0,
|
|
263
|
+
as: closeable || onClick ? "button" : "div",
|
|
264
|
+
closeable: closeable || !!onClick,
|
|
265
|
+
disabled,
|
|
266
|
+
onClick,
|
|
267
|
+
"data-qa-token": textContainer.current,
|
|
268
|
+
"data-qa-token-iscloseable": closeable === true,
|
|
269
|
+
"data-qa-token-isvalid": valid === true,
|
|
270
|
+
"data-qa-token-isdisabled": disabled === true,
|
|
271
|
+
...qa,
|
|
272
|
+
...rest,
|
|
273
|
+
children: [
|
|
274
|
+
!valid && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_visually_hidden2.VisuallyHidden, { as: "div", role: "status", children: "This is an invalid token" }),
|
|
276
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
277
|
+
import_seeds_react_icon2.default,
|
|
278
|
+
{
|
|
279
|
+
"aria-hidden": true,
|
|
280
|
+
pr: 300,
|
|
281
|
+
name: "circle-exclamation-solid",
|
|
282
|
+
size: "mini"
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_visually_hidden2.VisuallyHidden, { children: "Invalid" })
|
|
286
|
+
] }),
|
|
287
|
+
closeable ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_seeds_react_box2.default, { display: "flex", alignItems: "center", justifyContent: "space-between", children: [
|
|
288
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_box2.default, { as: "span", display: "flex", alignItems: "center", children }),
|
|
289
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_icon2.default, { "aria-hidden": true, pl: 300, name: "x-solid", size: "mini" })
|
|
290
|
+
] }) : children
|
|
291
|
+
]
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
var Token = (props) => {
|
|
296
|
+
if ((0, import_seeds_react_system_props2.hasStyledProps)(props)) {
|
|
297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TokenStyled, { ...props });
|
|
298
|
+
}
|
|
299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TokenTailwind, { ...props });
|
|
300
|
+
};
|
|
301
|
+
var TokenHybrid_default = Token;
|
|
302
|
+
|
|
303
|
+
// src/Token.tsx
|
|
304
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
305
|
+
var Token2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TokenHybrid_default, { ...props });
|
|
306
|
+
Token2.displayName = "Token";
|
|
307
|
+
var Token_default = Token2;
|
|
200
308
|
|
|
201
309
|
// src/TokenTypes.ts
|
|
202
|
-
var
|
|
310
|
+
var React4 = require("react");
|
|
203
311
|
|
|
204
312
|
// src/index.ts
|
|
205
313
|
var index_default = Token_default;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/Token.tsx","../src/styles.ts","../src/TokenTypes.ts"],"sourcesContent":["import Token from \"./Token\";\n\nexport default Token;\nexport { Token };\nexport * from \"./TokenTypes\";\n","import * as React from \"react\";\nimport { mergeRefs } from \"@sproutsocial/seeds-react-utilities\";\nimport { useTextContent } from \"@sproutsocial/seeds-react-hooks\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport Container from \"./styles\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\nconst Token = ({\n children,\n closeable = true,\n onClick,\n qa,\n valid = true,\n hasWarning = false,\n isGenerated = false,\n disabled = false,\n palette = \"neutral\",\n innerRef = null,\n ...rest\n}: TypeTokenProps) => {\n const textContainer = useTextContent(\"\");\n\n return (\n <Container\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore some legacy ref type mismatch between divs\n ref={mergeRefs(textContainer, innerRef)}\n valid={valid}\n hasWarning={hasWarning}\n isGenerated={isGenerated}\n palette={palette}\n type={closeable || onClick ? \"button\" : undefined}\n as={closeable || onClick ? \"button\" : \"div\"}\n closeable={closeable || !!onClick}\n disabled={disabled}\n onClick={onClick}\n data-qa-token={textContainer.current}\n data-qa-token-iscloseable={closeable === true}\n data-qa-token-isvalid={valid === true}\n data-qa-token-isdisabled={disabled === true}\n {...qa}\n {...rest}\n >\n {!valid && (\n <>\n <VisuallyHidden as=\"div\" role=\"status\">\n This is an invalid token\n </VisuallyHidden>\n <Icon\n aria-hidden\n pr={300}\n name=\"circle-exclamation-solid\"\n size=\"mini\"\n />\n <VisuallyHidden>Invalid</VisuallyHidden>\n </>\n )}\n {closeable ? (\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Box as=\"span\" display=\"flex\" alignItems=\"center\">\n {children}\n </Box>\n <Icon aria-hidden pl={300} name=\"x-solid\" size=\"mini\" />\n </Box>\n ) : (\n children\n )}\n </Container>\n );\n};\n\nexport default Token;\n","import styled from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport { useInteractiveColor } from \"@sproutsocial/seeds-react-hooks\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\nconst Container = styled.button<TypeTokenProps>`\n position: relative;\n display: inline-flex;\n align-items: center;\n margin: 0;\n line-height: 1;\n outline: none;\n font-family: ${({ theme }) => theme.fontFamily};\n font-size: ${({ theme }) => theme.fontSizes[200]};\n line-height: 13px;\n font-weight: ${({ theme }) => theme.fontWeights.normal};\n border: 1px solid ${({ theme }) => theme.colors.container.border.base};\n border-radius: ${({ theme }) => theme.radii[500]};\n color: ${({ theme }) => theme.colors.text.body};\n background: ${({ theme }) => theme.colors.container.background.base};\n padding: ${({ theme }) => theme.space[200]} ${({ theme }) => theme.space[300]};\n transition: all ${({ theme }) => theme.duration.fast}\n ${({ theme }) => theme.easing.ease_inout};\n\n &:focus {\n ${focusRing}\n }\n\n ${({ closeable, theme }) =>\n closeable &&\n `\n cursor: pointer;\n &:hover,\n &:active {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.base)};\n }\n `}\n\n ${({ theme, palette }) =>\n palette === \"blue\" &&\n `\n background: ${theme.colors.container.background.decorative.blue};\n border: 1px solid ${theme.colors.container.border.decorative.blue};\n &:hover,\n &:active {\n cursor: pointer;\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.decorative.blue)};\n }\n `}\n\n ${({ disabled, theme }) =>\n disabled &&\n `\n opacity: 0.4;\n cursor: not-allowed;\n &:hover,\n &:active {\n box-shadow: none;\n border: 1px solid ${theme.colors.container.border.base};\n }\n `}\n \n ${({ valid, theme }) =>\n !valid &&\n `\n color: ${theme.colors.text.error};\n background: ${theme.colors.container.background.error};\n border: 1px solid ${theme.colors.container.border.error};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.error)};\n }\n `}\n\n ${({ hasWarning, theme }) =>\n hasWarning &&\n `\n background: ${theme.colors.container.background.warning};\n border: 1px solid ${theme.colors.container.border.warning};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.warning)};\n }\n `}\n\n ${({ isGenerated, theme }) =>\n isGenerated &&\n `\n background: ${theme.colors.container.background.ai_generated};\n border: 1px solid ${theme.colors.container.border.ai_generated};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.ai_generated)};\n }\n color: ${theme.colors.text.ai_generated};\n `}\n\n\t${COMMON}\n`;\n\nexport default Container;\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\ntype TypeQaProps = object;\n\nexport interface TypeTokenProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"button\">, \"color\"> {\n onClick?: React.EventHandler<React.SyntheticEvent>;\n children: React.ReactNode;\n qa?: TypeQaProps;\n\n /** Show the close icon in the token. Can be used with or without icon prop */\n closeable?: boolean;\n\n /** Indicates whether the token value is valid or not */\n valid?: boolean;\n\n /** Indicates whether the token has a related warning */\n hasWarning?: boolean;\n\n /** Indicates whether the token was generated by AI */\n isGenerated?: boolean;\n\n /** Indicates whether the token is disabled */\n disabled?: boolean;\n palette?: \"neutral\" | \"blue\";\n as?: TypeStyledComponentsCommonProps[\"as\"];\n\n /** Used to get a reference to the underlying element */\n innerRef?: React.Ref<HTMLElement>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,mCAA0B;AAC1B,IAAAA,4BAA+B;AAC/B,6BAAgB;AAChB,8BAAiB;AACjB,yCAA+B;;;ACL/B,+BAAmB;AACnB,sCAAuB;AACvB,gCAA0B;AAC1B,+BAAoC;AAGpC,IAAM,YAAY,yBAAAC,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAOR,CAAC,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0CAAe,EAAE;AAEvC,SACE;AAAA,IAAC;AAAA;AAAA,MAGC,SAAK,wCAAU,eAAe,QAAQ;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,aAAa,UAAU,WAAW;AAAA,MACxC,IAAI,aAAa,UAAU,WAAW;AAAA,MACtC,WAAW,aAAa,CAAC,CAAC;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,iBAAe,cAAc;AAAA,MAC7B,6BAA2B,cAAc;AAAA,MACzC,yBAAuB,UAAU;AAAA,MACjC,4BAA0B,aAAa;AAAA,MACtC,GAAG;AAAA,MACH,GAAG;AAAA,MAEH;AAAA,SAAC,SACA,4EACE;AAAA,sDAAC,qDAAe,IAAG,OAAM,MAAK,UAAS,sCAEvC;AAAA,UACA;AAAA,YAAC,wBAAAC;AAAA,YAAA;AAAA,cACC,eAAW;AAAA,cACX,IAAI;AAAA,cACJ,MAAK;AAAA,cACL,MAAK;AAAA;AAAA,UACP;AAAA,UACA,4CAAC,qDAAe,qBAAO;AAAA,WACzB;AAAA,QAED,YACC,6CAAC,uBAAAC,SAAA,EAAI,SAAQ,QAAO,YAAW,UAAS,gBAAe,iBACrD;AAAA,sDAAC,uBAAAA,SAAA,EAAI,IAAG,QAAO,SAAQ,QAAO,YAAW,UACtC,UACH;AAAA,UACA,4CAAC,wBAAAD,SAAA,EAAK,eAAW,MAAC,IAAI,KAAK,MAAK,WAAU,MAAK,QAAO;AAAA,WACxD,IAEA;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,gBAAQ;;;AEzEf,IAAAE,SAAuB;;;AHEvB,IAAO,gBAAQ;","names":["import_seeds_react_hooks","styled","Icon","Box","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/Token.tsx","../src/TokenHybrid.tsx","../src/styles.ts","../src/TokenTailwind.tsx","../src/TokenTypes.ts"],"sourcesContent":["import Token from \"./Token\";\n\nexport default Token;\nexport { Token };\nexport * from \"./TokenTypes\";\n","import * as React from \"react\";\nimport TokenHybrid from \"./TokenHybrid\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\n/**\n * Token component. Automatically routes between the Tailwind implementation\n * (preferred) and the styled-components implementation (for consumers using\n * system props or styled() extension).\n */\nconst Token = (props: TypeTokenProps) => <TokenHybrid {...props} />;\n\nToken.displayName = \"Token\";\n\nexport default Token;\n","/**\n * Hybrid Token Component\n * Automatically chooses between Tailwind and styled-components based on props.\n * Consumers passing styled-system props (e.g. `mb`, `width`, `bg`) get the\n * styled-components implementation; everyone else gets the Tailwind path.\n */\n\nimport * as React from \"react\";\nimport { mergeRefs } from \"@sproutsocial/seeds-react-utilities\";\nimport { useTextContent } from \"@sproutsocial/seeds-react-hooks\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport Container from \"./styles\";\nimport { TokenTailwind } from \"./TokenTailwind\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\n// Styled-components implementation — preserved verbatim from the original Token\n// so consumers using styled-system props get identical behaviour.\nconst TokenStyled = ({\n children,\n closeable = true,\n onClick,\n qa,\n valid = true,\n hasWarning = false,\n isGenerated = false,\n disabled = false,\n palette = \"neutral\",\n innerRef = null,\n ...rest\n}: TypeTokenProps) => {\n const textContainer = useTextContent(\"\");\n\n return (\n <Container\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore some legacy ref type mismatch between divs\n ref={mergeRefs(textContainer, innerRef)}\n valid={valid}\n hasWarning={hasWarning}\n isGenerated={isGenerated}\n palette={palette}\n type={closeable || onClick ? \"button\" : undefined}\n as={closeable || onClick ? \"button\" : \"div\"}\n closeable={closeable || !!onClick}\n disabled={disabled}\n onClick={onClick}\n data-qa-token={textContainer.current}\n data-qa-token-iscloseable={closeable === true}\n data-qa-token-isvalid={valid === true}\n data-qa-token-isdisabled={disabled === true}\n {...qa}\n {...rest}\n >\n {!valid && (\n <>\n <VisuallyHidden as=\"div\" role=\"status\">\n This is an invalid token\n </VisuallyHidden>\n <Icon\n aria-hidden\n pr={300}\n name=\"circle-exclamation-solid\"\n size=\"mini\"\n />\n <VisuallyHidden>Invalid</VisuallyHidden>\n </>\n )}\n {closeable ? (\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Box as=\"span\" display=\"flex\" alignItems=\"center\">\n {children}\n </Box>\n <Icon aria-hidden pl={300} name=\"x-solid\" size=\"mini\" />\n </Box>\n ) : (\n children\n )}\n </Container>\n );\n};\n\nconst Token = (props: TypeTokenProps) => {\n // hasStyledProps only inspects a fixed allowlist of styled-system prop names\n // (bg, color, m*, p*, width, flex*, …), so it is safe to pass the full props —\n // none of Token's own props collide with that list.\n if (hasStyledProps(props)) {\n return <TokenStyled {...props} />;\n }\n\n // Use Tailwind version (preferred - better performance)\n return <TokenTailwind {...props} />;\n};\n\nexport default Token;\n","import styled from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport { useInteractiveColor } from \"@sproutsocial/seeds-react-hooks\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\nconst Container = styled.button<TypeTokenProps>`\n position: relative;\n display: inline-flex;\n align-items: center;\n margin: 0;\n line-height: 1;\n outline: none;\n font-family: ${({ theme }) => theme.fontFamily};\n font-size: ${({ theme }) => theme.fontSizes[200]};\n line-height: 13px;\n font-weight: ${({ theme }) => theme.fontWeights.normal};\n border: 1px solid ${({ theme }) => theme.colors.container.border.base};\n border-radius: ${({ theme }) => theme.radii[500]};\n color: ${({ theme }) => theme.colors.text.body};\n background: ${({ theme }) => theme.colors.container.background.base};\n padding: ${({ theme }) => theme.space[200]} ${({ theme }) => theme.space[300]};\n transition: all ${({ theme }) => theme.duration.fast}\n ${({ theme }) => theme.easing.ease_inout};\n\n &:focus {\n ${focusRing}\n }\n\n ${({ closeable, theme }) =>\n closeable &&\n `\n cursor: pointer;\n &:hover,\n &:active {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.base)};\n }\n `}\n\n ${({ theme, palette }) =>\n palette === \"blue\" &&\n `\n background: ${theme.colors.container.background.decorative.blue};\n border: 1px solid ${theme.colors.container.border.decorative.blue};\n &:hover,\n &:active {\n cursor: pointer;\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.decorative.blue)};\n }\n `}\n\n ${({ disabled, theme }) =>\n disabled &&\n `\n opacity: 0.4;\n cursor: not-allowed;\n &:hover,\n &:active {\n box-shadow: none;\n border: 1px solid ${theme.colors.container.border.base};\n }\n `}\n \n ${({ valid, theme }) =>\n !valid &&\n `\n color: ${theme.colors.text.error};\n background: ${theme.colors.container.background.error};\n border: 1px solid ${theme.colors.container.border.error};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.error)};\n }\n `}\n\n ${({ hasWarning, theme }) =>\n hasWarning &&\n `\n background: ${theme.colors.container.background.warning};\n border: 1px solid ${theme.colors.container.border.warning};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.warning)};\n }\n `}\n\n ${({ isGenerated, theme }) =>\n isGenerated &&\n `\n background: ${theme.colors.container.background.ai_generated};\n border: 1px solid ${theme.colors.container.border.ai_generated};\n &:hover {\n box-shadow: ${theme.shadows.low};\n border: 1px solid\n ${useInteractiveColor(theme.colors.container.border.ai_generated)};\n }\n color: ${theme.colors.text.ai_generated};\n `}\n\n\t${COMMON}\n`;\n\nexport default Container;\n","/**\n * Tailwind CSS implementation of Token component\n * Uses Seeds token CSS classes from token.css\n */\n\nimport * as React from \"react\";\nimport { mergeRefs } from \"@sproutsocial/seeds-react-utilities\";\nimport { useTextContent } from \"@sproutsocial/seeds-react-hooks\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport type { TypeTokenProps } from \"./TokenTypes\";\n\n// Utility for merging class names properly\nfunction cn(\n ...inputs: (string | undefined | null | false | Record<string, boolean>)[]\n): string {\n const classes: string[] = [];\n\n for (const input of inputs) {\n if (!input) continue;\n\n if (typeof input === \"string\") {\n classes.push(input);\n } else if (typeof input === \"object\") {\n for (const [key, value] of Object.entries(input)) {\n if (value) {\n classes.push(key);\n }\n }\n }\n }\n\n return classes.join(\" \");\n}\n\nexport const TokenTailwind = ({\n children,\n closeable = true,\n onClick,\n qa,\n valid = true,\n hasWarning = false,\n isGenerated = false,\n disabled = false,\n palette = \"neutral\",\n innerRef = null,\n as,\n className,\n ...rest\n}: TypeTokenProps) => {\n const textContainer = useTextContent(\"\");\n\n const isInteractive = closeable || !!onClick;\n // Mirror the styled component: it is a styled.button rendered `as` a div when\n // the token is neither closeable nor clickable. A consumer-provided `as` still\n // wins, matching the original (where `as` arrived via {...rest} last).\n const Element = (as ?? (isInteractive ? \"button\" : \"div\")) as React.ElementType;\n\n const classes = cn(\n \"seeds-token\",\n {\n \"seeds-token-closeable\": isInteractive,\n \"seeds-token-blue\": palette === \"blue\",\n \"seeds-token-disabled\": disabled,\n \"seeds-token-invalid\": !valid,\n \"seeds-token-warning\": hasWarning,\n \"seeds-token-generated\": isGenerated,\n },\n className\n );\n\n return (\n <Element\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n //@ts-ignore some legacy ref type mismatch between divs\n ref={mergeRefs(textContainer, innerRef)}\n type={isInteractive ? \"button\" : undefined}\n className={classes}\n {...(isInteractive ? { disabled } : {})}\n onClick={onClick}\n data-qa-token={textContainer.current}\n data-qa-token-iscloseable={closeable === true}\n data-qa-token-isvalid={valid === true}\n data-qa-token-isdisabled={disabled === true}\n {...qa}\n {...rest}\n >\n {!valid && (\n <>\n <VisuallyHidden as=\"div\" role=\"status\">\n This is an invalid token\n </VisuallyHidden>\n <Icon\n aria-hidden\n pr={300}\n name=\"circle-exclamation-solid\"\n size=\"mini\"\n />\n <VisuallyHidden>Invalid</VisuallyHidden>\n </>\n )}\n {closeable ? (\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Box as=\"span\" display=\"flex\" alignItems=\"center\">\n {children}\n </Box>\n <Icon aria-hidden pl={300} name=\"x-solid\" size=\"mini\" />\n </Box>\n ) : (\n children\n )}\n </Element>\n );\n};\n\nTokenTailwind.displayName = \"TokenTailwind\";\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\ntype TypeQaProps = object;\n\nexport interface TypeTokenProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"button\">, \"color\"> {\n onClick?: React.EventHandler<React.SyntheticEvent>;\n children: React.ReactNode;\n qa?: TypeQaProps;\n\n /** Show the close icon in the token. Can be used with or without icon prop */\n closeable?: boolean;\n\n /** Indicates whether the token value is valid or not */\n valid?: boolean;\n\n /** Indicates whether the token has a related warning */\n hasWarning?: boolean;\n\n /** Indicates whether the token was generated by AI */\n isGenerated?: boolean;\n\n /** Indicates whether the token is disabled */\n disabled?: boolean;\n palette?: \"neutral\" | \"blue\";\n as?: TypeStyledComponentsCommonProps[\"as\"];\n\n /** Used to get a reference to the underlying element */\n innerRef?: React.Ref<HTMLElement>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;;;ACOvB,IAAAC,SAAuB;AACvB,IAAAC,gCAA0B;AAC1B,IAAAC,4BAA+B;AAC/B,IAAAC,0BAAgB;AAChB,IAAAC,2BAAiB;AACjB,IAAAC,sCAA+B;AAC/B,IAAAC,mCAA+B;;;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AAAA,MACtC,GAAG;AAAA,MACH,GAAG;AAAA,MAEH;AAAA,SAAC,SACA,8EACE;AAAA,uDAAC,sDAAe,IAAG,OAAM,MAAK,UAAS,sCAEvC;AAAA,UACA;AAAA,YAAC,yBAAAC;AAAA,YAAA;AAAA,cACC,eAAW;AAAA,cACX,IAAI;AAAA,cACJ,MAAK;AAAA,cACL,MAAK;AAAA;AAAA,UACP;AAAA,UACA,6CAAC,sDAAe,qBAAO;AAAA,WACzB;AAAA,QAED,YACC,8CAAC,wBAAAC,SAAA,EAAI,SAAQ,QAAO,YAAW,UAAS,gBAAe,iBACrD;AAAA,uDAAC,wBAAAA,SAAA,EAAI,IAAG,QAAO,SAAQ,QAAO,YAAW,UACtC,UACH;AAAA,UACA,6CAAC,yBAAAD,SAAA,EAAK,eAAW,MAAC,IAAI,KAAK,MAAK,WAAU,MAAK,QAAO;AAAA,WACxD,IAEA;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAM,QAAQ,CAAC,UAA0B;AAIvC,UAAI,iDAAe,KAAK,GAAG;AACzB,WAAO,6CAAC,eAAa,GAAG,OAAO;AAAA,EACjC;AAGA,SAAO,6CAAC,iBAAe,GAAG,OAAO;AACnC;AAEA,IAAO,sBAAQ;;;ADvF0B,IAAAE,sBAAA;AAAzC,IAAMC,SAAQ,CAAC,UAA0B,6CAAC,uBAAa,GAAG,OAAO;AAEjEA,OAAM,cAAc;AAEpB,IAAO,gBAAQA;;;AIbf,IAAAC,SAAuB;;;ALEvB,IAAO,gBAAQ;","names":["React","React","import_seeds_react_utilities","import_seeds_react_hooks","import_seeds_react_box","import_seeds_react_icon","import_seeds_react_visually_hidden","import_seeds_react_system_props","styled","import_seeds_react_hooks","Icon","Box","import_jsx_runtime","Icon","Box","import_jsx_runtime","Token","React"]}
|
package/dist/token.css
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds Token component classes
|
|
3
|
+
* Use these instead of writing out individual Tailwind utility classes.
|
|
4
|
+
*
|
|
5
|
+
* Requires @sproutsocial/seeds-react-theme/dist/theme-all.css imported for
|
|
6
|
+
* CSS variable definitions and dark mode support.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* <button class="seeds-token seeds-token-closeable">Token</button>
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@layer components {
|
|
13
|
+
.seeds-token {
|
|
14
|
+
position: relative;
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
margin: 0;
|
|
18
|
+
outline: none;
|
|
19
|
+
font-family: var(--font-family);
|
|
20
|
+
font-size: var(--font-size-200);
|
|
21
|
+
line-height: 13px;
|
|
22
|
+
font-weight: var(--font-weight-normal);
|
|
23
|
+
border: 1px solid var(--color-container-border-base);
|
|
24
|
+
border-radius: var(--radius-500);
|
|
25
|
+
color: var(--color-text-body);
|
|
26
|
+
background: var(--color-container-bg-base);
|
|
27
|
+
padding: var(--space-200) var(--space-300);
|
|
28
|
+
transition: all var(--duration-fast) var(--ease-ease_inout);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.seeds-token:focus {
|
|
32
|
+
box-shadow:
|
|
33
|
+
0 0 0 1px var(--color-button-primary-bg-base),
|
|
34
|
+
0 0px 0px 4px
|
|
35
|
+
color-mix(in srgb, var(--color-button-primary-bg-base), transparent 70%);
|
|
36
|
+
outline: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.seeds-token::-moz-focus-inner {
|
|
40
|
+
border: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* closeable / clickable */
|
|
44
|
+
.seeds-token-closeable {
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.seeds-token-closeable:hover,
|
|
49
|
+
.seeds-token-closeable:active {
|
|
50
|
+
box-shadow: var(--shadow-low);
|
|
51
|
+
border: 1px solid
|
|
52
|
+
color-mix(in srgb, var(--color-container-border-base), black 20%);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* palette="blue" */
|
|
56
|
+
.seeds-token-blue {
|
|
57
|
+
background: var(--color-container-bg-decorative-blue);
|
|
58
|
+
border: 1px solid var(--color-container-border-decorative-blue);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.seeds-token-blue:hover,
|
|
62
|
+
.seeds-token-blue:active {
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
box-shadow: var(--shadow-low);
|
|
65
|
+
border: 1px solid
|
|
66
|
+
color-mix(in srgb, var(--color-container-border-decorative-blue), black 20%);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* disabled */
|
|
70
|
+
.seeds-token-disabled {
|
|
71
|
+
opacity: 0.4;
|
|
72
|
+
cursor: not-allowed;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.seeds-token-disabled:hover,
|
|
76
|
+
.seeds-token-disabled:active {
|
|
77
|
+
box-shadow: none;
|
|
78
|
+
border: 1px solid var(--color-container-border-base);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* valid={false} */
|
|
82
|
+
.seeds-token-invalid {
|
|
83
|
+
color: var(--color-text-error);
|
|
84
|
+
background: var(--color-container-bg-error);
|
|
85
|
+
border: 1px solid var(--color-container-border-error);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.seeds-token-invalid:hover {
|
|
89
|
+
box-shadow: var(--shadow-low);
|
|
90
|
+
border: 1px solid
|
|
91
|
+
color-mix(in srgb, var(--color-container-border-error), black 20%);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* hasWarning */
|
|
95
|
+
.seeds-token-warning {
|
|
96
|
+
background: var(--color-container-bg-warning);
|
|
97
|
+
border: 1px solid var(--color-container-border-warning);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.seeds-token-warning:hover {
|
|
101
|
+
box-shadow: var(--shadow-low);
|
|
102
|
+
border: 1px solid
|
|
103
|
+
color-mix(in srgb, var(--color-container-border-warning), black 20%);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* isGenerated (AI) */
|
|
107
|
+
.seeds-token-generated {
|
|
108
|
+
background: var(--color-container-bg-ai_generated);
|
|
109
|
+
border: 1px solid var(--color-container-border-ai_generated);
|
|
110
|
+
color: var(--color-text-ai_generated);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.seeds-token-generated:hover {
|
|
114
|
+
box-shadow: var(--shadow-low);
|
|
115
|
+
border: 1px solid
|
|
116
|
+
color-mix(in srgb, var(--color-container-border-ai_generated), black 20%);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Dark mode: useInteractiveColor lightens (white) instead of darkening (black). */
|
|
120
|
+
[data-theme="dark"] .seeds-token-closeable:hover,
|
|
121
|
+
[data-theme="dark"] .seeds-token-closeable:active,
|
|
122
|
+
.dark .seeds-token-closeable:hover,
|
|
123
|
+
.dark .seeds-token-closeable:active,
|
|
124
|
+
.lights-out .seeds-token-closeable:hover,
|
|
125
|
+
.lights-out .seeds-token-closeable:active {
|
|
126
|
+
border: 1px solid
|
|
127
|
+
color-mix(in srgb, var(--color-container-border-base), white 20%);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
[data-theme="dark"] .seeds-token-blue:hover,
|
|
131
|
+
[data-theme="dark"] .seeds-token-blue:active,
|
|
132
|
+
.dark .seeds-token-blue:hover,
|
|
133
|
+
.dark .seeds-token-blue:active,
|
|
134
|
+
.lights-out .seeds-token-blue:hover,
|
|
135
|
+
.lights-out .seeds-token-blue:active {
|
|
136
|
+
border: 1px solid
|
|
137
|
+
color-mix(in srgb, var(--color-container-border-decorative-blue), white 20%);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[data-theme="dark"] .seeds-token-invalid:hover,
|
|
141
|
+
.dark .seeds-token-invalid:hover,
|
|
142
|
+
.lights-out .seeds-token-invalid:hover {
|
|
143
|
+
border: 1px solid
|
|
144
|
+
color-mix(in srgb, var(--color-container-border-error), white 20%);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
[data-theme="dark"] .seeds-token-warning:hover,
|
|
148
|
+
.dark .seeds-token-warning:hover,
|
|
149
|
+
.lights-out .seeds-token-warning:hover {
|
|
150
|
+
border: 1px solid
|
|
151
|
+
color-mix(in srgb, var(--color-container-border-warning), white 20%);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
[data-theme="dark"] .seeds-token-generated:hover,
|
|
155
|
+
.dark .seeds-token-generated:hover,
|
|
156
|
+
.lights-out .seeds-token-generated:hover {
|
|
157
|
+
border: 1px solid
|
|
158
|
+
color-mix(in srgb, var(--color-container-border-ai_generated), white 20%);
|
|
159
|
+
}
|
|
160
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-token",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
4
4
|
"description": "Seeds React Token",
|
|
5
5
|
"author": "Sprout Social, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "tsup --dts",
|
|
12
|
-
"build:debug": "tsup --dts --metafile",
|
|
11
|
+
"build": "tsup --dts && cp src/token.css dist/token.css",
|
|
12
|
+
"build:debug": "tsup --dts --metafile && cp src/token.css dist/token.css",
|
|
13
13
|
"dev": "tsup --watch --dts",
|
|
14
14
|
"clean": "rm -rf .turbo dist",
|
|
15
15
|
"clean:modules": "rm -rf node_modules",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"test:watch": "jest --watch --coverage=false"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@sproutsocial/seeds-react-theme": "^4.
|
|
21
|
+
"@sproutsocial/seeds-react-theme": "^4.2.0",
|
|
22
22
|
"@sproutsocial/seeds-react-system-props": "^3.1.1",
|
|
23
|
-
"@sproutsocial/seeds-react-box": "^1.1.
|
|
24
|
-
"@sproutsocial/seeds-react-icon": "^2.4.
|
|
25
|
-
"@sproutsocial/seeds-react-visually-hidden": "^1.0.
|
|
26
|
-
"@sproutsocial/seeds-react-hooks": "^3.2.
|
|
23
|
+
"@sproutsocial/seeds-react-box": "^1.1.23",
|
|
24
|
+
"@sproutsocial/seeds-react-icon": "^2.4.2",
|
|
25
|
+
"@sproutsocial/seeds-react-visually-hidden": "^1.0.24",
|
|
26
|
+
"@sproutsocial/seeds-react-hooks": "^3.2.4",
|
|
27
27
|
"@sproutsocial/seeds-react-utilities": "^4.2.0",
|
|
28
|
-
"@sproutsocial/seeds-react-mixins": "^4.3.
|
|
28
|
+
"@sproutsocial/seeds-react-mixins": "^4.3.9"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "^18.0.0",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Empty PostCSS config — prevents tsup from picking up the root postcss.config.js
|
|
2
|
+
// (which runs Tailwind CSS and would fail without a tailwind.config.js in scope).
|
|
3
|
+
// token.css uses plain CSS custom properties and needs no PostCSS processing.
|
|
4
|
+
export default {
|
|
5
|
+
plugins: {},
|
|
6
|
+
};
|
package/src/Token.stories.tsx
CHANGED
|
@@ -127,3 +127,15 @@ export const IsGenerated: Story = {
|
|
|
127
127
|
</Token>
|
|
128
128
|
),
|
|
129
129
|
};
|
|
130
|
+
|
|
131
|
+
export const TailwindClassOverride: Story = {
|
|
132
|
+
name: "🚀 Tailwind class override",
|
|
133
|
+
render: (args) => (
|
|
134
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
|
|
135
|
+
<Token {...args}>Default</Token>
|
|
136
|
+
<Token {...args} className="mx-200 p-300 inline-flex">
|
|
137
|
+
mx-200 p-300 inline-flex
|
|
138
|
+
</Token>
|
|
139
|
+
</div>
|
|
140
|
+
),
|
|
141
|
+
};
|
package/src/Token.tsx
CHANGED
|
@@ -1,74 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
import { useTextContent } from "@sproutsocial/seeds-react-hooks";
|
|
4
|
-
import Box from "@sproutsocial/seeds-react-box";
|
|
5
|
-
import Icon from "@sproutsocial/seeds-react-icon";
|
|
6
|
-
import { VisuallyHidden } from "@sproutsocial/seeds-react-visually-hidden";
|
|
7
|
-
import Container from "./styles";
|
|
2
|
+
import TokenHybrid from "./TokenHybrid";
|
|
8
3
|
import type { TypeTokenProps } from "./TokenTypes";
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
hasWarning = false,
|
|
17
|
-
isGenerated = false,
|
|
18
|
-
disabled = false,
|
|
19
|
-
palette = "neutral",
|
|
20
|
-
innerRef = null,
|
|
21
|
-
...rest
|
|
22
|
-
}: TypeTokenProps) => {
|
|
23
|
-
const textContainer = useTextContent("");
|
|
5
|
+
/**
|
|
6
|
+
* Token component. Automatically routes between the Tailwind implementation
|
|
7
|
+
* (preferred) and the styled-components implementation (for consumers using
|
|
8
|
+
* system props or styled() extension).
|
|
9
|
+
*/
|
|
10
|
+
const Token = (props: TypeTokenProps) => <TokenHybrid {...props} />;
|
|
24
11
|
|
|
25
|
-
|
|
26
|
-
<Container
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
28
|
-
//@ts-ignore some legacy ref type mismatch between divs
|
|
29
|
-
ref={mergeRefs(textContainer, innerRef)}
|
|
30
|
-
valid={valid}
|
|
31
|
-
hasWarning={hasWarning}
|
|
32
|
-
isGenerated={isGenerated}
|
|
33
|
-
palette={palette}
|
|
34
|
-
type={closeable || onClick ? "button" : undefined}
|
|
35
|
-
as={closeable || onClick ? "button" : "div"}
|
|
36
|
-
closeable={closeable || !!onClick}
|
|
37
|
-
disabled={disabled}
|
|
38
|
-
onClick={onClick}
|
|
39
|
-
data-qa-token={textContainer.current}
|
|
40
|
-
data-qa-token-iscloseable={closeable === true}
|
|
41
|
-
data-qa-token-isvalid={valid === true}
|
|
42
|
-
data-qa-token-isdisabled={disabled === true}
|
|
43
|
-
{...qa}
|
|
44
|
-
{...rest}
|
|
45
|
-
>
|
|
46
|
-
{!valid && (
|
|
47
|
-
<>
|
|
48
|
-
<VisuallyHidden as="div" role="status">
|
|
49
|
-
This is an invalid token
|
|
50
|
-
</VisuallyHidden>
|
|
51
|
-
<Icon
|
|
52
|
-
aria-hidden
|
|
53
|
-
pr={300}
|
|
54
|
-
name="circle-exclamation-solid"
|
|
55
|
-
size="mini"
|
|
56
|
-
/>
|
|
57
|
-
<VisuallyHidden>Invalid</VisuallyHidden>
|
|
58
|
-
</>
|
|
59
|
-
)}
|
|
60
|
-
{closeable ? (
|
|
61
|
-
<Box display="flex" alignItems="center" justifyContent="space-between">
|
|
62
|
-
<Box as="span" display="flex" alignItems="center">
|
|
63
|
-
{children}
|
|
64
|
-
</Box>
|
|
65
|
-
<Icon aria-hidden pl={300} name="x-solid" size="mini" />
|
|
66
|
-
</Box>
|
|
67
|
-
) : (
|
|
68
|
-
children
|
|
69
|
-
)}
|
|
70
|
-
</Container>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
12
|
+
Token.displayName = "Token";
|
|
73
13
|
|
|
74
14
|
export default Token;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hybrid Token Component
|
|
3
|
+
* Automatically chooses between Tailwind and styled-components based on props.
|
|
4
|
+
* Consumers passing styled-system props (e.g. `mb`, `width`, `bg`) get the
|
|
5
|
+
* styled-components implementation; everyone else gets the Tailwind path.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { mergeRefs } from "@sproutsocial/seeds-react-utilities";
|
|
10
|
+
import { useTextContent } from "@sproutsocial/seeds-react-hooks";
|
|
11
|
+
import Box from "@sproutsocial/seeds-react-box";
|
|
12
|
+
import Icon from "@sproutsocial/seeds-react-icon";
|
|
13
|
+
import { VisuallyHidden } from "@sproutsocial/seeds-react-visually-hidden";
|
|
14
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
15
|
+
import Container from "./styles";
|
|
16
|
+
import { TokenTailwind } from "./TokenTailwind";
|
|
17
|
+
import type { TypeTokenProps } from "./TokenTypes";
|
|
18
|
+
|
|
19
|
+
// Styled-components implementation — preserved verbatim from the original Token
|
|
20
|
+
// so consumers using styled-system props get identical behaviour.
|
|
21
|
+
const TokenStyled = ({
|
|
22
|
+
children,
|
|
23
|
+
closeable = true,
|
|
24
|
+
onClick,
|
|
25
|
+
qa,
|
|
26
|
+
valid = true,
|
|
27
|
+
hasWarning = false,
|
|
28
|
+
isGenerated = false,
|
|
29
|
+
disabled = false,
|
|
30
|
+
palette = "neutral",
|
|
31
|
+
innerRef = null,
|
|
32
|
+
...rest
|
|
33
|
+
}: TypeTokenProps) => {
|
|
34
|
+
const textContainer = useTextContent("");
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Container
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
39
|
+
//@ts-ignore some legacy ref type mismatch between divs
|
|
40
|
+
ref={mergeRefs(textContainer, innerRef)}
|
|
41
|
+
valid={valid}
|
|
42
|
+
hasWarning={hasWarning}
|
|
43
|
+
isGenerated={isGenerated}
|
|
44
|
+
palette={palette}
|
|
45
|
+
type={closeable || onClick ? "button" : undefined}
|
|
46
|
+
as={closeable || onClick ? "button" : "div"}
|
|
47
|
+
closeable={closeable || !!onClick}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
onClick={onClick}
|
|
50
|
+
data-qa-token={textContainer.current}
|
|
51
|
+
data-qa-token-iscloseable={closeable === true}
|
|
52
|
+
data-qa-token-isvalid={valid === true}
|
|
53
|
+
data-qa-token-isdisabled={disabled === true}
|
|
54
|
+
{...qa}
|
|
55
|
+
{...rest}
|
|
56
|
+
>
|
|
57
|
+
{!valid && (
|
|
58
|
+
<>
|
|
59
|
+
<VisuallyHidden as="div" role="status">
|
|
60
|
+
This is an invalid token
|
|
61
|
+
</VisuallyHidden>
|
|
62
|
+
<Icon
|
|
63
|
+
aria-hidden
|
|
64
|
+
pr={300}
|
|
65
|
+
name="circle-exclamation-solid"
|
|
66
|
+
size="mini"
|
|
67
|
+
/>
|
|
68
|
+
<VisuallyHidden>Invalid</VisuallyHidden>
|
|
69
|
+
</>
|
|
70
|
+
)}
|
|
71
|
+
{closeable ? (
|
|
72
|
+
<Box display="flex" alignItems="center" justifyContent="space-between">
|
|
73
|
+
<Box as="span" display="flex" alignItems="center">
|
|
74
|
+
{children}
|
|
75
|
+
</Box>
|
|
76
|
+
<Icon aria-hidden pl={300} name="x-solid" size="mini" />
|
|
77
|
+
</Box>
|
|
78
|
+
) : (
|
|
79
|
+
children
|
|
80
|
+
)}
|
|
81
|
+
</Container>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const Token = (props: TypeTokenProps) => {
|
|
86
|
+
// hasStyledProps only inspects a fixed allowlist of styled-system prop names
|
|
87
|
+
// (bg, color, m*, p*, width, flex*, …), so it is safe to pass the full props —
|
|
88
|
+
// none of Token's own props collide with that list.
|
|
89
|
+
if (hasStyledProps(props)) {
|
|
90
|
+
return <TokenStyled {...props} />;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Use Tailwind version (preferred - better performance)
|
|
94
|
+
return <TokenTailwind {...props} />;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default Token;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind CSS implementation of Token component
|
|
3
|
+
* Uses Seeds token CSS classes from token.css
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { mergeRefs } from "@sproutsocial/seeds-react-utilities";
|
|
8
|
+
import { useTextContent } from "@sproutsocial/seeds-react-hooks";
|
|
9
|
+
import Box from "@sproutsocial/seeds-react-box";
|
|
10
|
+
import Icon from "@sproutsocial/seeds-react-icon";
|
|
11
|
+
import { VisuallyHidden } from "@sproutsocial/seeds-react-visually-hidden";
|
|
12
|
+
import type { TypeTokenProps } from "./TokenTypes";
|
|
13
|
+
|
|
14
|
+
// Utility for merging class names properly
|
|
15
|
+
function cn(
|
|
16
|
+
...inputs: (string | undefined | null | false | Record<string, boolean>)[]
|
|
17
|
+
): string {
|
|
18
|
+
const classes: string[] = [];
|
|
19
|
+
|
|
20
|
+
for (const input of inputs) {
|
|
21
|
+
if (!input) continue;
|
|
22
|
+
|
|
23
|
+
if (typeof input === "string") {
|
|
24
|
+
classes.push(input);
|
|
25
|
+
} else if (typeof input === "object") {
|
|
26
|
+
for (const [key, value] of Object.entries(input)) {
|
|
27
|
+
if (value) {
|
|
28
|
+
classes.push(key);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return classes.join(" ");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const TokenTailwind = ({
|
|
38
|
+
children,
|
|
39
|
+
closeable = true,
|
|
40
|
+
onClick,
|
|
41
|
+
qa,
|
|
42
|
+
valid = true,
|
|
43
|
+
hasWarning = false,
|
|
44
|
+
isGenerated = false,
|
|
45
|
+
disabled = false,
|
|
46
|
+
palette = "neutral",
|
|
47
|
+
innerRef = null,
|
|
48
|
+
as,
|
|
49
|
+
className,
|
|
50
|
+
...rest
|
|
51
|
+
}: TypeTokenProps) => {
|
|
52
|
+
const textContainer = useTextContent("");
|
|
53
|
+
|
|
54
|
+
const isInteractive = closeable || !!onClick;
|
|
55
|
+
// Mirror the styled component: it is a styled.button rendered `as` a div when
|
|
56
|
+
// the token is neither closeable nor clickable. A consumer-provided `as` still
|
|
57
|
+
// wins, matching the original (where `as` arrived via {...rest} last).
|
|
58
|
+
const Element = (as ?? (isInteractive ? "button" : "div")) as React.ElementType;
|
|
59
|
+
|
|
60
|
+
const classes = cn(
|
|
61
|
+
"seeds-token",
|
|
62
|
+
{
|
|
63
|
+
"seeds-token-closeable": isInteractive,
|
|
64
|
+
"seeds-token-blue": palette === "blue",
|
|
65
|
+
"seeds-token-disabled": disabled,
|
|
66
|
+
"seeds-token-invalid": !valid,
|
|
67
|
+
"seeds-token-warning": hasWarning,
|
|
68
|
+
"seeds-token-generated": isGenerated,
|
|
69
|
+
},
|
|
70
|
+
className
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Element
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
|
+
//@ts-ignore some legacy ref type mismatch between divs
|
|
77
|
+
ref={mergeRefs(textContainer, innerRef)}
|
|
78
|
+
type={isInteractive ? "button" : undefined}
|
|
79
|
+
className={classes}
|
|
80
|
+
{...(isInteractive ? { disabled } : {})}
|
|
81
|
+
onClick={onClick}
|
|
82
|
+
data-qa-token={textContainer.current}
|
|
83
|
+
data-qa-token-iscloseable={closeable === true}
|
|
84
|
+
data-qa-token-isvalid={valid === true}
|
|
85
|
+
data-qa-token-isdisabled={disabled === true}
|
|
86
|
+
{...qa}
|
|
87
|
+
{...rest}
|
|
88
|
+
>
|
|
89
|
+
{!valid && (
|
|
90
|
+
<>
|
|
91
|
+
<VisuallyHidden as="div" role="status">
|
|
92
|
+
This is an invalid token
|
|
93
|
+
</VisuallyHidden>
|
|
94
|
+
<Icon
|
|
95
|
+
aria-hidden
|
|
96
|
+
pr={300}
|
|
97
|
+
name="circle-exclamation-solid"
|
|
98
|
+
size="mini"
|
|
99
|
+
/>
|
|
100
|
+
<VisuallyHidden>Invalid</VisuallyHidden>
|
|
101
|
+
</>
|
|
102
|
+
)}
|
|
103
|
+
{closeable ? (
|
|
104
|
+
<Box display="flex" alignItems="center" justifyContent="space-between">
|
|
105
|
+
<Box as="span" display="flex" alignItems="center">
|
|
106
|
+
{children}
|
|
107
|
+
</Box>
|
|
108
|
+
<Icon aria-hidden pl={300} name="x-solid" size="mini" />
|
|
109
|
+
</Box>
|
|
110
|
+
) : (
|
|
111
|
+
children
|
|
112
|
+
)}
|
|
113
|
+
</Element>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
TokenTailwind.displayName = "TokenTailwind";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Token from "../";
|
|
2
|
+
|
|
3
|
+
// Regression guard for DS-4394: racine's `generate:props-docs` runs react-docgen
|
|
4
|
+
// over each package's entry component and keys the output on `displayName`. A bare
|
|
5
|
+
// cross-file re-export resolves to no local definition, so the entry must be a real
|
|
6
|
+
// local component with an explicit `displayName`.
|
|
7
|
+
describe("Token entry component", () => {
|
|
8
|
+
it("exposes an explicit displayName for react-docgen", () => {
|
|
9
|
+
expect((Token as { displayName?: string }).displayName).toBe("Token");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -60,6 +60,21 @@ describe("Token", () => {
|
|
|
60
60
|
expect(onSubmit).not.toHaveBeenCalled();
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
it("should render the Tailwind (CSS-class) implementation by default", () => {
|
|
64
|
+
const { container } = render(<Token closeable={false}>Token</Token>);
|
|
65
|
+
expect(container.querySelector(".seeds-token")).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should render the styled-components implementation when styled-system props are passed", () => {
|
|
69
|
+
const { container } = render(
|
|
70
|
+
<Token closeable={false} mb={400}>
|
|
71
|
+
Token
|
|
72
|
+
</Token>
|
|
73
|
+
);
|
|
74
|
+
expect(container.querySelector(".seeds-token")).not.toBeInTheDocument();
|
|
75
|
+
expect(screen.getByText("Token")).toBeInTheDocument();
|
|
76
|
+
});
|
|
77
|
+
|
|
63
78
|
it("should add a qa selector with text content", () => {
|
|
64
79
|
render(
|
|
65
80
|
<Token closeable={false}>
|
package/src/css.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.css";
|
package/src/token.css
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds Token component classes
|
|
3
|
+
* Use these instead of writing out individual Tailwind utility classes.
|
|
4
|
+
*
|
|
5
|
+
* Requires @sproutsocial/seeds-react-theme/dist/theme-all.css imported for
|
|
6
|
+
* CSS variable definitions and dark mode support.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* <button class="seeds-token seeds-token-closeable">Token</button>
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@layer components {
|
|
13
|
+
.seeds-token {
|
|
14
|
+
position: relative;
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
margin: 0;
|
|
18
|
+
outline: none;
|
|
19
|
+
font-family: var(--font-family);
|
|
20
|
+
font-size: var(--font-size-200);
|
|
21
|
+
line-height: 13px;
|
|
22
|
+
font-weight: var(--font-weight-normal);
|
|
23
|
+
border: 1px solid var(--color-container-border-base);
|
|
24
|
+
border-radius: var(--radius-500);
|
|
25
|
+
color: var(--color-text-body);
|
|
26
|
+
background: var(--color-container-bg-base);
|
|
27
|
+
padding: var(--space-200) var(--space-300);
|
|
28
|
+
transition: all var(--duration-fast) var(--ease-ease_inout);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.seeds-token:focus {
|
|
32
|
+
box-shadow:
|
|
33
|
+
0 0 0 1px var(--color-button-primary-bg-base),
|
|
34
|
+
0 0px 0px 4px
|
|
35
|
+
color-mix(in srgb, var(--color-button-primary-bg-base), transparent 70%);
|
|
36
|
+
outline: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.seeds-token::-moz-focus-inner {
|
|
40
|
+
border: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* closeable / clickable */
|
|
44
|
+
.seeds-token-closeable {
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.seeds-token-closeable:hover,
|
|
49
|
+
.seeds-token-closeable:active {
|
|
50
|
+
box-shadow: var(--shadow-low);
|
|
51
|
+
border: 1px solid
|
|
52
|
+
color-mix(in srgb, var(--color-container-border-base), black 20%);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* palette="blue" */
|
|
56
|
+
.seeds-token-blue {
|
|
57
|
+
background: var(--color-container-bg-decorative-blue);
|
|
58
|
+
border: 1px solid var(--color-container-border-decorative-blue);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.seeds-token-blue:hover,
|
|
62
|
+
.seeds-token-blue:active {
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
box-shadow: var(--shadow-low);
|
|
65
|
+
border: 1px solid
|
|
66
|
+
color-mix(in srgb, var(--color-container-border-decorative-blue), black 20%);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* disabled */
|
|
70
|
+
.seeds-token-disabled {
|
|
71
|
+
opacity: 0.4;
|
|
72
|
+
cursor: not-allowed;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.seeds-token-disabled:hover,
|
|
76
|
+
.seeds-token-disabled:active {
|
|
77
|
+
box-shadow: none;
|
|
78
|
+
border: 1px solid var(--color-container-border-base);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* valid={false} */
|
|
82
|
+
.seeds-token-invalid {
|
|
83
|
+
color: var(--color-text-error);
|
|
84
|
+
background: var(--color-container-bg-error);
|
|
85
|
+
border: 1px solid var(--color-container-border-error);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.seeds-token-invalid:hover {
|
|
89
|
+
box-shadow: var(--shadow-low);
|
|
90
|
+
border: 1px solid
|
|
91
|
+
color-mix(in srgb, var(--color-container-border-error), black 20%);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* hasWarning */
|
|
95
|
+
.seeds-token-warning {
|
|
96
|
+
background: var(--color-container-bg-warning);
|
|
97
|
+
border: 1px solid var(--color-container-border-warning);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.seeds-token-warning:hover {
|
|
101
|
+
box-shadow: var(--shadow-low);
|
|
102
|
+
border: 1px solid
|
|
103
|
+
color-mix(in srgb, var(--color-container-border-warning), black 20%);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* isGenerated (AI) */
|
|
107
|
+
.seeds-token-generated {
|
|
108
|
+
background: var(--color-container-bg-ai_generated);
|
|
109
|
+
border: 1px solid var(--color-container-border-ai_generated);
|
|
110
|
+
color: var(--color-text-ai_generated);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.seeds-token-generated:hover {
|
|
114
|
+
box-shadow: var(--shadow-low);
|
|
115
|
+
border: 1px solid
|
|
116
|
+
color-mix(in srgb, var(--color-container-border-ai_generated), black 20%);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Dark mode: useInteractiveColor lightens (white) instead of darkening (black). */
|
|
120
|
+
[data-theme="dark"] .seeds-token-closeable:hover,
|
|
121
|
+
[data-theme="dark"] .seeds-token-closeable:active,
|
|
122
|
+
.dark .seeds-token-closeable:hover,
|
|
123
|
+
.dark .seeds-token-closeable:active,
|
|
124
|
+
.lights-out .seeds-token-closeable:hover,
|
|
125
|
+
.lights-out .seeds-token-closeable:active {
|
|
126
|
+
border: 1px solid
|
|
127
|
+
color-mix(in srgb, var(--color-container-border-base), white 20%);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
[data-theme="dark"] .seeds-token-blue:hover,
|
|
131
|
+
[data-theme="dark"] .seeds-token-blue:active,
|
|
132
|
+
.dark .seeds-token-blue:hover,
|
|
133
|
+
.dark .seeds-token-blue:active,
|
|
134
|
+
.lights-out .seeds-token-blue:hover,
|
|
135
|
+
.lights-out .seeds-token-blue:active {
|
|
136
|
+
border: 1px solid
|
|
137
|
+
color-mix(in srgb, var(--color-container-border-decorative-blue), white 20%);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[data-theme="dark"] .seeds-token-invalid:hover,
|
|
141
|
+
.dark .seeds-token-invalid:hover,
|
|
142
|
+
.lights-out .seeds-token-invalid:hover {
|
|
143
|
+
border: 1px solid
|
|
144
|
+
color-mix(in srgb, var(--color-container-border-error), white 20%);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
[data-theme="dark"] .seeds-token-warning:hover,
|
|
148
|
+
.dark .seeds-token-warning:hover,
|
|
149
|
+
.lights-out .seeds-token-warning:hover {
|
|
150
|
+
border: 1px solid
|
|
151
|
+
color-mix(in srgb, var(--color-container-border-warning), white 20%);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
[data-theme="dark"] .seeds-token-generated:hover,
|
|
155
|
+
.dark .seeds-token-generated:hover,
|
|
156
|
+
.lights-out .seeds-token-generated:hover {
|
|
157
|
+
border: 1px solid
|
|
158
|
+
color-mix(in srgb, var(--color-container-border-ai_generated), white 20%);
|
|
159
|
+
}
|
|
160
|
+
}
|