@sproutsocial/seeds-react-fieldset 1.0.26 → 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/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- // src/Fieldset.tsx
2
- import * as React from "react";
1
+ // src/FieldsetHybrid.tsx
2
+ import * as React2 from "react";
3
3
  import Box2 from "@sproutsocial/seeds-react-box";
4
- import Text from "@sproutsocial/seeds-react-text";
4
+ import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
5
5
 
6
6
  // src/styles.ts
7
7
  import styled, { css } from "styled-components";
@@ -24,27 +24,13 @@ var ChildContainer = styled(Box)`
24
24
  `}
25
25
  `;
26
26
 
27
- // src/Fieldset.tsx
28
- import { jsx, jsxs } from "react/jsx-runtime";
29
- var Fieldset = ({
30
- layout = "vertical",
31
- label,
32
- helperText,
27
+ // src/FieldsetParts.tsx
28
+ import Text from "@sproutsocial/seeds-react-text";
29
+ import { jsx } from "react/jsx-runtime";
30
+ var FieldsetLegend = ({
33
31
  children,
34
32
  ...rest
35
- }) => /* @__PURE__ */ jsxs(Box2, { as: "fieldset", border: "none", p: 0, "data-qa-fieldset": "", ...rest, children: [
36
- typeof label === "string" ? /* @__PURE__ */ jsx(Fieldset.Legend, { children: label }) : label,
37
- typeof helperText === "string" ? /* @__PURE__ */ jsx(Fieldset.HelperText, { children: helperText }) : helperText,
38
- /* @__PURE__ */ jsx(
39
- Box2,
40
- {
41
- display: "flex",
42
- flexDirection: layout === "vertical" ? "column" : "row",
43
- children: React.Children.map(children, (child) => /* @__PURE__ */ jsx(ChildContainer, { layout, children: child }))
44
- }
45
- )
46
- ] });
47
- var FieldsetLegend = ({ children, ...rest }) => /* @__PURE__ */ jsx(
33
+ }) => /* @__PURE__ */ jsx(
48
34
  Text,
49
35
  {
50
36
  as: "legend",
@@ -56,11 +42,108 @@ var FieldsetLegend = ({ children, ...rest }) => /* @__PURE__ */ jsx(
56
42
  children
57
43
  }
58
44
  );
59
- var FieldsetHelperText = ({ children, ...rest }) => /* @__PURE__ */ jsx(Text, { as: "p", fontSize: 200, mb: 300, ...rest, children });
45
+ var FieldsetHelperText = ({
46
+ children,
47
+ ...rest
48
+ }) => /* @__PURE__ */ jsx(Text, { as: "p", fontSize: 200, mb: 300, ...rest, children });
60
49
  FieldsetLegend.displayName = "Fieldset.Legend";
61
50
  FieldsetHelperText.displayName = "Fieldset.HelperText";
62
- Fieldset.Legend = FieldsetLegend;
63
- Fieldset.HelperText = FieldsetHelperText;
51
+
52
+ // src/FieldsetTailwind.tsx
53
+ import * as React from "react";
54
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
55
+ function cn(...inputs) {
56
+ const classes = [];
57
+ for (const input of inputs) {
58
+ if (!input) continue;
59
+ if (typeof input === "string") {
60
+ classes.push(input);
61
+ } else if (typeof input === "object") {
62
+ for (const [key, value] of Object.entries(input)) {
63
+ if (value) {
64
+ classes.push(key);
65
+ }
66
+ }
67
+ }
68
+ }
69
+ return classes.join(" ");
70
+ }
71
+ var FieldsetTailwind = ({
72
+ layout = "vertical",
73
+ label,
74
+ helperText,
75
+ children,
76
+ className,
77
+ ...rest
78
+ }) => {
79
+ const Root = "fieldset";
80
+ return /* @__PURE__ */ jsxs(
81
+ Root,
82
+ {
83
+ className: cn("seeds-fieldset", className),
84
+ "data-qa-fieldset": "",
85
+ ...rest,
86
+ children: [
87
+ typeof label === "string" ? /* @__PURE__ */ jsx2("legend", { className: "seeds-fieldset-legend", children: label }) : label,
88
+ typeof helperText === "string" ? /* @__PURE__ */ jsx2("p", { className: "seeds-fieldset-helper-text", children: helperText }) : helperText,
89
+ /* @__PURE__ */ jsx2("div", { className: cn("seeds-fieldset-list", `seeds-fieldset-list-${layout}`), children: React.Children.map(children, (child) => /* @__PURE__ */ jsx2(
90
+ "div",
91
+ {
92
+ className: cn(
93
+ "seeds-fieldset-item",
94
+ `seeds-fieldset-item-${layout}`
95
+ ),
96
+ children: child
97
+ }
98
+ )) })
99
+ ]
100
+ }
101
+ );
102
+ };
103
+ FieldsetTailwind.displayName = "FieldsetTailwind";
104
+
105
+ // src/FieldsetHybrid.tsx
106
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
107
+ var FieldsetHybrid = ({
108
+ layout = "vertical",
109
+ label,
110
+ helperText,
111
+ children,
112
+ ...rest
113
+ }) => {
114
+ if (hasStyledProps(rest)) {
115
+ return /* @__PURE__ */ jsxs2(Box2, { as: "fieldset", border: "none", p: 0, "data-qa-fieldset": "", ...rest, children: [
116
+ typeof label === "string" ? /* @__PURE__ */ jsx3(FieldsetLegend, { children: label }) : label,
117
+ typeof helperText === "string" ? /* @__PURE__ */ jsx3(FieldsetHelperText, { children: helperText }) : helperText,
118
+ /* @__PURE__ */ jsx3(
119
+ Box2,
120
+ {
121
+ display: "flex",
122
+ flexDirection: layout === "vertical" ? "column" : "row",
123
+ children: React2.Children.map(children, (child) => /* @__PURE__ */ jsx3(ChildContainer, { layout, children: child }))
124
+ }
125
+ )
126
+ ] });
127
+ }
128
+ return /* @__PURE__ */ jsx3(
129
+ FieldsetTailwind,
130
+ {
131
+ layout,
132
+ label,
133
+ helperText,
134
+ ...rest,
135
+ children
136
+ }
137
+ );
138
+ };
139
+ FieldsetHybrid.displayName = "Fieldset";
140
+ var FieldsetHybrid_default = FieldsetHybrid;
141
+
142
+ // src/Fieldset.tsx
143
+ var Fieldset = Object.assign(FieldsetHybrid_default, {
144
+ Legend: FieldsetLegend,
145
+ HelperText: FieldsetHelperText
146
+ });
64
147
  var Fieldset_default = Fieldset;
65
148
 
66
149
  // src/FieldsetTypes.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Fieldset.tsx","../../src/styles.ts","../../src/FieldsetTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { ChildContainer } from \"./styles\";\nimport type {\n TypeFieldsetProps,\n TypeFieldsetLegendProps,\n TypeFieldsetHelperText,\n} from \"./FieldsetTypes\";\n\n/**\n * Fieldset Component\n */\nconst Fieldset = ({\n layout = \"vertical\",\n label,\n helperText,\n children,\n ...rest\n}: TypeFieldsetProps) => (\n <Box as=\"fieldset\" border=\"none\" p={0} data-qa-fieldset=\"\" {...rest}>\n {typeof label === \"string\" ? (\n <Fieldset.Legend>{label}</Fieldset.Legend>\n ) : (\n label\n )}\n {typeof helperText === \"string\" ? (\n <Fieldset.HelperText>{helperText}</Fieldset.HelperText>\n ) : (\n helperText\n )}\n <Box\n display=\"flex\"\n flexDirection={layout === \"vertical\" ? \"column\" : \"row\"}\n >\n {React.Children.map(children, (child) => (\n <ChildContainer layout={layout}>{child}</ChildContainer>\n ))}\n </Box>\n </Box>\n);\n\nconst FieldsetLegend = ({ children, ...rest }: TypeFieldsetLegendProps) => (\n <Text\n as=\"legend\"\n fontSize={300}\n fontWeight=\"semibold\"\n color=\"text.body\"\n mb={300}\n {...rest}\n >\n {children}\n </Text>\n);\n\nconst FieldsetHelperText = ({ children, ...rest }: TypeFieldsetHelperText) => (\n <Text as=\"p\" fontSize={200} mb={300} {...rest}>\n {children}\n </Text>\n);\n\nFieldsetLegend.displayName = \"Fieldset.Legend\";\nFieldsetHelperText.displayName = \"Fieldset.HelperText\";\n\nFieldset.Legend = FieldsetLegend;\nFieldset.HelperText = FieldsetHelperText;\n\nexport default Fieldset;\n","import styled, { css } from \"styled-components\";\nimport type { TypeFieldsetChildContainerProps } from \"./FieldsetTypes\";\nimport Box from \"@sproutsocial/seeds-react-box\";\n\nexport const ChildContainer = styled(Box)<TypeFieldsetChildContainerProps>`\n ${(props) =>\n props.layout === \"vertical\" &&\n css`\n margin-top: ${props.theme.space[300]};\n\n &:first-child {\n margin-top: 0;\n }\n `}\n\n ${(props) =>\n props.layout === \"horizontal\" &&\n css`\n margin-left: ${props.theme.space[300]};\n\n &:first-child {\n margin-left: 0;\n }\n `}\n`;\n","import type { TypeTextProps } from \"@sproutsocial/seeds-react-text\";\nimport React from \"react\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport interface TypeFieldsetProps extends TypeBoxProps {\n /** Label text to display above the fieldset */\n label: React.ReactNode;\n helperText?: React.ReactNode;\n layout?: \"vertical\" | \"horizontal\";\n children: React.ReactNode;\n}\n\nexport interface TypeFieldsetChildContainerProps {\n layout: TypeFieldsetProps[\"layout\"];\n}\n\nexport interface TypeFieldsetLegendProps extends TypeTextProps {\n children: React.ReactNode;\n}\n\nexport interface TypeFieldsetHelperText extends TypeTextProps {\n children: React.ReactNode;\n}\n","import Fieldset from \"./Fieldset\";\n\nexport default Fieldset;\nexport { Fieldset };\nexport * from \"./FieldsetTypes\";\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,OAAOA,UAAS;AAChB,OAAO,UAAU;;;ACFjB,OAAO,UAAU,WAAW;AAE5B,OAAO,SAAS;AAET,IAAM,iBAAiB,OAAO,GAAG;AAAA,IACpC,CAAC,UACD,MAAM,WAAW,cACjB;AAAA,oBACgB,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,KAKrC;AAAA;AAAA,IAED,CAAC,UACD,MAAM,WAAW,gBACjB;AAAA,qBACiB,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,KAKtC;AAAA;;;ADHH,SAEI,KAFJ;AAPF,IAAM,WAAW,CAAC;AAAA,EAChB,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MACE,qBAACC,MAAA,EAAI,IAAG,YAAW,QAAO,QAAO,GAAG,GAAG,oBAAiB,IAAI,GAAG,MAC5D;AAAA,SAAO,UAAU,WAChB,oBAAC,SAAS,QAAT,EAAiB,iBAAM,IAExB;AAAA,EAED,OAAO,eAAe,WACrB,oBAAC,SAAS,YAAT,EAAqB,sBAAW,IAEjC;AAAA,EAEF;AAAA,IAACA;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,eAAe,WAAW,aAAa,WAAW;AAAA,MAEjD,UAAM,eAAS,IAAI,UAAU,CAAC,UAC7B,oBAAC,kBAAe,QAAiB,iBAAM,CACxC;AAAA;AAAA,EACH;AAAA,GACF;AAGF,IAAM,iBAAiB,CAAC,EAAE,UAAU,GAAG,KAAK,MAC1C;AAAA,EAAC;AAAA;AAAA,IACC,IAAG;AAAA,IACH,UAAU;AAAA,IACV,YAAW;AAAA,IACX,OAAM;AAAA,IACN,IAAI;AAAA,IACH,GAAG;AAAA,IAEH;AAAA;AACH;AAGF,IAAM,qBAAqB,CAAC,EAAE,UAAU,GAAG,KAAK,MAC9C,oBAAC,QAAK,IAAG,KAAI,UAAU,KAAK,IAAI,KAAM,GAAG,MACtC,UACH;AAGF,eAAe,cAAc;AAC7B,mBAAmB,cAAc;AAEjC,SAAS,SAAS;AAClB,SAAS,aAAa;AAEtB,IAAO,mBAAQ;;;AElEf,OAAkB;;;ACClB,IAAO,gBAAQ;","names":["Box","Box"]}
