@sproutsocial/seeds-react-label 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore ADDED
@@ -0,0 +1,6 @@
1
+ # Node modules
2
+ node_modules/
3
+
4
+ # Build output
5
+ dist/
6
+ coverage/
package/.eslintrc.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ["eslint-config-seeds/racine"],
4
+ };
@@ -0,0 +1,21 @@
1
+ yarn run v1.22.22
2
+ $ tsup --dts
3
+ CLI Building entry: src/index.ts
4
+ CLI Using tsconfig: tsconfig.json
5
+ CLI tsup v8.0.2
6
+ CLI Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-label/tsup.config.ts
7
+ CLI Target: es2022
8
+ CLI Cleaning output folder
9
+ CJS Build start
10
+ ESM Build start
11
+ CJS dist/index.js 2.76 KB
12
+ CJS dist/index.js.map 1.97 KB
13
+ CJS ⚡️ Build success in 159ms
14
+ ESM dist/esm/index.js 965.00 B
15
+ ESM dist/esm/index.js.map 1.88 KB
16
+ ESM ⚡️ Build success in 163ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 29769ms
19
+ DTS dist/index.d.ts 499.00 B
20
+ DTS dist/index.d.mts 499.00 B
21
+ Done in 37.43s.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @sproutsocial/seeds-react-label
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 8ca97dd: Migrated FormField, Fieldset, and Label to their own seeds-react component
@@ -0,0 +1,39 @@
1
+ // src/Label.tsx
2
+ import "react";
3
+ import styled from "styled-components";
4
+ import Text from "@sproutsocial/seeds-react-text";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ var LabelBase = ({ as = "label", ...rest }) => /* @__PURE__ */ jsx(Text, { ...rest, as });
7
+ var StyledLabel = styled(LabelBase)`
8
+ display: flex;
9
+ align-items: center;
10
+ `;
11
+ var Label = ({ htmlFor, required, children, ...props }) => {
12
+ return /* @__PURE__ */ jsxs(
13
+ StyledLabel,
14
+ {
15
+ fontSize: 200,
16
+ fontWeight: "semibold",
17
+ color: "text.headline",
18
+ "data-qa-label": htmlFor,
19
+ htmlFor,
20
+ ...props,
21
+ children: [
22
+ children,
23
+ required && /* @__PURE__ */ jsx(Text, { ml: 100, "aria-hidden": true, children: "*" })
24
+ ]
25
+ }
26
+ );
27
+ };
28
+ var Label_default = Label;
29
+
30
+ // src/LabelTypes.ts
31
+ import "react";
32
+
33
+ // src/index.ts
34
+ var src_default = Label_default;
35
+ export {
36
+ Label_default as Label,
37
+ src_default as default
38
+ };
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Label.tsx","../../src/LabelTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport styled from \"styled-components\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\n\nconst LabelBase = ({ as = \"label\", ...rest }: TypeLabelProps) => (\n <Text {...rest} as={as} />\n);\n\n// TODO: Screen readers should read \"required\" instead of \"*\"\nconst StyledLabel = styled(LabelBase)`\n display: flex;\n align-items: center;\n`;\n\nconst Label = ({ htmlFor, required, children, ...props }: TypeLabelProps) => {\n return (\n <StyledLabel\n fontSize={200}\n fontWeight=\"semibold\"\n color=\"text.headline\"\n data-qa-label={htmlFor}\n htmlFor={htmlFor}\n {...props}\n >\n {children}\n {required && (\n <Text ml={100} aria-hidden>\n *\n </Text>\n )}\n </StyledLabel>\n );\n};\n\nexport default Label;\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;AACvB,OAAO,YAAY;AACnB,OAAO,UAAU;AAIf,cAWE,YAXF;AADF,IAAM,YAAY,CAAC,EAAE,KAAK,SAAS,GAAG,KAAK,MACzC,oBAAC,QAAM,GAAG,MAAM,IAAQ;AAI1B,IAAM,cAAc,OAAO,SAAS;AAAA;AAAA;AAAA;AAKpC,IAAM,QAAQ,CAAC,EAAE,SAAS,UAAU,UAAU,GAAG,MAAM,MAAsB;AAC3E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,YAAW;AAAA,MACX,OAAM;AAAA,MACN,iBAAe;AAAA,MACf;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,QACA,YACC,oBAAC,QAAK,IAAI,KAAK,eAAW,MAAC,eAE3B;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,gBAAQ;;;ACnCf,OAAuB;;;ACEvB,IAAO,cAAQ;","names":[]}
@@ -0,0 +1,14 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { TypeTextProps } from '@sproutsocial/seeds-react-text';
4
+
5
+ interface TypeLabelProps extends TypeTextProps {
6
+ /** ID of the associated form element */
7
+ htmlFor: string;
8
+ children: React.ReactNode;
9
+ required?: boolean;
10
+ }
11
+
12
+ declare const Label: ({ htmlFor, required, children, ...props }: TypeLabelProps) => react_jsx_runtime.JSX.Element;
13
+
14
+ export { Label, type TypeLabelProps, Label as default };
@@ -0,0 +1,14 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { TypeTextProps } from '@sproutsocial/seeds-react-text';
4
+
5
+ interface TypeLabelProps extends TypeTextProps {
6
+ /** ID of the associated form element */
7
+ htmlFor: string;
8
+ children: React.ReactNode;
9
+ required?: boolean;
10
+ }
11
+
12
+ declare const Label: ({ htmlFor, required, children, ...props }: TypeLabelProps) => react_jsx_runtime.JSX.Element;
13
+
14
+ export { Label, type TypeLabelProps, Label as default };
package/dist/index.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ Label: () => Label_default,
34
+ default: () => src_default
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+
38
+ // src/Label.tsx
39
+ var React = require("react");
40
+ var import_styled_components = __toESM(require("styled-components"));
41
+ var import_seeds_react_text = __toESM(require("@sproutsocial/seeds-react-text"));
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var LabelBase = ({ as = "label", ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.default, { ...rest, as });
44
+ var StyledLabel = (0, import_styled_components.default)(LabelBase)`
45
+ display: flex;
46
+ align-items: center;
47
+ `;
48
+ var Label = ({ htmlFor, required, children, ...props }) => {
49
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
50
+ StyledLabel,
51
+ {
52
+ fontSize: 200,
53
+ fontWeight: "semibold",
54
+ color: "text.headline",
55
+ "data-qa-label": htmlFor,
56
+ htmlFor,
57
+ ...props,
58
+ children: [
59
+ children,
60
+ required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.default, { ml: 100, "aria-hidden": true, children: "*" })
61
+ ]
62
+ }
63
+ );
64
+ };
65
+ var Label_default = Label;
66
+
67
+ // src/LabelTypes.ts
68
+ var React2 = require("react");
69
+
70
+ // src/index.ts
71
+ var src_default = Label_default;
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ Label
75
+ });
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 styled from \"styled-components\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport type { TypeLabelProps } from \"./LabelTypes\";\n\nconst LabelBase = ({ as = \"label\", ...rest }: TypeLabelProps) => (\n <Text {...rest} as={as} />\n);\n\n// TODO: Screen readers should read \"required\" instead of \"*\"\nconst StyledLabel = styled(LabelBase)`\n display: flex;\n align-items: center;\n`;\n\nconst Label = ({ htmlFor, required, children, ...props }: TypeLabelProps) => {\n return (\n <StyledLabel\n fontSize={200}\n fontWeight=\"semibold\"\n color=\"text.headline\"\n data-qa-label={htmlFor}\n htmlFor={htmlFor}\n {...props}\n >\n {children}\n {required && (\n <Text ml={100} aria-hidden>\n *\n </Text>\n )}\n </StyledLabel>\n );\n};\n\nexport default Label;\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,YAAuB;AACvB,+BAAmB;AACnB,8BAAiB;AAIf;AADF,IAAM,YAAY,CAAC,EAAE,KAAK,SAAS,GAAG,KAAK,MACzC,4CAAC,wBAAAA,SAAA,EAAM,GAAG,MAAM,IAAQ;AAI1B,IAAM,kBAAc,yBAAAC,SAAO,SAAS;AAAA;AAAA;AAAA;AAKpC,IAAM,QAAQ,CAAC,EAAE,SAAS,UAAU,UAAU,GAAG,MAAM,MAAsB;AAC3E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,YAAW;AAAA,MACX,OAAM;AAAA,MACN,iBAAe;AAAA,MACf;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,QACA,YACC,4CAAC,wBAAAD,SAAA,EAAK,IAAI,KAAK,eAAW,MAAC,eAE3B;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,gBAAQ;;;ACnCf,IAAAE,SAAuB;;;AFEvB,IAAO,cAAQ;","names":["Text","styled","React"]}
package/jest.config.js ADDED
@@ -0,0 +1,9 @@
1
+ const baseConfig = require("@sproutsocial/seeds-testing");
2
+
3
+ /** * @type {import('jest').Config} */
4
+ const config = {
5
+ ...baseConfig,
6
+ displayName: "seeds-react-label",
7
+ };
8
+
9
+ module.exports = config;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@sproutsocial/seeds-react-label",
3
+ "version": "1.0.0",
4
+ "description": "Seeds React Label",
5
+ "author": "Sprout Social, Inc.",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "module": "dist/esm/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "scripts": {
11
+ "build": "tsup --dts",
12
+ "build:debug": "tsup --dts --metafile",
13
+ "dev": "tsup --watch --dts",
14
+ "clean": "rm -rf .turbo dist",
15
+ "clean:modules": "rm -rf node_modules",
16
+ "typecheck": "tsc --noEmit",
17
+ "test": "jest",
18
+ "test:watch": "jest --watch --coverage=false"
19
+ },
20
+ "dependencies": {
21
+ "@sproutsocial/seeds-react-theme": "^*",
22
+ "@sproutsocial/seeds-react-system-props": "^*",
23
+ "@sproutsocial/seeds-react-text": "*"
24
+ },
25
+ "devDependencies": {
26
+ "@types/react": "^18.0.0",
27
+ "@types/styled-components": "^5.1.26",
28
+ "@sproutsocial/eslint-config-seeds": "*",
29
+ "react": "^18.0.0",
30
+ "styled-components": "^5.2.3",
31
+ "tsup": "^8.0.2",
32
+ "typescript": "^5.6.2",
33
+ "@sproutsocial/seeds-tsconfig": "*",
34
+ "@sproutsocial/seeds-testing": "*",
35
+ "@sproutsocial/seeds-react-testing-library": "*"
36
+ },
37
+ "peerDependencies": {
38
+ "styled-components": "^5.2.3"
39
+ },
40
+ "engines": {
41
+ "node": ">=18"
42
+ }
43
+ }
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { Input } from "@sproutsocial/seeds-react-input";
4
+ import { Text } from "@sproutsocial/seeds-react-text";
5
+ import Label from "./Label";
6
+
7
+ const meta: Meta<typeof Label> = {
8
+ title: "Components/Form Elements/Label",
9
+ component: Label,
10
+ };
11
+ export default meta;
12
+
13
+ type Story = StoryObj<typeof Label>;
14
+
15
+ export const Default: Story = {
16
+ render: () => <Label htmlFor="default">Example label</Label>,
17
+ };
18
+
19
+ export const RequiredLabel: Story = {
20
+ render: () => (
21
+ <>
22
+ <Text.Byline mb={300}>*=Required</Text.Byline>
23
+ <Label htmlFor="name" required mb={200}>
24
+ Full name
25
+ </Label>
26
+ <Input name="name" id="name" required />
27
+ </>
28
+ ),
29
+ };
package/src/Label.tsx ADDED
@@ -0,0 +1,36 @@
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
+ const LabelBase = ({ as = "label", ...rest }: TypeLabelProps) => (
7
+ <Text {...rest} as={as} />
8
+ );
9
+
10
+ // TODO: Screen readers should read "required" instead of "*"
11
+ const StyledLabel = styled(LabelBase)`
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
+ };
35
+
36
+ export default Label;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ import type { TypeTextProps } from "@sproutsocial/seeds-react-text";
3
+
4
+ export interface TypeLabelProps extends TypeTextProps {
5
+ /** ID of the associated form element */
6
+ htmlFor: string;
7
+ children: React.ReactNode;
8
+ required?: boolean;
9
+ }
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { render, screen } from "@sproutsocial/seeds-react-testing-library";
3
+ import Label from "../Label";
4
+
5
+ describe("Label", () => {
6
+ it("should render the proper text", () => {
7
+ render(<Label htmlFor="firstname">First Name:</Label>);
8
+
9
+ expect(screen.getByText("First Name:")).toBeInTheDocument();
10
+ });
11
+ });
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import Label from "../";
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ function LabelTypes() {
6
+ return (
7
+ <>
8
+ <Label htmlFor="default">Example label</Label>
9
+ {/* @ts-expect-error - test that missing required props is rejected */}
10
+ <Label />
11
+ </>
12
+ );
13
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import Label from "./Label";
2
+
3
+ export default Label;
4
+ export { Label };
5
+ export * from "./LabelTypes";
@@ -0,0 +1,7 @@
1
+ import "styled-components";
2
+ import { TypeTheme } from "@sproutsocial/seeds-react-theme";
3
+
4
+ declare module "styled-components" {
5
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
6
+ export interface DefaultTheme extends TypeTheme {}
7
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@sproutsocial/seeds-tsconfig/bundler/dom/library-monorepo",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "module": "esnext"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "dist", "coverage", "**/*.stories.tsx"]
9
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig((options) => ({
4
+ entry: ["src/index.ts"],
5
+ format: ["cjs", "esm"],
6
+ clean: true,
7
+ legacyOutput: true,
8
+ dts: options.dts,
9
+ external: ["react"],
10
+ sourcemap: true,
11
+ metafile: options.metafile,
12
+ }));