@sproutsocial/seeds-react-label 1.0.25 → 1.0.27
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 +67 -11
- package/CHANGELOG.md +15 -0
- package/dist/esm/index.js +75 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +76 -6
- package/dist/index.js.map +1 -1
- package/dist/label.css +17 -0
- package/package.json +14 -6
- package/src/Label.tsx +7 -31
- package/src/LabelHybrid.tsx +47 -0
- package/src/LabelTailwind.tsx +64 -0
- package/src/__tests__/Label.test.tsx +37 -0
- package/src/label.css +17 -0
- package/src/styles.tsx +14 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
yarn run v1.22.22
|
|
2
|
-
$ tsup --dts
|
|
2
|
+
$ tsup --dts && cp src/label.css dist/label.css
|
|
3
|
+
▲ [WARNING] The condition "types" here will never be used as it comes after both "import" and "require" [package.json]
|
|
4
|
+
|
|
5
|
+
package.json:14:6:
|
|
6
|
+
14 │ "types": "./dist/index.d.ts"
|
|
7
|
+
╵ ~~~~~~~
|
|
8
|
+
|
|
9
|
+
The "import" condition comes earlier and will be used for all "import" statements:
|
|
10
|
+
|
|
11
|
+
package.json:12:6:
|
|
12
|
+
12 │ "import": "./dist/esm/index.js",
|
|
13
|
+
╵ ~~~~~~~~
|
|
14
|
+
|
|
15
|
+
The "require" condition comes earlier and will be used for all "require" calls:
|
|
16
|
+
|
|
17
|
+
package.json:13:6:
|
|
18
|
+
13 │ "require": "./dist/index.js",
|
|
19
|
+
╵ ~~~~~~~~~
|
|
20
|
+
|
|
3
21
|
[34mCLI[39m Building entry: src/index.ts
|
|
4
22
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
23
|
[34mCLI[39m tsup v8.5.0
|
|
@@ -8,14 +26,52 @@ $ tsup --dts
|
|
|
8
26
|
[34mCLI[39m Cleaning output folder
|
|
9
27
|
[34mCJS[39m Build start
|
|
10
28
|
[34mESM[39m Build start
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
|
|
29
|
+
[warn] [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe condition "types" here will never be used as it comes after both "import" and "require"[0m [package.json]
|
|
30
|
+
|
|
31
|
+
package.json:14:6:
|
|
32
|
+
[37m 14 │ [32m"types"[37m: "./dist/index.d.ts"
|
|
33
|
+
╵ [32m~~~~~~~[0m
|
|
34
|
+
|
|
35
|
+
The "import" condition comes earlier and will be used for all "import" statements:
|
|
36
|
+
|
|
37
|
+
package.json:12:6:
|
|
38
|
+
[37m 12 │ [32m"import"[37m: "./dist/esm/index.js",
|
|
39
|
+
╵ [32m~~~~~~~~[0m
|
|
40
|
+
|
|
41
|
+
The "require" condition comes earlier and will be used for all "require" calls:
|
|
42
|
+
|
|
43
|
+
package.json:13:6:
|
|
44
|
+
[37m 13 │ [32m"require"[37m: "./dist/index.js",
|
|
45
|
+
╵ [32m~~~~~~~~~[0m
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
[warn] [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe condition "types" here will never be used as it comes after both "import" and "require"[0m [package.json]
|
|
49
|
+
|
|
50
|
+
package.json:14:6:
|
|
51
|
+
[37m 14 │ [32m"types"[37m: "./dist/index.d.ts"
|
|
52
|
+
╵ [32m~~~~~~~[0m
|
|
53
|
+
|
|
54
|
+
The "import" condition comes earlier and will be used for all "import" statements:
|
|
55
|
+
|
|
56
|
+
package.json:12:6:
|
|
57
|
+
[37m 12 │ [32m"import"[37m: "./dist/esm/index.js",
|
|
58
|
+
╵ [32m~~~~~~~~[0m
|
|
59
|
+
|
|
60
|
+
The "require" condition comes earlier and will be used for all "require" calls:
|
|
61
|
+
|
|
62
|
+
package.json:13:6:
|
|
63
|
+
[37m 13 │ [32m"require"[37m: "./dist/index.js",
|
|
64
|
+
╵ [32m~~~~~~~~~[0m
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
[32mCJS[39m [1mdist/index.js [22m[32m4.70 KB[39m
|
|
68
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m5.91 KB[39m
|
|
69
|
+
[32mCJS[39m ⚡️ Build success in 85ms
|
|
70
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m2.60 KB[39m
|
|
71
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m5.75 KB[39m
|
|
72
|
+
[32mESM[39m ⚡️ Build success in 85ms
|
|
17
73
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
21
|
-
Done in
|
|
74
|
+
[32mDTS[39m ⚡️ Build success in 3946ms
|
|
75
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m665.00 B[39m
|
|
76
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m665.00 B[39m
|
|
77
|
+
Done in 6.01s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-label
|
|
2
2
|
|
|
3
|
+
## 1.0.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d21ae54]
|
|
8
|
+
- @sproutsocial/seeds-react-theme@4.2.1
|
|
9
|
+
|
|
10
|
+
## 1.0.26
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [6611f6a]
|
|
15
|
+
- @sproutsocial/seeds-react-system-props@3.1.2
|
|
16
|
+
- @sproutsocial/seeds-react-text@1.5.1
|
|
17
|
+
|
|
3
18
|
## 1.0.25
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -1,30 +1,100 @@
|
|
|
1
1
|
// src/Label.tsx
|
|
2
2
|
import "react";
|
|
3
|
+
|
|
4
|
+
// src/LabelHybrid.tsx
|
|
5
|
+
import "react";
|
|
6
|
+
import Text3 from "@sproutsocial/seeds-react-text";
|
|
7
|
+
|
|
8
|
+
// src/styles.tsx
|
|
9
|
+
import "react";
|
|
3
10
|
import styled from "styled-components";
|
|
4
11
|
import Text from "@sproutsocial/seeds-react-text";
|
|
5
|
-
import { jsx
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
13
|
var LabelBase = ({ as = "label", ...rest }) => /* @__PURE__ */ jsx(Text, { ...rest, as });
|
|
7
14
|
var StyledLabel = styled(LabelBase)`
|
|
8
15
|
display: flex;
|
|
9
16
|
align-items: center;
|
|
10
17
|
`;
|
|
11
|
-
|
|
18
|
+
|
|
19
|
+
// src/LabelTailwind.tsx
|
|
20
|
+
import "react";
|
|
21
|
+
import Text2 from "@sproutsocial/seeds-react-text";
|
|
22
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
23
|
+
function cn(...inputs) {
|
|
24
|
+
const classes = [];
|
|
25
|
+
for (const input of inputs) {
|
|
26
|
+
if (!input) continue;
|
|
27
|
+
if (typeof input === "string") {
|
|
28
|
+
classes.push(input);
|
|
29
|
+
} else if (typeof input === "object") {
|
|
30
|
+
for (const [key, value] of Object.entries(input)) {
|
|
31
|
+
if (value) {
|
|
32
|
+
classes.push(key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return classes.join(" ");
|
|
38
|
+
}
|
|
39
|
+
var LabelTailwind = ({
|
|
40
|
+
htmlFor,
|
|
41
|
+
required,
|
|
42
|
+
children,
|
|
43
|
+
className,
|
|
44
|
+
...rest
|
|
45
|
+
}) => {
|
|
12
46
|
return /* @__PURE__ */ jsxs(
|
|
13
|
-
|
|
47
|
+
LabelBase,
|
|
14
48
|
{
|
|
49
|
+
className: cn("seeds-label", className),
|
|
15
50
|
fontSize: 200,
|
|
16
51
|
fontWeight: "semibold",
|
|
17
52
|
color: "text.headline",
|
|
18
53
|
"data-qa-label": htmlFor,
|
|
19
54
|
htmlFor,
|
|
20
|
-
...
|
|
55
|
+
...rest,
|
|
21
56
|
children: [
|
|
22
57
|
children,
|
|
23
|
-
required && /* @__PURE__ */
|
|
58
|
+
required && /* @__PURE__ */ jsx2(Text2, { ml: 100, "aria-hidden": true, children: "*" })
|
|
24
59
|
]
|
|
25
60
|
}
|
|
26
61
|
);
|
|
27
62
|
};
|
|
63
|
+
LabelTailwind.displayName = "LabelTailwind";
|
|
64
|
+
|
|
65
|
+
// src/LabelHybrid.tsx
|
|
66
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
67
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
68
|
+
var LabelHybrid = ({
|
|
69
|
+
htmlFor,
|
|
70
|
+
required,
|
|
71
|
+
children,
|
|
72
|
+
...rest
|
|
73
|
+
}) => {
|
|
74
|
+
if (hasStyledProps(rest)) {
|
|
75
|
+
return /* @__PURE__ */ jsxs2(
|
|
76
|
+
StyledLabel,
|
|
77
|
+
{
|
|
78
|
+
fontSize: 200,
|
|
79
|
+
fontWeight: "semibold",
|
|
80
|
+
color: "text.headline",
|
|
81
|
+
"data-qa-label": htmlFor,
|
|
82
|
+
htmlFor,
|
|
83
|
+
...rest,
|
|
84
|
+
children: [
|
|
85
|
+
children,
|
|
86
|
+
required && /* @__PURE__ */ jsx3(Text3, { ml: 100, "aria-hidden": true, children: "*" })
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return /* @__PURE__ */ jsx3(LabelTailwind, { htmlFor, required, ...rest, children });
|
|
92
|
+
};
|
|
93
|
+
var LabelHybrid_default = LabelHybrid;
|
|
94
|
+
|
|
95
|
+
// src/Label.tsx
|
|
96
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
97
|
+
var Label = (props) => /* @__PURE__ */ jsx4(LabelHybrid_default, { ...props });
|
|
28
98
|
var Label_default = Label;
|
|
29
99
|
|
|
30
100
|
// src/LabelTypes.ts
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Label.tsx","../../src/LabelTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/Label.tsx","../../src/LabelHybrid.tsx","../../src/styles.tsx","../../src/LabelTailwind.tsx","../../src/LabelTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport LabelHybrid from \"./LabelHybrid\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\n\n/**\n * Label 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 Label = (props: TypeLabelProps) => <LabelHybrid {...props} />;\n\nexport default Label;\n","/**\n * Hybrid Label Component\n * Automatically chooses between Tailwind and styled-components based on props\n */\n\nimport * as React from \"react\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { StyledLabel } from \"./styles\"; // Styled-components version\nimport { LabelTailwind } from \"./LabelTailwind\"; // Tailwind version\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\n\nconst LabelHybrid = ({\n htmlFor,\n required,\n children,\n ...rest\n}: TypeLabelProps) => {\n if (hasStyledProps(rest)) {\n return (\n <StyledLabel\n fontSize={200}\n fontWeight=\"semibold\"\n color=\"text.headline\"\n data-qa-label={htmlFor}\n htmlFor={htmlFor}\n {...rest}\n >\n {children}\n {required && (\n <Text ml={100} aria-hidden>\n *\n </Text>\n )}\n </StyledLabel>\n );\n }\n\n // Use Tailwind version (preferred - better performance)\n return (\n <LabelTailwind htmlFor={htmlFor} required={required} {...rest}>\n {children}\n </LabelTailwind>\n );\n};\n\nexport default LabelHybrid;\n","import * as React from \"react\";\nimport styled from \"styled-components\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\n\nexport const LabelBase = ({ as = \"label\", ...rest }: TypeLabelProps) => (\n <Text {...rest} as={as} />\n);\n\n// TODO: Screen readers should read \"required\" instead of \"*\"\nexport const StyledLabel = styled(LabelBase)`\n display: flex;\n align-items: center;\n`;\n","/**\n * Tailwind CSS implementation of Label component\n * Uses Seeds label CSS classes from label.css\n *\n * Typography (fontSize / fontWeight / color) continues to flow through the\n * Text child props for exact parity; only the flex layout moves to label.css.\n */\n\nimport * as React from \"react\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { LabelBase } from \"./styles\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\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 LabelTailwind = ({\n htmlFor,\n required,\n children,\n className,\n ...rest\n}: TypeLabelProps) => {\n return (\n <LabelBase\n className={cn(\"seeds-label\", className)}\n fontSize={200}\n fontWeight=\"semibold\"\n color=\"text.headline\"\n data-qa-label={htmlFor}\n htmlFor={htmlFor}\n {...rest}\n >\n {children}\n {required && (\n <Text ml={100} aria-hidden>\n *\n </Text>\n )}\n </LabelBase>\n );\n};\n\nLabelTailwind.displayName = \"LabelTailwind\";\n","import * as React from \"react\";\nimport type { TypeTextProps } from \"@sproutsocial/seeds-react-text\";\n\nexport interface TypeLabelProps extends TypeTextProps {\n /** ID of the associated form element */\n htmlFor: string;\n children: React.ReactNode;\n required?: boolean;\n}\n","import Label from \"./Label\";\n\nexport default Label;\nexport { Label };\nexport * from \"./LabelTypes\";\n"],"mappings":";AAAA,OAAuB;;;ACKvB,OAAuB;AACvB,OAAOA,WAAU;;;ACNjB,OAAuB;AACvB,OAAO,YAAY;AACnB,OAAO,UAAU;AAIf;AADK,IAAM,YAAY,CAAC,EAAE,KAAK,SAAS,GAAG,KAAK,MAChD,oBAAC,QAAM,GAAG,MAAM,IAAQ;AAInB,IAAM,cAAc,OAAO,SAAS;AAAA;AAAA;AAAA;;;ACF3C,OAAuB;AACvB,OAAOC,WAAU;AAmCb,SAWI,OAAAC,MAXJ;AA9BJ,SAAS,MACJ,QACK;AACR,QAAM,UAAoB,CAAC;AAE3B,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,MAAO;AAEZ,QAAI,OAAO,UAAU,UAAU;AAC7B,cAAQ,KAAK,KAAK;AAAA,IACpB,WAAW,OAAO,UAAU,UAAU;AACpC,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,YAAI,OAAO;AACT,kBAAQ,KAAK,GAAG;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,KAAK,GAAG;AACzB;AAEO,IAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAsB;AACpB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,eAAe,SAAS;AAAA,MACtC,UAAU;AAAA,MACV,YAAW;AAAA,MACX,OAAM;AAAA,MACN,iBAAe;AAAA,MACf;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,QACA,YACC,gBAAAA,KAACC,OAAA,EAAK,IAAI,KAAK,eAAW,MAAC,eAE3B;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,cAAc,cAAc;;;AFtD5B,SAAS,sBAAsB;AAWzB,SAUI,OAAAC,MAVJ,QAAAC,aAAA;AARN,IAAM,cAAc,CAAC;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAsB;AACpB,MAAI,eAAe,IAAI,GAAG;AACxB,WACE,gBAAAA;AAAA,MAAC;AAAA;AAAA,QACC,UAAU;AAAA,QACV,YAAW;AAAA,QACX,OAAM;AAAA,QACN,iBAAe;AAAA,QACf;AAAA,QACC,GAAG;AAAA,QAEH;AAAA;AAAA,UACA,YACC,gBAAAD,KAACE,OAAA,EAAK,IAAI,KAAK,eAAW,MAAC,eAE3B;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AAGA,SACE,gBAAAF,KAAC,iBAAc,SAAkB,UAAqB,GAAG,MACtD,UACH;AAEJ;AAEA,IAAO,sBAAQ;;;ADrC0B,gBAAAG,YAAA;AAAzC,IAAM,QAAQ,CAAC,UAA0B,gBAAAA,KAAC,uBAAa,GAAG,OAAO;AAEjE,IAAO,gBAAQ;;;AIXf,OAAuB;;;ACEvB,IAAO,gBAAQ;","names":["Text","Text","jsx","Text","jsx","jsxs","Text","jsx"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -9,6 +9,11 @@ interface TypeLabelProps extends TypeTextProps {
|
|
|
9
9
|
required?: boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Label component. Automatically routes between the Tailwind implementation
|
|
14
|
+
* (preferred) and the styled-components implementation (for consumers using
|
|
15
|
+
* system props or styled() extension).
|
|
16
|
+
*/
|
|
17
|
+
declare const Label: (props: TypeLabelProps) => react_jsx_runtime.JSX.Element;
|
|
13
18
|
|
|
14
19
|
export { Label, type TypeLabelProps, Label as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ interface TypeLabelProps extends TypeTextProps {
|
|
|
9
9
|
required?: boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Label component. Automatically routes between the Tailwind implementation
|
|
14
|
+
* (preferred) and the styled-components implementation (for consumers using
|
|
15
|
+
* system props or styled() extension).
|
|
16
|
+
*/
|
|
17
|
+
declare const Label: (props: TypeLabelProps) => react_jsx_runtime.JSX.Element;
|
|
13
18
|
|
|
14
19
|
export { Label, type TypeLabelProps, Label as default };
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,13 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/Label.tsx
|
|
39
|
+
var React4 = require("react");
|
|
40
|
+
|
|
41
|
+
// src/LabelHybrid.tsx
|
|
42
|
+
var React3 = require("react");
|
|
43
|
+
var import_seeds_react_text3 = __toESM(require("@sproutsocial/seeds-react-text"));
|
|
44
|
+
|
|
45
|
+
// src/styles.tsx
|
|
39
46
|
var React = require("react");
|
|
40
47
|
var import_styled_components = __toESM(require("styled-components"));
|
|
41
48
|
var import_seeds_react_text = __toESM(require("@sproutsocial/seeds-react-text"));
|
|
@@ -45,27 +52,90 @@ var StyledLabel = (0, import_styled_components.default)(LabelBase)`
|
|
|
45
52
|
display: flex;
|
|
46
53
|
align-items: center;
|
|
47
54
|
`;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
|
|
56
|
+
// src/LabelTailwind.tsx
|
|
57
|
+
var React2 = require("react");
|
|
58
|
+
var import_seeds_react_text2 = __toESM(require("@sproutsocial/seeds-react-text"));
|
|
59
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
60
|
+
function cn(...inputs) {
|
|
61
|
+
const classes = [];
|
|
62
|
+
for (const input of inputs) {
|
|
63
|
+
if (!input) continue;
|
|
64
|
+
if (typeof input === "string") {
|
|
65
|
+
classes.push(input);
|
|
66
|
+
} else if (typeof input === "object") {
|
|
67
|
+
for (const [key, value] of Object.entries(input)) {
|
|
68
|
+
if (value) {
|
|
69
|
+
classes.push(key);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return classes.join(" ");
|
|
75
|
+
}
|
|
76
|
+
var LabelTailwind = ({
|
|
77
|
+
htmlFor,
|
|
78
|
+
required,
|
|
79
|
+
children,
|
|
80
|
+
className,
|
|
81
|
+
...rest
|
|
82
|
+
}) => {
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
84
|
+
LabelBase,
|
|
51
85
|
{
|
|
86
|
+
className: cn("seeds-label", className),
|
|
52
87
|
fontSize: 200,
|
|
53
88
|
fontWeight: "semibold",
|
|
54
89
|
color: "text.headline",
|
|
55
90
|
"data-qa-label": htmlFor,
|
|
56
91
|
htmlFor,
|
|
57
|
-
...
|
|
92
|
+
...rest,
|
|
58
93
|
children: [
|
|
59
94
|
children,
|
|
60
|
-
required && /* @__PURE__ */ (0,
|
|
95
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_text2.default, { ml: 100, "aria-hidden": true, children: "*" })
|
|
61
96
|
]
|
|
62
97
|
}
|
|
63
98
|
);
|
|
64
99
|
};
|
|
100
|
+
LabelTailwind.displayName = "LabelTailwind";
|
|
101
|
+
|
|
102
|
+
// src/LabelHybrid.tsx
|
|
103
|
+
var import_seeds_react_system_props = require("@sproutsocial/seeds-react-system-props");
|
|
104
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
105
|
+
var LabelHybrid = ({
|
|
106
|
+
htmlFor,
|
|
107
|
+
required,
|
|
108
|
+
children,
|
|
109
|
+
...rest
|
|
110
|
+
}) => {
|
|
111
|
+
if ((0, import_seeds_react_system_props.hasStyledProps)(rest)) {
|
|
112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
113
|
+
StyledLabel,
|
|
114
|
+
{
|
|
115
|
+
fontSize: 200,
|
|
116
|
+
fontWeight: "semibold",
|
|
117
|
+
color: "text.headline",
|
|
118
|
+
"data-qa-label": htmlFor,
|
|
119
|
+
htmlFor,
|
|
120
|
+
...rest,
|
|
121
|
+
children: [
|
|
122
|
+
children,
|
|
123
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_seeds_react_text3.default, { ml: 100, "aria-hidden": true, children: "*" })
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LabelTailwind, { htmlFor, required, ...rest, children });
|
|
129
|
+
};
|
|
130
|
+
var LabelHybrid_default = LabelHybrid;
|
|
131
|
+
|
|
132
|
+
// src/Label.tsx
|
|
133
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
134
|
+
var Label = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LabelHybrid_default, { ...props });
|
|
65
135
|
var Label_default = Label;
|
|
66
136
|
|
|
67
137
|
// src/LabelTypes.ts
|
|
68
|
-
var
|
|
138
|
+
var React5 = require("react");
|
|
69
139
|
|
|
70
140
|
// src/index.ts
|
|
71
141
|
var index_default = Label_default;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/Label.tsx","../src/LabelTypes.ts"],"sourcesContent":["import Label from \"./Label\";\n\nexport default Label;\nexport { Label };\nexport * from \"./LabelTypes\";\n","import * as React from \"react\";\nimport
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/Label.tsx","../src/LabelHybrid.tsx","../src/styles.tsx","../src/LabelTailwind.tsx","../src/LabelTypes.ts"],"sourcesContent":["import Label from \"./Label\";\n\nexport default Label;\nexport { Label };\nexport * from \"./LabelTypes\";\n","import * as React from \"react\";\nimport LabelHybrid from \"./LabelHybrid\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\n\n/**\n * Label 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 Label = (props: TypeLabelProps) => <LabelHybrid {...props} />;\n\nexport default Label;\n","/**\n * Hybrid Label Component\n * Automatically chooses between Tailwind and styled-components based on props\n */\n\nimport * as React from \"react\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { StyledLabel } from \"./styles\"; // Styled-components version\nimport { LabelTailwind } from \"./LabelTailwind\"; // Tailwind version\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\n\nconst LabelHybrid = ({\n htmlFor,\n required,\n children,\n ...rest\n}: TypeLabelProps) => {\n if (hasStyledProps(rest)) {\n return (\n <StyledLabel\n fontSize={200}\n fontWeight=\"semibold\"\n color=\"text.headline\"\n data-qa-label={htmlFor}\n htmlFor={htmlFor}\n {...rest}\n >\n {children}\n {required && (\n <Text ml={100} aria-hidden>\n *\n </Text>\n )}\n </StyledLabel>\n );\n }\n\n // Use Tailwind version (preferred - better performance)\n return (\n <LabelTailwind htmlFor={htmlFor} required={required} {...rest}>\n {children}\n </LabelTailwind>\n );\n};\n\nexport default LabelHybrid;\n","import * as React from \"react\";\nimport styled from \"styled-components\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\n\nexport const LabelBase = ({ as = \"label\", ...rest }: TypeLabelProps) => (\n <Text {...rest} as={as} />\n);\n\n// TODO: Screen readers should read \"required\" instead of \"*\"\nexport const StyledLabel = styled(LabelBase)`\n display: flex;\n align-items: center;\n`;\n","/**\n * Tailwind CSS implementation of Label component\n * Uses Seeds label CSS classes from label.css\n *\n * Typography (fontSize / fontWeight / color) continues to flow through the\n * Text child props for exact parity; only the flex layout moves to label.css.\n */\n\nimport * as React from \"react\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { LabelBase } from \"./styles\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\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 LabelTailwind = ({\n htmlFor,\n required,\n children,\n className,\n ...rest\n}: TypeLabelProps) => {\n return (\n <LabelBase\n className={cn(\"seeds-label\", className)}\n fontSize={200}\n fontWeight=\"semibold\"\n color=\"text.headline\"\n data-qa-label={htmlFor}\n htmlFor={htmlFor}\n {...rest}\n >\n {children}\n {required && (\n <Text ml={100} aria-hidden>\n *\n </Text>\n )}\n </LabelBase>\n );\n};\n\nLabelTailwind.displayName = \"LabelTailwind\";\n","import * as React from \"react\";\nimport type { TypeTextProps } from \"@sproutsocial/seeds-react-text\";\n\nexport interface TypeLabelProps extends TypeTextProps {\n /** ID of the associated form element */\n htmlFor: string;\n children: React.ReactNode;\n required?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;;;ACKvB,IAAAC,SAAuB;AACvB,IAAAC,2BAAiB;;;ACNjB,YAAuB;AACvB,+BAAmB;AACnB,8BAAiB;AAIf;AADK,IAAM,YAAY,CAAC,EAAE,KAAK,SAAS,GAAG,KAAK,MAChD,4CAAC,wBAAAC,SAAA,EAAM,GAAG,MAAM,IAAQ;AAInB,IAAM,kBAAc,yBAAAC,SAAO,SAAS;AAAA;AAAA;AAAA;;;ACF3C,IAAAC,SAAuB;AACvB,IAAAC,2BAAiB;AAmCb,IAAAC,sBAAA;AA9BJ,SAAS,MACJ,QACK;AACR,QAAM,UAAoB,CAAC;AAE3B,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,MAAO;AAEZ,QAAI,OAAO,UAAU,UAAU;AAC7B,cAAQ,KAAK,KAAK;AAAA,IACpB,WAAW,OAAO,UAAU,UAAU;AACpC,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,YAAI,OAAO;AACT,kBAAQ,KAAK,GAAG;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,KAAK,GAAG;AACzB;AAEO,IAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAsB;AACpB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,eAAe,SAAS;AAAA,MACtC,UAAU;AAAA,MACV,YAAW;AAAA,MACX,OAAM;AAAA,MACN,iBAAe;AAAA,MACf;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,QACA,YACC,6CAAC,yBAAAC,SAAA,EAAK,IAAI,KAAK,eAAW,MAAC,eAE3B;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,cAAc,cAAc;;;AFtD5B,sCAA+B;AAWzB,IAAAC,sBAAA;AARN,IAAM,cAAc,CAAC;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAsB;AACpB,UAAI,gDAAe,IAAI,GAAG;AACxB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,UAAU;AAAA,QACV,YAAW;AAAA,QACX,OAAM;AAAA,QACN,iBAAe;AAAA,QACf;AAAA,QACC,GAAG;AAAA,QAEH;AAAA;AAAA,UACA,YACC,6CAAC,yBAAAC,SAAA,EAAK,IAAI,KAAK,eAAW,MAAC,eAE3B;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AAGA,SACE,6CAAC,iBAAc,SAAkB,UAAqB,GAAG,MACtD,UACH;AAEJ;AAEA,IAAO,sBAAQ;;;ADrC0B,IAAAC,sBAAA;AAAzC,IAAM,QAAQ,CAAC,UAA0B,6CAAC,uBAAa,GAAG,OAAO;AAEjE,IAAO,gBAAQ;;;AIXf,IAAAC,SAAuB;;;ALEvB,IAAO,gBAAQ;","names":["React","React","import_seeds_react_text","Text","styled","React","import_seeds_react_text","import_jsx_runtime","Text","import_jsx_runtime","Text","import_jsx_runtime","React"]}
|
package/dist/label.css
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds Label 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
|
+
* All rules are wrapped in `@layer components` so that consumer Tailwind
|
|
9
|
+
* utilities (unlayered) win the cascade over these styles.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@layer components {
|
|
13
|
+
.seeds-label {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-label",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "Seeds React Label",
|
|
5
5
|
"author": "Sprout Social, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/esm/index.js",
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./dist/label.css": "./dist/label.css"
|
|
17
|
+
},
|
|
10
18
|
"scripts": {
|
|
11
|
-
"build": "tsup --dts",
|
|
12
|
-
"build:debug": "tsup --dts --metafile",
|
|
19
|
+
"build": "tsup --dts && cp src/label.css dist/label.css",
|
|
20
|
+
"build:debug": "tsup --dts --metafile && cp src/label.css dist/label.css",
|
|
13
21
|
"dev": "tsup --watch --dts",
|
|
14
22
|
"clean": "rm -rf .turbo dist",
|
|
15
23
|
"clean:modules": "rm -rf node_modules",
|
|
@@ -18,9 +26,9 @@
|
|
|
18
26
|
"test:watch": "jest --watch --coverage=false"
|
|
19
27
|
},
|
|
20
28
|
"dependencies": {
|
|
21
|
-
"@sproutsocial/seeds-react-theme": "^4.2.
|
|
22
|
-
"@sproutsocial/seeds-react-system-props": "^3.1.
|
|
23
|
-
"@sproutsocial/seeds-react-text": "^1.5.
|
|
29
|
+
"@sproutsocial/seeds-react-theme": "^4.2.1",
|
|
30
|
+
"@sproutsocial/seeds-react-system-props": "^3.1.2",
|
|
31
|
+
"@sproutsocial/seeds-react-text": "^1.5.1"
|
|
24
32
|
},
|
|
25
33
|
"devDependencies": {
|
|
26
34
|
"@types/react": "^18.0.0",
|
package/src/Label.tsx
CHANGED
|
@@ -1,36 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
import Text from "@sproutsocial/seeds-react-text";
|
|
2
|
+
import LabelHybrid from "./LabelHybrid";
|
|
4
3
|
import type { TypeLabelProps } from "./LabelTypes";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
const Label = ({ htmlFor, required, children, ...props }: TypeLabelProps) => {
|
|
17
|
-
return (
|
|
18
|
-
<StyledLabel
|
|
19
|
-
fontSize={200}
|
|
20
|
-
fontWeight="semibold"
|
|
21
|
-
color="text.headline"
|
|
22
|
-
data-qa-label={htmlFor}
|
|
23
|
-
htmlFor={htmlFor}
|
|
24
|
-
{...props}
|
|
25
|
-
>
|
|
26
|
-
{children}
|
|
27
|
-
{required && (
|
|
28
|
-
<Text ml={100} aria-hidden>
|
|
29
|
-
*
|
|
30
|
-
</Text>
|
|
31
|
-
)}
|
|
32
|
-
</StyledLabel>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
5
|
+
/**
|
|
6
|
+
* Label 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 Label = (props: TypeLabelProps) => <LabelHybrid {...props} />;
|
|
35
11
|
|
|
36
12
|
export default Label;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hybrid Label Component
|
|
3
|
+
* Automatically chooses between Tailwind and styled-components based on props
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import Text from "@sproutsocial/seeds-react-text";
|
|
8
|
+
import { StyledLabel } from "./styles"; // Styled-components version
|
|
9
|
+
import { LabelTailwind } from "./LabelTailwind"; // Tailwind version
|
|
10
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
11
|
+
import type { TypeLabelProps } from "./LabelTypes";
|
|
12
|
+
|
|
13
|
+
const LabelHybrid = ({
|
|
14
|
+
htmlFor,
|
|
15
|
+
required,
|
|
16
|
+
children,
|
|
17
|
+
...rest
|
|
18
|
+
}: TypeLabelProps) => {
|
|
19
|
+
if (hasStyledProps(rest)) {
|
|
20
|
+
return (
|
|
21
|
+
<StyledLabel
|
|
22
|
+
fontSize={200}
|
|
23
|
+
fontWeight="semibold"
|
|
24
|
+
color="text.headline"
|
|
25
|
+
data-qa-label={htmlFor}
|
|
26
|
+
htmlFor={htmlFor}
|
|
27
|
+
{...rest}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
{required && (
|
|
31
|
+
<Text ml={100} aria-hidden>
|
|
32
|
+
*
|
|
33
|
+
</Text>
|
|
34
|
+
)}
|
|
35
|
+
</StyledLabel>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Use Tailwind version (preferred - better performance)
|
|
40
|
+
return (
|
|
41
|
+
<LabelTailwind htmlFor={htmlFor} required={required} {...rest}>
|
|
42
|
+
{children}
|
|
43
|
+
</LabelTailwind>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default LabelHybrid;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind CSS implementation of Label component
|
|
3
|
+
* Uses Seeds label CSS classes from label.css
|
|
4
|
+
*
|
|
5
|
+
* Typography (fontSize / fontWeight / color) continues to flow through the
|
|
6
|
+
* Text child props for exact parity; only the flex layout moves to label.css.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import Text from "@sproutsocial/seeds-react-text";
|
|
11
|
+
import { LabelBase } from "./styles";
|
|
12
|
+
import type { TypeLabelProps } from "./LabelTypes";
|
|
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 LabelTailwind = ({
|
|
38
|
+
htmlFor,
|
|
39
|
+
required,
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
...rest
|
|
43
|
+
}: TypeLabelProps) => {
|
|
44
|
+
return (
|
|
45
|
+
<LabelBase
|
|
46
|
+
className={cn("seeds-label", className)}
|
|
47
|
+
fontSize={200}
|
|
48
|
+
fontWeight="semibold"
|
|
49
|
+
color="text.headline"
|
|
50
|
+
data-qa-label={htmlFor}
|
|
51
|
+
htmlFor={htmlFor}
|
|
52
|
+
{...rest}
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
{required && (
|
|
56
|
+
<Text ml={100} aria-hidden>
|
|
57
|
+
*
|
|
58
|
+
</Text>
|
|
59
|
+
)}
|
|
60
|
+
</LabelBase>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
LabelTailwind.displayName = "LabelTailwind";
|
|
@@ -8,4 +8,41 @@ describe("Label", () => {
|
|
|
8
8
|
|
|
9
9
|
expect(screen.getByText("First Name:")).toBeInTheDocument();
|
|
10
10
|
});
|
|
11
|
+
|
|
12
|
+
it("renders the Tailwind path with the seeds-label class and qa attribute", () => {
|
|
13
|
+
const { container } = render(<Label htmlFor="firstname">First Name:</Label>);
|
|
14
|
+
const label = container.querySelector("[data-qa-label]");
|
|
15
|
+
expect(label).toHaveClass("seeds-label");
|
|
16
|
+
expect(label).toHaveAttribute("data-qa-label", "firstname");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("renders the required marker on the Tailwind path", () => {
|
|
20
|
+
render(
|
|
21
|
+
<Label htmlFor="firstname" required>
|
|
22
|
+
First Name:
|
|
23
|
+
</Label>
|
|
24
|
+
);
|
|
25
|
+
expect(screen.getByText("*")).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("merges a consumer className on the Tailwind path (styled() contract)", () => {
|
|
29
|
+
const { container } = render(
|
|
30
|
+
<Label htmlFor="firstname" className="custom">
|
|
31
|
+
First Name:
|
|
32
|
+
</Label>
|
|
33
|
+
);
|
|
34
|
+
const label = container.querySelector("[data-qa-label]");
|
|
35
|
+
expect(label).toHaveClass("seeds-label");
|
|
36
|
+
expect(label).toHaveClass("custom");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("routes through the styled-components path when a system prop is present", () => {
|
|
40
|
+
// mt is a system prop, which routes Label through the styled-components path
|
|
41
|
+
render(
|
|
42
|
+
<Label htmlFor="firstname" mt={200}>
|
|
43
|
+
First Name:
|
|
44
|
+
</Label>
|
|
45
|
+
);
|
|
46
|
+
expect(screen.getByText("First Name:")).toBeInTheDocument();
|
|
47
|
+
});
|
|
11
48
|
});
|
package/src/label.css
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds Label 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
|
+
* All rules are wrapped in `@layer components` so that consumer Tailwind
|
|
9
|
+
* utilities (unlayered) win the cascade over these styles.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@layer components {
|
|
13
|
+
.seeds-label {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/styles.tsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import Text from "@sproutsocial/seeds-react-text";
|
|
4
|
+
import type { TypeLabelProps } from "./LabelTypes";
|
|
5
|
+
|
|
6
|
+
export const LabelBase = ({ as = "label", ...rest }: TypeLabelProps) => (
|
|
7
|
+
<Text {...rest} as={as} />
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
// TODO: Screen readers should read "required" instead of "*"
|
|
11
|
+
export const StyledLabel = styled(LabelBase)`
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
`;
|