1
+ {"version":3,"sources":["../../src/FieldsetHybrid.tsx","../../src/styles.ts","../../src/FieldsetParts.tsx","../../src/FieldsetTailwind.tsx","../../src/Fieldset.tsx","../../src/FieldsetTypes.ts","../../src/index.ts"],"sourcesContent":["/**\n * Hybrid Fieldset Component\n * Automatically chooses between Tailwind and styled-components based on props\n */\n\nimport * as React from \"react\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport { ChildContainer } from \"./styles\"; // Styled-components version\nimport { FieldsetLegend, FieldsetHelperText } from \"./FieldsetParts\";\nimport { FieldsetTailwind } from \"./FieldsetTailwind\"; // Tailwind version\nimport type { TypeFieldsetProps } from \"./FieldsetTypes\";\n\nconst FieldsetHybrid = ({\n layout = \"vertical\",\n label,\n helperText,\n children,\n ...rest\n}: TypeFieldsetProps) => {\n if (hasStyledProps(rest)) {\n // Legacy styled-components tree — identical to the pre-migration Fieldset body\n return (\n <Box as=\"fieldset\" border=\"none\" p={0} data-qa-fieldset=\"\" {...rest}>\n {typeof label === \"string\" ? (\n <FieldsetLegend>{label}</FieldsetLegend>\n ) : (\n label\n )}\n {typeof helperText === \"string\" ? (\n <FieldsetHelperText>{helperText}</FieldsetHelperText>\n ) : (\n helperText\n )}\n <Box\n display=\"flex\"\n flexDirection={layout === \"vertical\" ? \"column\" : \"row\"}\n >\n {React.Children.map(children, (child) => (\n <ChildContainer layout={layout}>{child}</ChildContainer>\n ))}\n </Box>\n </Box>\n );\n }\n\n // Use Tailwind version (preferred - better performance)\n return (\n <FieldsetTailwind\n layout={layout}\n label={label}\n helperText={helperText}\n {...rest}\n >\n {children}\n </FieldsetTailwind>\n );\n};\n\nFieldsetHybrid.displayName = \"Fieldset\";\nexport default FieldsetHybrid;\n","import styled, { css } from \"styled-components\";\nimport type { TypeFieldsetChildContainerProps } from \"./FieldsetTypes\";\nimport Box from \"@sproutsocial/seeds-react-box\";\n\nexport const ChildContainer = styled(Box)<TypeFieldsetChildContainerProps>`\n ${(props) =>\n props.layout === \"vertical\" &&\n css`\n margin-top: ${props.theme.space[300]};\n\n &:first-child {\n margin-top: 0;\n }\n `}\n\n ${(props) =>\n props.layout === \"horizontal\" &&\n css`\n margin-left: ${props.theme.space[300]};\n\n &:first-child {\n margin-left: 0;\n }\n `}\n`;\n","import Text from \"@sproutsocial/seeds-react-text\";\nimport type {\n TypeFieldsetLegendProps,\n TypeFieldsetHelperText,\n} from \"./FieldsetTypes\";\n\n/**\n * Text-based legend and helper-text parts for Fieldset.\n *\n * These remain styled-components (Text) because they are exposed as the public\n * Fieldset.Legend / Fieldset.HelperText statics and accept arbitrary\n * styled-system props. They are shared by both the styled-components branch of\n * FieldsetHybrid and the compound statics attached in Fieldset.tsx.\n */\nexport const FieldsetLegend = ({\n children,\n ...rest\n}: TypeFieldsetLegendProps) => (\n <Text\n as=\"legend\"\n fontSize={300}\n fontWeight=\"semibold\"\n color=\"text.body\"\n mb={300}\n {...rest}\n >\n {children}\n </Text>\n);\n\nexport const FieldsetHelperText = ({\n children,\n ...rest\n}: TypeFieldsetHelperText) => (\n <Text as=\"p\" fontSize={200} mb={300} {...rest}>\n {children}\n </Text>\n);\n\nFieldsetLegend.displayName = \"Fieldset.Legend\";\nFieldsetHelperText.displayName = \"Fieldset.HelperText\";\n","/**\n * Tailwind CSS implementation of Fieldset component\n * Uses Seeds fieldset CSS classes from fieldset.css\n */\n\nimport * as React from \"react\";\nimport type { TypeFieldsetProps } from \"./FieldsetTypes\";\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 FieldsetTailwind = ({\n layout = \"vertical\",\n label,\n helperText,\n children,\n className,\n ...rest\n}: TypeFieldsetProps) => {\n // Use a loosely-typed root so DOM attributes in `...rest` (e.g. aria-live) are\n // forwarded without TypeScript flagging styled-system props carried by\n // TypeBoxProps (e.g. `color`) that conflict with the intrinsic <fieldset> attrs.\n // Mirrors ButtonTailwind, which spreads `...rest` onto an `as any` element.\n const Root = \"fieldset\" as any;\n\n return (\n <Root\n className={cn(\"seeds-fieldset\", className)}\n data-qa-fieldset=\"\"\n {...rest}\n >\n {typeof label === \"string\" ? (\n <legend className=\"seeds-fieldset-legend\">{label}</legend>\n ) : (\n label\n )}\n {typeof helperText === \"string\" ? (\n <p className=\"seeds-fieldset-helper-text\">{helperText}</p>\n ) : (\n helperText\n )}\n <div className={cn(\"seeds-fieldset-list\", `seeds-fieldset-list-${layout}`)}>\n {React.Children.map(children, (child) => (\n <div\n className={cn(\n \"seeds-fieldset-item\",\n `seeds-fieldset-item-${layout}`\n )}\n >\n {child}\n </div>\n ))}\n </div>\n </Root>\n );\n};\n\nFieldsetTailwind.displayName = \"FieldsetTailwind\";\n","import FieldsetHybrid from \"./FieldsetHybrid\";\nimport { FieldsetLegend, FieldsetHelperText } from \"./FieldsetParts\";\n\n/**\n * Fieldset Component\n *\n * Thin assembly over the hybrid implementation: FieldsetHybrid routes to the\n * styled-components path when styled-system props are passed and to the Tailwind\n * path otherwise. The public Fieldset.Legend / Fieldset.HelperText statics remain\n * Text-based (see FieldsetParts) so they keep accepting styled-system props.\n */\nconst Fieldset = Object.assign(FieldsetHybrid, {\n Legend: FieldsetLegend,\n HelperText: FieldsetHelperText,\n});\n\nexport default Fieldset;\n","import type { TypeTextProps } from \"@sproutsocial/seeds-react-text\";\nimport React from \"react\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport interface TypeFieldsetProps extends TypeBoxProps {\n /** Label text to display above the fieldset */\n label: React.ReactNode;\n helperText?: React.ReactNode;\n layout?: \"vertical\" | \"horizontal\";\n children: React.ReactNode;\n}\n\nexport interface TypeFieldsetChildContainerProps {\n layout: TypeFieldsetProps[\"layout\"];\n}\n\nexport interface TypeFieldsetLegendProps extends TypeTextProps {\n children: React.ReactNode;\n}\n\nexport interface TypeFieldsetHelperText extends TypeTextProps {\n children: React.ReactNode;\n}\n","import Fieldset from \"./Fieldset\";\n\nexport default Fieldset;\nexport { Fieldset };\nexport * from \"./FieldsetTypes\";\n"],"mappings":"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","names":["React","Box","jsx","jsx","jsxs","Box"]}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Seeds Fieldset 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
+ * <fieldset class="seeds-fieldset">
10
+ * <legend class="seeds-fieldset-legend">Label</legend>
11
+ * <p class="seeds-fieldset-helper-text">Helper text</p>
12
+ * <div class="seeds-fieldset-list seeds-fieldset-list-vertical">
13
+ * <div class="seeds-fieldset-item seeds-fieldset-item-vertical">...</div>
14
+ * </div>
15
+ * </fieldset>
16
+ */
17
+
18
+ @layer components {
19
+ .seeds-fieldset {
20
+ box-sizing: border-box;
21
+ font-family: var(--font-family);
22
+ border: none;
23
+ padding: 0;
24
+ }
25
+
26
+ .seeds-fieldset-legend {
27
+ margin: 0;
28
+ font-family: var(--font-family);
29
+ font-size: var(--font-size-300);
30
+ line-height: var(--line-height-300);
31
+ font-weight: var(--font-weight-semibold);
32
+ color: var(--color-text-body);
33
+ margin-bottom: var(--space-300);
34
+ }
35
+
36
+ .seeds-fieldset-helper-text {
37
+ margin: 0;
38
+ font-family: var(--font-family);
39
+ font-size: var(--font-size-200);
40
+ line-height: var(--line-height-200);
41
+ margin-bottom: var(--space-300);
42
+ }
43
+
44
+ .seeds-fieldset-list {
45
+ box-sizing: border-box;
46
+ font-family: var(--font-family);
47
+ display: flex;
48
+ }
49
+
50
+ .seeds-fieldset-list-vertical {
51
+ flex-direction: column;
52
+ }
53
+
54
+ .seeds-fieldset-list-horizontal {
55
+ flex-direction: row;
56
+ }
57
+
58
+ .seeds-fieldset-item {
59
+ box-sizing: border-box;
60
+ font-family: var(--font-family);
61
+ }
62
+
63
+ .seeds-fieldset-item-vertical {
64
+ margin-top: var(--space-300);
65
+ }
66
+
67
+ .seeds-fieldset-item-vertical:first-child {
68
+ margin-top: 0;
69
+ }
70
+
71
+ .seeds-fieldset-item-horizontal {
72
+ margin-left: var(--space-300);
73
+ }
74
+
75
+ .seeds-fieldset-item-horizontal:first-child {
76
+ margin-left: 0;
77
+ }
78
+ }
package/dist/index.d.mts CHANGED
@@ -22,9 +22,16 @@ interface TypeFieldsetHelperText extends TypeTextProps {
22
22
 
23
23
  /**
24
24
  * Fieldset Component
25
+ *
26
+ * Thin assembly over the hybrid implementation: FieldsetHybrid routes to the
27
+ * styled-components path when styled-system props are passed and to the Tailwind
28
+ * path otherwise. The public Fieldset.Legend / Fieldset.HelperText statics remain
29
+ * Text-based (see FieldsetParts) so they keep accepting styled-system props.
25
30
  */
26
31
  declare const Fieldset: {
27
32
  ({ layout, label, helperText, children, ...rest }: TypeFieldsetProps): react_jsx_runtime.JSX.Element;
33
+ displayName: string;
34
+ } & {
28
35
  Legend: {
29
36
  ({ children, ...rest }: TypeFieldsetLegendProps): react_jsx_runtime.JSX.Element;
30
37
  displayName: string;
package/dist/index.d.ts CHANGED
@@ -22,9 +22,16 @@ interface TypeFieldsetHelperText extends TypeTextProps {
22
22
 
23
23
  /**
24
24
  * Fieldset Component
25
+ *
26
+ * Thin assembly over the hybrid implementation: FieldsetHybrid routes to the
27
+ * styled-components path when styled-system props are passed and to the Tailwind
28
+ * path otherwise. The public Fieldset.Legend / Fieldset.HelperText statics remain
29
+ * Text-based (see FieldsetParts) so they keep accepting styled-system props.
25
30
  */
26
31
  declare const Fieldset: {
27
32
  ({ layout, label, helperText, children, ...rest }: TypeFieldsetProps): react_jsx_runtime.JSX.Element;
33
+ displayName: string;
34
+ } & {
28
35
  Legend: {
29
36
  ({ children, ...rest }: TypeFieldsetLegendProps): react_jsx_runtime.JSX.Element;
30
37
  displayName: string;
package/dist/index.js CHANGED
@@ -35,10 +35,10 @@ __export(index_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(index_exports);
37
37
 
38
- // src/Fieldset.tsx
39
- var React = __toESM(require("react"));
38
+ // src/FieldsetHybrid.tsx
39
+ var React2 = __toESM(require("react"));
40
40
  var import_seeds_react_box2 = __toESM(require("@sproutsocial/seeds-react-box"));
41
- var import_seeds_react_text = __toESM(require("@sproutsocial/seeds-react-text"));
41
+ var import_seeds_react_system_props = require("@sproutsocial/seeds-react-system-props");
42
42
 
43
43
  // src/styles.ts
44
44
  var import_styled_components = __toESM(require("styled-components"));
@@ -61,27 +61,13 @@ var ChildContainer = (0, import_styled_components.default)(import_seeds_react_bo
61
61
  `}
62
62
  `;
63
63
 
64
- // src/Fieldset.tsx
64
+ // src/FieldsetParts.tsx
65
+ var import_seeds_react_text = __toESM(require("@sproutsocial/seeds-react-text"));
65
66
  var import_jsx_runtime = require("react/jsx-runtime");
66
- var Fieldset = ({
67
- layout = "vertical",
68
- label,
69
- helperText,
67
+ var FieldsetLegend = ({
70
68
  children,
71
69
  ...rest
72
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_seeds_react_box2.default, { as: "fieldset", border: "none", p: 0, "data-qa-fieldset": "", ...rest, children: [
73
- typeof label === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fieldset.Legend, { children: label }) : label,
74
- typeof helperText === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fieldset.HelperText, { children: helperText }) : helperText,
75
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
- import_seeds_react_box2.default,
77
- {
78
- display: "flex",
79
- flexDirection: layout === "vertical" ? "column" : "row",
80
- children: React.Children.map(children, (child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChildContainer, { layout, children: child }))
81
- }
82
- )
83
- ] });
84
- var FieldsetLegend = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
71
  import_seeds_react_text.default,
86
72
  {
87
73
  as: "legend",
@@ -93,11 +79,108 @@ var FieldsetLegend = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_r
93
79
  children
94
80
  }
95
81
  );
96
- var FieldsetHelperText = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.default, { as: "p", fontSize: 200, mb: 300, ...rest, children });
82
+ var FieldsetHelperText = ({
83
+ children,
84
+ ...rest
85
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.default, { as: "p", fontSize: 200, mb: 300, ...rest, children });
97
86
  FieldsetLegend.displayName = "Fieldset.Legend";
98
87
  FieldsetHelperText.displayName = "Fieldset.HelperText";
99
- Fieldset.Legend = FieldsetLegend;
100
- Fieldset.HelperText = FieldsetHelperText;
88
+
89
+ // src/FieldsetTailwind.tsx
90
+ var React = __toESM(require("react"));
91
+ var import_jsx_runtime2 = require("react/jsx-runtime");
92
+ function cn(...inputs) {
93
+ const classes = [];
94
+ for (const input of inputs) {
95
+ if (!input) continue;
96
+ if (typeof input === "string") {
97
+ classes.push(input);
98
+ } else if (typeof input === "object") {
99
+ for (const [key, value] of Object.entries(input)) {
100
+ if (value) {
101
+ classes.push(key);
102
+ }
103
+ }
104
+ }
105
+ }
106
+ return classes.join(" ");
107
+ }
108
+ var FieldsetTailwind = ({
109
+ layout = "vertical",
110
+ label,
111
+ helperText,
112
+ children,
113
+ className,
114
+ ...rest
115
+ }) => {
116
+ const Root = "fieldset";
117
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
118
+ Root,
119
+ {
120
+ className: cn("seeds-fieldset", className),
121
+ "data-qa-fieldset": "",
122
+ ...rest,
123
+ children: [
124
+ typeof label === "string" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", { className: "seeds-fieldset-legend", children: label }) : label,
125
+ typeof helperText === "string" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "seeds-fieldset-helper-text", children: helperText }) : helperText,
126
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: cn("seeds-fieldset-list", `seeds-fieldset-list-${layout}`), children: React.Children.map(children, (child) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
127
+ "div",
128
+ {
129
+ className: cn(
130
+ "seeds-fieldset-item",
131
+ `seeds-fieldset-item-${layout}`
132
+ ),
133
+ children: child
134
+ }
135
+ )) })
136
+ ]
137
+ }
138
+ );
139
+ };
140
+ FieldsetTailwind.displayName = "FieldsetTailwind";
141
+
142
+ // src/FieldsetHybrid.tsx
143
+ var import_jsx_runtime3 = require("react/jsx-runtime");
144
+ var FieldsetHybrid = ({
145
+ layout = "vertical",
146
+ label,
147
+ helperText,
148
+ children,
149
+ ...rest
150
+ }) => {
151
+ if ((0, import_seeds_react_system_props.hasStyledProps)(rest)) {
152
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_seeds_react_box2.default, { as: "fieldset", border: "none", p: 0, "data-qa-fieldset": "", ...rest, children: [
153
+ typeof label === "string" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FieldsetLegend, { children: label }) : label,
154
+ typeof helperText === "string" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FieldsetHelperText, { children: helperText }) : helperText,
155
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
156
+ import_seeds_react_box2.default,
157
+ {
158
+ display: "flex",
159
+ flexDirection: layout === "vertical" ? "column" : "row",
160
+ children: React2.Children.map(children, (child) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChildContainer, { layout, children: child }))
161
+ }
162
+ )
163
+ ] });
164
+ }
165
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
166
+ FieldsetTailwind,
167
+ {
168
+ layout,
169
+ label,
170
+ helperText,
171
+ ...rest,
172
+ children
173
+ }
174
+ );
175
+ };
176
+ FieldsetHybrid.displayName = "Fieldset";
177
+ var FieldsetHybrid_default = FieldsetHybrid;
178
+
179
+ // src/Fieldset.tsx
180
+ var Fieldset = Object.assign(FieldsetHybrid_default, {
181
+ Legend: FieldsetLegend,
182
+ HelperText: FieldsetHelperText
183
+ });
101
184
  var Fieldset_default = Fieldset;
102
185
 
103
186
  // src/FieldsetTypes.ts
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/Fieldset.tsx","../src/styles.ts","../src/FieldsetTypes.ts"],"sourcesContent":["import Fieldset from \"./Fieldset\";\n\nexport default Fieldset;\nexport { Fieldset };\nexport * from \"./FieldsetTypes\";\n","import * as React from \"react\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { ChildContainer } from \"./styles\";\nimport type {\n TypeFieldsetProps,\n TypeFieldsetLegendProps,\n TypeFieldsetHelperText,\n} from \"./FieldsetTypes\";\n\n/**\n * Fieldset Component\n */\nconst Fieldset = ({\n layout = \"vertical\",\n label,\n helperText,\n children,\n ...rest\n}: TypeFieldsetProps) => (\n <Box as=\"fieldset\" border=\"none\" p={0} data-qa-fieldset=\"\" {...rest}>\n {typeof label === \"string\" ? (\n <Fieldset.Legend>{label}</Fieldset.Legend>\n ) : (\n label\n )}\n {typeof helperText === \"string\" ? (\n <Fieldset.HelperText>{helperText}</Fieldset.HelperText>\n ) : (\n helperText\n )}\n <Box\n display=\"flex\"\n flexDirection={layout === \"vertical\" ? \"column\" : \"row\"}\n >\n {React.Children.map(children, (child) => (\n <ChildContainer layout={layout}>{child}</ChildContainer>\n ))}\n </Box>\n </Box>\n);\n\nconst FieldsetLegend = ({ children, ...rest }: TypeFieldsetLegendProps) => (\n <Text\n as=\"legend\"\n fontSize={300}\n fontWeight=\"semibold\"\n color=\"text.body\"\n mb={300}\n {...rest}\n >\n {children}\n </Text>\n);\n\nconst FieldsetHelperText = ({ children, ...rest }: TypeFieldsetHelperText) => (\n <Text as=\"p\" fontSize={200} mb={300} {...rest}>\n {children}\n </Text>\n);\n\nFieldsetLegend.displayName = \"Fieldset.Legend\";\nFieldsetHelperText.displayName = \"Fieldset.HelperText\";\n\nFieldset.Legend = FieldsetLegend;\nFieldset.HelperText = FieldsetHelperText;\n\nexport default Fieldset;\n","import styled, { css } from \"styled-components\";\nimport type { TypeFieldsetChildContainerProps } from \"./FieldsetTypes\";\nimport Box from \"@sproutsocial/seeds-react-box\";\n\nexport const ChildContainer = styled(Box)<TypeFieldsetChildContainerProps>`\n ${(props) =>\n props.layout === \"vertical\" &&\n css`\n margin-top: ${props.theme.space[300]};\n\n &:first-child {\n margin-top: 0;\n }\n `}\n\n ${(props) =>\n props.layout === \"horizontal\" &&\n css`\n margin-left: ${props.theme.space[300]};\n\n &:first-child {\n margin-left: 0;\n }\n `}\n`;\n","import type { TypeTextProps } from \"@sproutsocial/seeds-react-text\";\nimport React from \"react\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport interface TypeFieldsetProps extends TypeBoxProps {\n /** Label text to display above the fieldset */\n label: React.ReactNode;\n helperText?: React.ReactNode;\n layout?: \"vertical\" | \"horizontal\";\n children: React.ReactNode;\n}\n\nexport interface TypeFieldsetChildContainerProps {\n layout: TypeFieldsetProps[\"layout\"];\n}\n\nexport interface TypeFieldsetLegendProps extends TypeTextProps {\n children: React.ReactNode;\n}\n\nexport interface TypeFieldsetHelperText extends TypeTextProps {\n children: React.ReactNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,IAAAA,0BAAgB;AAChB,8BAAiB;;;ACFjB,+BAA4B;AAE5B,6BAAgB;AAET,IAAM,qBAAiB,yBAAAC,SAAO,uBAAAC,OAAG;AAAA,IACpC,CAAC,UACD,MAAM,WAAW,cACjB;AAAA,oBACgB,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,KAKrC;AAAA;AAAA,IAED,CAAC,UACD,MAAM,WAAW,gBACjB;AAAA,qBACiB,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,KAKtC;AAAA;;;ADHH;AAPF,IAAM,WAAW,CAAC;AAAA,EAChB,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MACE,6CAAC,wBAAAC,SAAA,EAAI,IAAG,YAAW,QAAO,QAAO,GAAG,GAAG,oBAAiB,IAAI,GAAG,MAC5D;AAAA,SAAO,UAAU,WAChB,4CAAC,SAAS,QAAT,EAAiB,iBAAM,IAExB;AAAA,EAED,OAAO,eAAe,WACrB,4CAAC,SAAS,YAAT,EAAqB,sBAAW,IAEjC;AAAA,EAEF;AAAA,IAAC,wBAAAA;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,eAAe,WAAW,aAAa,WAAW;AAAA,MAEjD,UAAM,eAAS,IAAI,UAAU,CAAC,UAC7B,4CAAC,kBAAe,QAAiB,iBAAM,CACxC;AAAA;AAAA,EACH;AAAA,GACF;AAGF,IAAM,iBAAiB,CAAC,EAAE,UAAU,GAAG,KAAK,MAC1C;AAAA,EAAC,wBAAAC;AAAA,EAAA;AAAA,IACC,IAAG;AAAA,IACH,UAAU;AAAA,IACV,YAAW;AAAA,IACX,OAAM;AAAA,IACN,IAAI;AAAA,IACH,GAAG;AAAA,IAEH;AAAA;AACH;AAGF,IAAM,qBAAqB,CAAC,EAAE,UAAU,GAAG,KAAK,MAC9C,4CAAC,wBAAAA,SAAA,EAAK,IAAG,KAAI,UAAU,KAAK,IAAI,KAAM,GAAG,MACtC,UACH;AAGF,eAAe,cAAc;AAC7B,mBAAmB,cAAc;AAEjC,SAAS,SAAS;AAClB,SAAS,aAAa;AAEtB,IAAO,mBAAQ;;;AElEf,mBAAkB;;;AHClB,IAAO,gBAAQ;","names":["import_seeds_react_box","styled","Box","Box","Text"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/FieldsetHybrid.tsx","../src/styles.ts","../src/FieldsetParts.tsx","../src/FieldsetTailwind.tsx","../src/Fieldset.tsx","../src/FieldsetTypes.ts"],"sourcesContent":["import Fieldset from \"./Fieldset\";\n\nexport default Fieldset;\nexport { Fieldset };\nexport * from \"./FieldsetTypes\";\n","/**\n * Hybrid Fieldset Component\n * Automatically chooses between Tailwind and styled-components based on props\n */\n\nimport * as React from \"react\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport { ChildContainer } from \"./styles\"; // Styled-components version\nimport { FieldsetLegend, FieldsetHelperText } from \"./FieldsetParts\";\nimport { FieldsetTailwind } from \"./FieldsetTailwind\"; // Tailwind version\nimport type { TypeFieldsetProps } from \"./FieldsetTypes\";\n\nconst FieldsetHybrid = ({\n layout = \"vertical\",\n label,\n helperText,\n children,\n ...rest\n}: TypeFieldsetProps) => {\n if (hasStyledProps(rest)) {\n // Legacy styled-components tree — identical to the pre-migration Fieldset body\n return (\n <Box as=\"fieldset\" border=\"none\" p={0} data-qa-fieldset=\"\" {...rest}>\n {typeof label === \"string\" ? (\n <FieldsetLegend>{label}</FieldsetLegend>\n ) : (\n label\n )}\n {typeof helperText === \"string\" ? (\n <FieldsetHelperText>{helperText}</FieldsetHelperText>\n ) : (\n helperText\n )}\n <Box\n display=\"flex\"\n flexDirection={layout === \"vertical\" ? \"column\" : \"row\"}\n >\n {React.Children.map(children, (child) => (\n <ChildContainer layout={layout}>{child}</ChildContainer>\n ))}\n </Box>\n </Box>\n );\n }\n\n // Use Tailwind version (preferred - better performance)\n return (\n <FieldsetTailwind\n layout={layout}\n label={label}\n helperText={helperText}\n {...rest}\n >\n {children}\n </FieldsetTailwind>\n );\n};\n\nFieldsetHybrid.displayName = \"Fieldset\";\nexport default FieldsetHybrid;\n","import styled, { css } from \"styled-components\";\nimport type { TypeFieldsetChildContainerProps } from \"./FieldsetTypes\";\nimport Box from \"@sproutsocial/seeds-react-box\";\n\nexport const ChildContainer = styled(Box)<TypeFieldsetChildContainerProps>`\n ${(props) =>\n props.layout === \"vertical\" &&\n css`\n margin-top: ${props.theme.space[300]};\n\n &:first-child {\n margin-top: 0;\n }\n `}\n\n ${(props) =>\n props.layout === \"horizontal\" &&\n css`\n margin-left: ${props.theme.space[300]};\n\n &:first-child {\n margin-left: 0;\n }\n `}\n`;\n","import Text from \"@sproutsocial/seeds-react-text\";\nimport type {\n TypeFieldsetLegendProps,\n TypeFieldsetHelperText,\n} from \"./FieldsetTypes\";\n\n/**\n * Text-based legend and helper-text parts for Fieldset.\n *\n * These remain styled-components (Text) because they are exposed as the public\n * Fieldset.Legend / Fieldset.HelperText statics and accept arbitrary\n * styled-system props. They are shared by both the styled-components branch of\n * FieldsetHybrid and the compound statics attached in Fieldset.tsx.\n */\nexport const FieldsetLegend = ({\n children,\n ...rest\n}: TypeFieldsetLegendProps) => (\n <Text\n as=\"legend\"\n fontSize={300}\n fontWeight=\"semibold\"\n color=\"text.body\"\n mb={300}\n {...rest}\n >\n {children}\n </Text>\n);\n\nexport const FieldsetHelperText = ({\n children,\n ...rest\n}: TypeFieldsetHelperText) => (\n <Text as=\"p\" fontSize={200} mb={300} {...rest}>\n {children}\n </Text>\n);\n\nFieldsetLegend.displayName = \"Fieldset.Legend\";\nFieldsetHelperText.displayName = \"Fieldset.HelperText\";\n","/**\n * Tailwind CSS implementation of Fieldset component\n * Uses Seeds fieldset CSS classes from fieldset.css\n */\n\nimport * as React from \"react\";\nimport type { TypeFieldsetProps } from \"./FieldsetTypes\";\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 FieldsetTailwind = ({\n layout = \"vertical\",\n label,\n helperText,\n children,\n className,\n ...rest\n}: TypeFieldsetProps) => {\n // Use a loosely-typed root so DOM attributes in `...rest` (e.g. aria-live) are\n // forwarded without TypeScript flagging styled-system props carried by\n // TypeBoxProps (e.g. `color`) that conflict with the intrinsic <fieldset> attrs.\n // Mirrors ButtonTailwind, which spreads `...rest` onto an `as any` element.\n const Root = \"fieldset\" as any;\n\n return (\n <Root\n className={cn(\"seeds-fieldset\", className)}\n data-qa-fieldset=\"\"\n {...rest}\n >\n {typeof label === \"string\" ? (\n <legend className=\"seeds-fieldset-legend\">{label}</legend>\n ) : (\n label\n )}\n {typeof helperText === \"string\" ? (\n <p className=\"seeds-fieldset-helper-text\">{helperText}</p>\n ) : (\n helperText\n )}\n <div className={cn(\"seeds-fieldset-list\", `seeds-fieldset-list-${layout}`)}>\n {React.Children.map(children, (child) => (\n <div\n className={cn(\n \"seeds-fieldset-item\",\n `seeds-fieldset-item-${layout}`\n )}\n >\n {child}\n </div>\n ))}\n </div>\n </Root>\n );\n};\n\nFieldsetTailwind.displayName = \"FieldsetTailwind\";\n","import FieldsetHybrid from \"./FieldsetHybrid\";\nimport { FieldsetLegend, FieldsetHelperText } from \"./FieldsetParts\";\n\n/**\n * Fieldset Component\n *\n * Thin assembly over the hybrid implementation: FieldsetHybrid routes to the\n * styled-components path when styled-system props are passed and to the Tailwind\n * path otherwise. The public Fieldset.Legend / Fieldset.HelperText statics remain\n * Text-based (see FieldsetParts) so they keep accepting styled-system props.\n */\nconst Fieldset = Object.assign(FieldsetHybrid, {\n Legend: FieldsetLegend,\n HelperText: FieldsetHelperText,\n});\n\nexport default Fieldset;\n","import type { TypeTextProps } from \"@sproutsocial/seeds-react-text\";\nimport React from \"react\";\nimport type { TypeBoxProps } from \"@sproutsocial/seeds-react-box\";\n\nexport interface TypeFieldsetProps extends TypeBoxProps {\n /** Label text to display above the fieldset */\n label: React.ReactNode;\n helperText?: React.ReactNode;\n layout?: \"vertical\" | \"horizontal\";\n children: React.ReactNode;\n}\n\nexport interface TypeFieldsetChildContainerProps {\n layout: TypeFieldsetProps[\"layout\"];\n}\n\nexport interface TypeFieldsetLegendProps extends TypeTextProps {\n children: React.ReactNode;\n}\n\nexport interface TypeFieldsetHelperText extends TypeTextProps {\n children: React.ReactNode;\n}\n"],"mappings":"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","names":["React","import_seeds_react_box","styled","Box","Text","import_jsx_runtime","import_jsx_runtime","Box"]}
package/package.json CHANGED
@@ -1,15 +1,26 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-fieldset",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "Seeds React Fieldset",
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
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/esm/index.js",
16
+ "require": "./dist/index.js",
17
+ "types": "./dist/index.d.ts"
18
+ },
19
+ "./dist/fieldset.css": "./dist/fieldset.css"
20
+ },
10
21
  "scripts": {
11
- "build": "tsup --dts",
12
- "build:debug": "tsup --dts --metafile",
22
+ "build": "tsup --dts && cp src/fieldset.css dist/fieldset.css",
23
+ "build:debug": "tsup --dts --metafile && cp src/fieldset.css dist/fieldset.css",
13
24
  "dev": "tsup --watch --dts",
14
25
  "clean": "rm -rf .turbo dist",
15
26
  "clean:modules": "rm -rf node_modules",
@@ -34,7 +45,7 @@
34
45
  "@sproutsocial/seeds-tsconfig": "*",
35
46
  "@sproutsocial/seeds-testing": "*",
36
47
  "@sproutsocial/seeds-react-testing-library": "*",
37
- "@sproutsocial/seeds-react-radio": "^1.3.26"
48
+ "@sproutsocial/seeds-react-radio": "^1.3.27"
38
49
  },
39
50
  "peerDependencies": {
40
51
  "styled-components": "^5.2.3"
package/.eslintignore DELETED
@@ -1,6 +0,0 @@
1
- # Node modules
2
- node_modules/
3
-
4
- # Build output
5
- dist/
6
- coverage/
package/.eslintrc.js DELETED
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: ["eslint-config-seeds/racine"],
4
- };
@@ -1,21 +0,0 @@
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.5.0
6
- CLI Using tsup config: /home/runner/_work/seeds/seeds/seeds-react/seeds-react-fieldset/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 4.18 KB
12
- CJS dist/index.js.map 4.56 KB
13
- CJS ⚡️ Build success in 18ms
14
- ESM dist/esm/index.js 2.09 KB
15
- ESM dist/esm/index.js.map 4.45 KB
16
- ESM ⚡️ Build success in 18ms
17
- DTS Build start
18
- DTS ⚡️ Build success in 1769ms
19
- DTS dist/index.d.ts 1.30 KB
20
- DTS dist/index.d.mts 1.30 KB
21
- Done in 2.54s.
package/CHANGELOG.md DELETED
@@ -1,221 +0,0 @@
1
- # @sproutsocial/seeds-react-fieldset
2
-
3
- ## 1.0.26
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [6611f6a]
8
- - @sproutsocial/seeds-react-system-props@3.1.2
9
- - @sproutsocial/seeds-react-box@1.1.24
10
- - @sproutsocial/seeds-react-text@1.5.1
11
-
12
- ## 1.0.25
13
-
14
- ### Patch Changes
15
-
16
- - Updated dependencies [85f9728]
17
- - Updated dependencies [fa7d859]
18
- - @sproutsocial/seeds-react-theme@4.2.0
19
- - @sproutsocial/seeds-react-box@1.1.23
20
-
21
- ## 1.0.24
22
-
23
- ### Patch Changes
24
-
25
- - Updated dependencies [65b5879]
26
- - @sproutsocial/seeds-react-text@1.5.0
27
-
28
- ## 1.0.23
29
-
30
- ### Patch Changes
31
-
32
- - Updated dependencies [a13a571]
33
- - @sproutsocial/seeds-react-theme@4.1.1
34
- - @sproutsocial/seeds-react-box@1.1.22
35
-
36
- ## 1.0.22
37
-
38
- ### Patch Changes
39
-
40
- - Updated dependencies [edc1819]
41
- - @sproutsocial/seeds-react-text@1.4.3
42
-
43
- ## 1.0.21
44
-
45
- ### Patch Changes
46
-
47
- - Updated dependencies [5892f44]
48
- - @sproutsocial/seeds-react-system-props@3.1.1
49
- - @sproutsocial/seeds-react-box@1.1.21
50
- - @sproutsocial/seeds-react-text@1.4.2
51
-
52
- ## 1.0.20
53
-
54
- ### Patch Changes
55
-
56
- - Updated dependencies [5114a32]
57
- - @sproutsocial/seeds-react-theme@4.1.0
58
- - @sproutsocial/seeds-react-box@1.1.20
59
-
60
- ## 1.0.19
61
-
62
- ### Patch Changes
63
-
64
- - Updated dependencies [132ef9d]
65
- - Updated dependencies [132ef9d]
66
- - @sproutsocial/seeds-react-theme@4.0.0
67
- - @sproutsocial/seeds-react-system-props@3.1.0
68
- - @sproutsocial/seeds-react-box@1.1.19
69
- - @sproutsocial/seeds-react-text@1.4.1
70
-
71
- ## 1.0.18
72
-
73
- ### Patch Changes
74
-
75
- - Updated dependencies [47c62b3]
76
- - @sproutsocial/seeds-react-theme@3.7.1
77
- - @sproutsocial/seeds-react-box@1.1.18
78
-
79
- ## 1.0.17
80
-
81
- ### Patch Changes
82
-
83
- - Updated dependencies [06da9c2]
84
- - @sproutsocial/seeds-react-theme@3.7.0
85
- - @sproutsocial/seeds-react-box@1.1.17
86
-
87
- ## 1.0.16
88
-
89
- ### Patch Changes
90
-
91
- - Updated dependencies [4ba8720]
92
- - @sproutsocial/seeds-react-theme@3.6.2
93
- - @sproutsocial/seeds-react-box@1.1.16
94
-
95
- ## 1.0.15
96
-
97
- ### Patch Changes
98
-
99
- - Updated dependencies [1f9a473]
100
- - @sproutsocial/seeds-react-theme@3.6.1
101
- - @sproutsocial/seeds-react-box@1.1.15
102
-
103
- ## 1.0.14
104
-
105
- ### Patch Changes
106
-
107
- - Updated dependencies [17d4f12]
108
- - @sproutsocial/seeds-react-theme@3.6.0
109
- - @sproutsocial/seeds-react-box@1.1.14
110
-
111
- ## 1.0.13
112
-
113
- ### Patch Changes
114
-
115
- - Updated dependencies [118e300]
116
- - @sproutsocial/seeds-react-theme@3.5.1
117
- - @sproutsocial/seeds-react-box@1.1.13
118
-
119
- ## 1.0.12
120
-
121
- ### Patch Changes
122
-
123
- - Updated dependencies [db6ce39]
124
- - Updated dependencies [20bb01b]
125
- - @sproutsocial/seeds-react-theme@3.5.0
126
- - @sproutsocial/seeds-react-box@1.1.12
127
-
128
- ## 1.0.11
129
-
130
- ### Patch Changes
131
-
132
- - Updated dependencies [29ced53]
133
- - @sproutsocial/seeds-react-text@1.4.0
134
-
135
- ## 1.0.10
136
-
137
- ### Patch Changes
138
-
139
- - Updated dependencies [7716e16]
140
- - @sproutsocial/seeds-react-theme@3.4.0
141
- - @sproutsocial/seeds-react-box@1.1.11
142
-
143
- ## 1.0.9
144
-
145
- ### Patch Changes
146
-
147
- - @sproutsocial/seeds-react-theme@3.3.2
148
- - @sproutsocial/seeds-react-box@1.1.10
149
-
150
- ## 1.0.8
151
-
152
- ### Patch Changes
153
-
154
- - @sproutsocial/seeds-react-theme@3.3.1
155
- - @sproutsocial/seeds-react-box@1.1.9
156
-
157
- ## 1.0.7
158
-
159
- ### Patch Changes
160
-
161
- - Updated dependencies [750d1ea]
162
- - @sproutsocial/seeds-react-theme@3.3.0
163
- - @sproutsocial/seeds-react-box@1.1.8
164
-
165
- ## 1.0.6
166
-
167
- ### Patch Changes
168
-
169
- - Updated dependencies [fa7579a]
170
- - @sproutsocial/seeds-react-theme@3.2.1
171
- - @sproutsocial/seeds-react-box@1.1.7
172
-
173
- ## 1.0.5
174
-
175
- ### Patch Changes
176
-
177
- - Updated dependencies [8f6ba8d]
178
- - @sproutsocial/seeds-react-theme@3.2.0
179
- - @sproutsocial/seeds-react-box@1.1.6
180
-
181
- ## 1.0.4
182
-
183
- ### Patch Changes
184
-
185
- - Updated dependencies [b1c3b44]
186
- - @sproutsocial/seeds-react-theme@3.1.1
187
- - @sproutsocial/seeds-react-box@1.1.5
188
-
189
- ## 1.0.3
190
-
191
- ### Patch Changes
192
-
193
- - Updated dependencies [47580c4]
194
- - @sproutsocial/seeds-react-theme@3.1.0
195
- - @sproutsocial/seeds-react-box@1.1.4
196
-
197
- ## 1.0.2
198
-
199
- ### Patch Changes
200
-
201
- - Updated dependencies [22e1111]
202
- - @sproutsocial/seeds-react-text@1.3.2
203
- - @sproutsocial/seeds-react-theme@3.0.1
204
- - @sproutsocial/seeds-react-box@1.1.3
205
-
206
- ## 1.0.1
207
-
208
- ### Patch Changes
209
-
210
- - 9fd8bac: Update dependencies to use semantic package version instead of wildcards
211
- - Updated dependencies [9fd8bac]
212
- - @sproutsocial/seeds-react-system-props@3.0.2
213
- - @sproutsocial/seeds-react-theme@2.2.1
214
- - @sproutsocial/seeds-react-text@1.3.1
215
- - @sproutsocial/seeds-react-box@1.1.2
216
-
217
- ## 1.0.0
218
-
219
- ### Major Changes
220
-
221
- - 8ca97dd: Migrated FormField, Fieldset, and Label to their own seeds-react component
package/jest.config.js DELETED
@@ -1,9 +0,0 @@
1
- const baseConfig = require("@sproutsocial/seeds-testing");
2
-
3
- /** * @type {import('jest').Config} */
4
- const config = {
5
- ...baseConfig,
6
- displayName: "seeds-react-fieldset",
7
- };
8
-
9
- module.exports = config;
@@ -1,222 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Box } from "@sproutsocial/seeds-react-box";
3
- import { Button } from "@sproutsocial/seeds-react-button";
4
- import { FormField } from "@sproutsocial/seeds-react-form-field";
5
- import { Input } from "@sproutsocial/seeds-react-input";
6
- import { Radio } from "@sproutsocial/seeds-react-radio";
7
- import { Text } from "@sproutsocial/seeds-react-text";
8
- import Fieldset from "./Fieldset";
9
-
10
- export default {
11
- title: "Components/Form Elements/Fieldset",
12
- component: Fieldset,
13
- };
14
-
15
- export const RadioGroup = () => {
16
- const values = ["Chicago", "Seattle", "Dublin"];
17
- const [selectedValue, setSelectedValue] = useState(values[0]);
18
- const isChecked = (value: string | undefined) => value === selectedValue;
19
- // @ts-ignore - idk what to type this event as
20
- const _handleChange = (e) => {
21
- e.target as HTMLInputElement;
22
- setSelectedValue(e.target.value);
23
- };
24
-
25
- return (
26
- <Box width="443px">
27
- <Fieldset label="Select a location">
28
- {values.map((value) => (
29
- <Radio
30
- id={value}
31
- value={value}
32
- name="location"
33
- label={value}
34
- checked={isChecked(value)}
35
- onChange={_handleChange}
36
- />
37
- ))}
38
- </Fieldset>
39
- </Box>
40
- );
41
- };
42
-
43
- RadioGroup.story = {
44
- name: "Radio group",
45
- };
46
-
47
- export const inputs = () => (
48
- <Box width="443px">
49
- <Fieldset
50
- label={
51
- <Text fontSize={400} color="text.headline">
52
- Your Name
53
- </Text>
54
- }
55
- >
56
- <FormField label="First Name">
57
- {(props) => <Input {...props} name="first-name" />}
58
- </FormField>
59
- <FormField label="Last Name">
60
- {(props) => <Input {...props} name="last-name" />}
61
- </FormField>
62
- </Fieldset>
63
- </Box>
64
- );
65
-
66
- inputs.story = {
67
- name: "Inputs",
68
- };
69
-
70
- export const HorizontalRadios = () => {
71
- const values = ["Chicago", "Seattle", "Dublin"];
72
- const [selectedValue, setSelectedValue] = useState(values[0]);
73
- const isChecked = (value: string | undefined) => value === selectedValue;
74
- // @ts-ignore - idk what to type this event as
75
- const _handleChange = (e) => {
76
- e.target as HTMLInputElement;
77
- setSelectedValue(e.target.value);
78
- };
79
-
80
- return (
81
- <Box width="443px">
82
- <Fieldset label="Select a location" layout="horizontal">
83
- {values.map((value) => (
84
- <Radio
85
- id={value}
86
- value={value}
87
- name="location"
88
- label={value}
89
- checked={isChecked(value)}
90
- onChange={_handleChange}
91
- />
92
- ))}
93
- </Fieldset>
94
- </Box>
95
- );
96
- };
97
-
98
- HorizontalRadios.story = {
99
- name: "Horizontal Radios",
100
- };
101
-
102
- export const horizontalInputs = () => (
103
- <Box width="443px">
104
- <Fieldset label="Your Name" layout="horizontal">
105
- <FormField label="First Name">
106
- {(props) => <Input {...props} name="first-name" />}
107
- </FormField>
108
- <FormField label="Last Name">
109
- {(props) => <Input {...props} name="last-name" />}
110
- </FormField>
111
- </Fieldset>
112
- </Box>
113
- );
114
-
115
- horizontalInputs.story = {
116
- name: "Horizontal Inputs",
117
- };
118
-
119
- export const ValidateInput = () => {
120
- const [firstNameValue, setFirstNameValue] = useState("");
121
- const [lastNameValue, setLastNameValue] = useState("");
122
- const [validation, setValidation] = useState({
123
- firstName: false,
124
- lastName: false,
125
- });
126
-
127
- const firstNameValidation = firstNameValue === "Justyn" ? false : true;
128
- const lastNameValidation = lastNameValue === "Howard" ? false : true;
129
-
130
- const validate = () => {
131
- setValidation({
132
- firstName: firstNameValidation,
133
- lastName: lastNameValidation,
134
- });
135
- };
136
-
137
- // @ts-ignore - idk what to type this event as
138
- const handleFirstNameOnChange = ({ target }) => {
139
- if (firstNameValue.length > 0 && validation.firstName) {
140
- setValidation({
141
- firstName: false,
142
- lastName: lastNameValidation,
143
- });
144
- }
145
- setFirstNameValue(target.value);
146
- };
147
-
148
- // @ts-ignore - idk what to type this event as
149
- const handleLastNameOnChange = ({ target }) => {
150
- if (lastNameValue.length > 0 && validation.lastName) {
151
- setValidation({
152
- firstName: firstNameValidation,
153
- lastName: false,
154
- });
155
- }
156
- setLastNameValue(target.value);
157
- };
158
-
159
- return (
160
- <Box width="443px">
161
- <Fieldset label="Your Name" aria-live="polite">
162
- <FormField
163
- label="First Name"
164
- isInvalid={validation.firstName}
165
- error='First name must be "Justyn" to continue'
166
- >
167
- {(props) => (
168
- <Input
169
- {...props}
170
- value={firstNameValue}
171
- onChange={(e) => handleFirstNameOnChange(e)}
172
- name="first-name"
173
- />
174
- )}
175
- </FormField>
176
- <FormField
177
- label="Last Name"
178
- isInvalid={validation.lastName}
179
- error='Last name must be "Howard" to continue'
180
- >
181
- {(props) => (
182
- <Input
183
- {...props}
184
- value={lastNameValue}
185
- onChange={(e) => handleLastNameOnChange(e)}
186
- name="last-name"
187
- />
188
- )}
189
- </FormField>
190
- <Button type="submit" appearance="primary" onClick={validate}>
191
- Submit
192
- </Button>
193
- </Fieldset>
194
- </Box>
195
- );
196
- };
197
-
198
- ValidateInput.storyName = "Validation";
199
-
200
- export const customFieldset = () => (
201
- <Box width="443px">
202
- <Fieldset
203
- label={
204
- <Fieldset.Legend fontSize={500} color="green.400">
205
- What's your sign?
206
- </Fieldset.Legend>
207
- }
208
- helperText={
209
- <Fieldset.HelperText fontSize={400} color="blue.700">
210
- Mucho Mucho Amor
211
- </Fieldset.HelperText>
212
- }
213
- >
214
- <FormField label="Name">
215
- {(props) => <Input {...props} name="name" />}
216
- </FormField>
217
- <FormField label="Zodiac">
218
- {(props) => <Input {...props} name="zodiac" />}
219
- </FormField>
220
- </Fieldset>
221
- </Box>
222
- );
package/src/Fieldset.tsx DELETED
@@ -1,68 +0,0 @@
1
- import * as React from "react";
2
- import Box from "@sproutsocial/seeds-react-box";
3
- import Text from "@sproutsocial/seeds-react-text";
4
- import { ChildContainer } from "./styles";
5
- import type {
6
- TypeFieldsetProps,
7
- TypeFieldsetLegendProps,
8
- TypeFieldsetHelperText,
9
- } from "./FieldsetTypes";
10
-
11
- /**
12
- * Fieldset Component
13
- */
14
- const Fieldset = ({
15
- layout = "vertical",
16
- label,
17
- helperText,
18
- children,
19
- ...rest
20
- }: TypeFieldsetProps) => (
21
- <Box as="fieldset" border="none" p={0} data-qa-fieldset="" {...rest}>
22
- {typeof label === "string" ? (
23
- <Fieldset.Legend>{label}</Fieldset.Legend>
24
- ) : (
25
- label
26
- )}
27
- {typeof helperText === "string" ? (
28
- <Fieldset.HelperText>{helperText}</Fieldset.HelperText>
29
- ) : (
30
- helperText
31
- )}
32
- <Box
33
- display="flex"
34
- flexDirection={layout === "vertical" ? "column" : "row"}
35
- >
36
- {React.Children.map(children, (child) => (
37
- <ChildContainer layout={layout}>{child}</ChildContainer>
38
- ))}
39
- </Box>
40
- </Box>
41
- );
42
-
43
- const FieldsetLegend = ({ children, ...rest }: TypeFieldsetLegendProps) => (
44
- <Text
45
- as="legend"
46
- fontSize={300}
47
- fontWeight="semibold"
48
- color="text.body"
49
- mb={300}
50
- {...rest}
51
- >
52
- {children}
53
- </Text>
54
- );
55
-
56
- const FieldsetHelperText = ({ children, ...rest }: TypeFieldsetHelperText) => (
57
- <Text as="p" fontSize={200} mb={300} {...rest}>
58
- {children}
59
- </Text>
60
- );
61
-
62
- FieldsetLegend.displayName = "Fieldset.Legend";
63
- FieldsetHelperText.displayName = "Fieldset.HelperText";
64
-
65
- Fieldset.Legend = FieldsetLegend;
66
- Fieldset.HelperText = FieldsetHelperText;
67
-
68
- export default Fieldset;
@@ -1,23 +0,0 @@
1
- import type { TypeTextProps } from "@sproutsocial/seeds-react-text";
2
- import React from "react";
3
- import type { TypeBoxProps } from "@sproutsocial/seeds-react-box";
4
-
5
- export interface TypeFieldsetProps extends TypeBoxProps {
6
- /** Label text to display above the fieldset */
7
- label: React.ReactNode;
8
- helperText?: React.ReactNode;
9
- layout?: "vertical" | "horizontal";
10
- children: React.ReactNode;
11
- }
12
-
13
- export interface TypeFieldsetChildContainerProps {
14
- layout: TypeFieldsetProps["layout"];
15
- }
16
-
17
- export interface TypeFieldsetLegendProps extends TypeTextProps {
18
- children: React.ReactNode;
19
- }
20
-
21
- export interface TypeFieldsetHelperText extends TypeTextProps {
22
- children: React.ReactNode;
23
- }
@@ -1,31 +0,0 @@
1
- import React from "react";
2
- import { render, screen } from "@sproutsocial/seeds-react-testing-library";
3
- import Radio from "@sproutsocial/seeds-react-radio";
4
- import Fieldset from "../Fieldset";
5
-
6
- test("Fieldset builds component when supplied props", () => {
7
- render(
8
- <Fieldset label="the label" helperText="helper text">
9
- <Radio id="the content" name="the content" label="the content" />
10
- </Fieldset>
11
- );
12
- expect(screen.getByText("the label")).toBeInTheDocument();
13
- expect(screen.getByText("helper text")).toBeInTheDocument();
14
- expect(screen.getByLabelText("the content")).toBeInTheDocument();
15
- });
16
-
17
- test("Fieldset supports custom label and helper text", () => {
18
- render(
19
- <Fieldset
20
- label={<Fieldset.Legend fontSize={500}>the label</Fieldset.Legend>}
21
- helperText={
22
- <Fieldset.HelperText mb={400}>helper text</Fieldset.HelperText>
23
- }
24
- >
25
- <Radio id="the content" name="the content" label="the content" />
26
- </Fieldset>
27
- );
28
- expect(screen.getByText("the label")).toBeInTheDocument();
29
- expect(screen.getByText("helper text")).toBeInTheDocument();
30
- expect(screen.getByLabelText("the content")).toBeInTheDocument();
31
- });
@@ -1,30 +0,0 @@
1
- import * as React from "react";
2
- import Radio from "@sproutsocial/seeds-react-radio";
3
- import Fieldset from "../Fieldset";
4
-
5
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
- function FieldsetTypes() {
7
- return (
8
- <>
9
- <Fieldset label="the label" helperText="helper text">
10
- <Radio id="the content" name="the content" label="the content" />
11
- </Fieldset>
12
- <Fieldset
13
- label={<Fieldset.Legend fontSize={500}>the label</Fieldset.Legend>}
14
- helperText={
15
- <Fieldset.HelperText mb={400}>helper text</Fieldset.HelperText>
16
- }
17
- >
18
- <Radio id="the content" name="the content" label="the content" />
19
- </Fieldset>
20
-
21
- {/* @ts-expect-error - test that invalid type is rejected */}
22
- <Fieldset>{/* empty */}</Fieldset>
23
-
24
- {/* @ts-expect-error - test that invalid type is rejected */}
25
- <Fieldset>
26
- <div>thing</div>
27
- </Fieldset>
28
- </>
29
- );
30
- }
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- import Fieldset from "./Fieldset";
2
-
3
- export default Fieldset;
4
- export { Fieldset };
5
- export * from "./FieldsetTypes";
package/src/styled.d.ts DELETED
@@ -1,7 +0,0 @@
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/src/styles.ts DELETED
@@ -1,25 +0,0 @@
1
- import styled, { css } from "styled-components";
2
- import type { TypeFieldsetChildContainerProps } from "./FieldsetTypes";
3
- import Box from "@sproutsocial/seeds-react-box";
4
-
5
- export const ChildContainer = styled(Box)<TypeFieldsetChildContainerProps>`
6
- ${(props) =>
7
- props.layout === "vertical" &&
8
- css`
9
- margin-top: ${props.theme.space[300]};
10
-
11
- &:first-child {
12
- margin-top: 0;
13
- }
14
- `}
15
-
16
- ${(props) =>
17
- props.layout === "horizontal" &&
18
- css`
19
- margin-left: ${props.theme.space[300]};
20
-
21
- &:first-child {
22
- margin-left: 0;
23
- }
24
- `}
25
- `;
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
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 DELETED
@@ -1,12 +0,0 @@
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
- }));