@sproutsocial/seeds-react-keyboard-key 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/.turbo/turbo-build.log +67 -11
- package/CHANGELOG.md +7 -0
- package/dist/esm/index.js +55 -4
- 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 +57 -6
- package/dist/index.js.map +1 -1
- package/dist/keyboard-key.css +24 -0
- package/package.json +12 -4
- package/src/KeyboardKey.tsx +9 -11
- package/src/KeyboardKeyHybrid.tsx +31 -0
- package/src/KeyboardKeyTailwind.tsx +50 -0
- package/src/__tests__/features.test.tsx +24 -0
- package/src/keyboard-key.css +24 -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/keyboard-key.css dist/keyboard-key.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.66 KB[39m
|
|
68
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m5.70 KB[39m
|
|
69
|
+
[32mCJS[39m ⚡️ Build success in 17ms
|
|
70
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m2.52 KB[39m
|
|
71
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m5.53 KB[39m
|
|
72
|
+
[32mESM[39m ⚡️ Build success in 17ms
|
|
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 6.
|
|
74
|
+
[32mDTS[39m ⚡️ Build success in 5119ms
|
|
75
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m793.00 B[39m
|
|
76
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m793.00 B[39m
|
|
77
|
+
Done in 6.43s.
|
package/CHANGELOG.md
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// src/KeyboardKey.tsx
|
|
2
2
|
import "react";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
// src/KeyboardKeyHybrid.tsx
|
|
5
|
+
import "react";
|
|
6
|
+
import Text2 from "@sproutsocial/seeds-react-text";
|
|
4
7
|
|
|
5
8
|
// src/styles.ts
|
|
6
9
|
import styled from "styled-components";
|
|
@@ -20,11 +23,59 @@ var Container = styled.div`
|
|
|
20
23
|
`;
|
|
21
24
|
var styles_default = Container;
|
|
22
25
|
|
|
23
|
-
// src/
|
|
26
|
+
// src/KeyboardKeyTailwind.tsx
|
|
27
|
+
import "react";
|
|
28
|
+
import Text from "@sproutsocial/seeds-react-text";
|
|
24
29
|
import { jsx } from "react/jsx-runtime";
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
function cn(...inputs) {
|
|
31
|
+
const classes = [];
|
|
32
|
+
for (const input of inputs) {
|
|
33
|
+
if (!input) continue;
|
|
34
|
+
if (typeof input === "string") {
|
|
35
|
+
classes.push(input);
|
|
36
|
+
} else if (typeof input === "object") {
|
|
37
|
+
for (const [key, value] of Object.entries(input)) {
|
|
38
|
+
if (value) {
|
|
39
|
+
classes.push(key);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return classes.join(" ");
|
|
45
|
+
}
|
|
46
|
+
var KeyboardKeyTailwind = ({
|
|
47
|
+
children,
|
|
48
|
+
className,
|
|
49
|
+
...rest
|
|
50
|
+
}) => {
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
className: cn("seeds-keyboard-key", className),
|
|
55
|
+
...rest,
|
|
56
|
+
children: /* @__PURE__ */ jsx("kbd", { "data-qa-keyboardkey": children, children: /* @__PURE__ */ jsx(Text, { children }) })
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
KeyboardKeyTailwind.displayName = "KeyboardKeyTailwind";
|
|
61
|
+
|
|
62
|
+
// src/KeyboardKeyHybrid.tsx
|
|
63
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
64
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
65
|
+
var KeyboardKeyHybrid = ({
|
|
66
|
+
children,
|
|
67
|
+
...rest
|
|
68
|
+
}) => {
|
|
69
|
+
if (hasStyledProps(rest)) {
|
|
70
|
+
return /* @__PURE__ */ jsx2(styles_default, { ...rest, children: /* @__PURE__ */ jsx2("kbd", { "data-qa-keyboardkey": children, children: /* @__PURE__ */ jsx2(Text2, { children }) }) });
|
|
71
|
+
}
|
|
72
|
+
return /* @__PURE__ */ jsx2(KeyboardKeyTailwind, { ...rest, children });
|
|
27
73
|
};
|
|
74
|
+
KeyboardKeyHybrid.displayName = "KeyboardKey";
|
|
75
|
+
|
|
76
|
+
// src/KeyboardKey.tsx
|
|
77
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
78
|
+
var KeyboardKey = (props) => /* @__PURE__ */ jsx3(KeyboardKeyHybrid, { ...props });
|
|
28
79
|
|
|
29
80
|
// src/KeyboardKeyTypes.ts
|
|
30
81
|
import "react";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/KeyboardKey.tsx","../../src/styles.ts","../../src/KeyboardKeyTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport Container from \"./styles\";\nimport type { TypeKeyboardKeyProps } from \"./KeyboardKeyTypes\";\n\nexport const
|
|
1
|
+
{"version":3,"sources":["../../src/KeyboardKey.tsx","../../src/KeyboardKeyHybrid.tsx","../../src/styles.ts","../../src/KeyboardKeyTailwind.tsx","../../src/KeyboardKeyTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { KeyboardKeyHybrid } from \"./KeyboardKeyHybrid\";\nimport type { TypeKeyboardKeyProps } from \"./KeyboardKeyTypes\";\n\n/**\n * KeyboardKey component. Automatically routes between the Tailwind\n * implementation (preferred) and the styled-components implementation (for\n * consumers using system props or styled() extension).\n */\nexport const KeyboardKey = (props: TypeKeyboardKeyProps) => (\n <KeyboardKeyHybrid {...props} />\n);\n","/**\n * Hybrid KeyboardKey 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 Container from \"./styles\"; // Styled-components version\nimport { KeyboardKeyTailwind } from \"./KeyboardKeyTailwind\"; // Tailwind version\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeKeyboardKeyProps } from \"./KeyboardKeyTypes\";\n\nexport const KeyboardKeyHybrid = ({\n children,\n ...rest\n}: TypeKeyboardKeyProps) => {\n if (hasStyledProps(rest)) {\n return (\n <Container {...rest}>\n <kbd data-qa-keyboardkey={children}>\n <Text>{children}</Text>\n </kbd>\n </Container>\n );\n }\n\n // Use Tailwind version (preferred - better performance)\n return <KeyboardKeyTailwind {...rest}>{children}</KeyboardKeyTailwind>;\n};\n\nKeyboardKeyHybrid.displayName = \"KeyboardKey\";\n","import styled from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\n\nconst Container = styled.div`\n display: inline-flex;\n color: ${(props) => props.theme.colors.text.body};\n background-color: ${(props) => props.theme.colors.container.background.base};\n border: 1px solid ${(props) => props.theme.colors.container.border.base};\n border-radius: ${(props) => props.theme.radii[500]};\n box-shadow: ${(props) => props.theme.shadows.low};\n padding: 0 ${(props) => props.theme.space[200]};\n min-width: 20px;\n justify-content: center;\n\n ${COMMON}\n`;\n\nexport default Container;\n","/**\n * Tailwind CSS implementation of KeyboardKey component\n * Uses Seeds keyboard-key CSS classes from keyboard-key.css\n */\n\nimport * as React from \"react\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport type { TypeKeyboardKeyProps } from \"./KeyboardKeyTypes\";\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 KeyboardKeyTailwind = ({\n children,\n className,\n ...rest\n}: TypeKeyboardKeyProps) => {\n return (\n <div\n className={cn(\"seeds-keyboard-key\", className)}\n {...(rest as React.ComponentPropsWithoutRef<\"div\">)}\n >\n <kbd data-qa-keyboardkey={children}>\n <Text>{children}</Text>\n </kbd>\n </div>\n );\n};\n\nKeyboardKeyTailwind.displayName = \"KeyboardKeyTailwind\";\n","import * as React from \"react\";\nimport type {\n TypeSystemCommonProps,\n TypeStyledComponentsCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\nexport interface TypeKeyboardKeyProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"div\">, \"color\"> {\n /** Text to display inside of key */\n children: string;\n}\n","import { KeyboardKey } from \"./KeyboardKey\";\n\nexport default KeyboardKey;\nexport { KeyboardKey };\nexport * from \"./KeyboardKeyTypes\";\n"],"mappings":";AAAA,OAAuB;;;ACKvB,OAAuB;AACvB,OAAOA,WAAU;;;ACNjB,OAAO,YAAY;AACnB,SAAS,cAAc;AAEvB,IAAM,YAAY,OAAO;AAAA;AAAA,WAEd,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,IAAI;AAAA,sBAC5B,CAAC,UAAU,MAAM,MAAM,OAAO,UAAU,WAAW,IAAI;AAAA,sBACvD,CAAC,UAAU,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,mBACtD,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,gBACpC,CAAC,UAAU,MAAM,MAAM,QAAQ,GAAG;AAAA,eACnC,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA,IAI5C,MAAM;AAAA;AAGV,IAAO,iBAAQ;;;ACZf,OAAuB;AACvB,OAAO,UAAU;AAqCT;AAjCR,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,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA4B;AAC1B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,sBAAsB,SAAS;AAAA,MAC5C,GAAI;AAAA,MAEL,8BAAC,SAAI,uBAAqB,UACxB,8BAAC,QAAM,UAAS,GAClB;AAAA;AAAA,EACF;AAEJ;AAEA,oBAAoB,cAAc;;;AFxClC,SAAS,sBAAsB;AAWrB,gBAAAC,YAAA;AARH,IAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA,GAAG;AACL,MAA4B;AAC1B,MAAI,eAAe,IAAI,GAAG;AACxB,WACE,gBAAAA,KAAC,kBAAW,GAAG,MACb,0BAAAA,KAAC,SAAI,uBAAqB,UACxB,0BAAAA,KAACC,OAAA,EAAM,UAAS,GAClB,GACF;AAAA,EAEJ;AAGA,SAAO,gBAAAD,KAAC,uBAAqB,GAAG,MAAO,UAAS;AAClD;AAEA,kBAAkB,cAAc;;;ADpB9B,gBAAAE,YAAA;AADK,IAAM,cAAc,CAAC,UAC1B,gBAAAA,KAAC,qBAAmB,GAAG,OAAO;;;AIVhC,OAAuB;;;ACEvB,IAAO,gBAAQ;","names":["Text","jsx","Text","jsx"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,11 @@ interface TypeKeyboardKeyProps extends TypeStyledComponentsCommonProps, TypeSyst
|
|
|
7
7
|
children: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* KeyboardKey component. Automatically routes between the Tailwind
|
|
12
|
+
* implementation (preferred) and the styled-components implementation (for
|
|
13
|
+
* consumers using system props or styled() extension).
|
|
14
|
+
*/
|
|
15
|
+
declare const KeyboardKey: (props: TypeKeyboardKeyProps) => react_jsx_runtime.JSX.Element;
|
|
11
16
|
|
|
12
17
|
export { KeyboardKey, type TypeKeyboardKeyProps, KeyboardKey as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ interface TypeKeyboardKeyProps extends TypeStyledComponentsCommonProps, TypeSyst
|
|
|
7
7
|
children: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* KeyboardKey component. Automatically routes between the Tailwind
|
|
12
|
+
* implementation (preferred) and the styled-components implementation (for
|
|
13
|
+
* consumers using system props or styled() extension).
|
|
14
|
+
*/
|
|
15
|
+
declare const KeyboardKey: (props: TypeKeyboardKeyProps) => react_jsx_runtime.JSX.Element;
|
|
11
16
|
|
|
12
17
|
export { KeyboardKey, type TypeKeyboardKeyProps, KeyboardKey as default };
|
package/dist/index.js
CHANGED
|
@@ -36,8 +36,11 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/KeyboardKey.tsx
|
|
39
|
-
var
|
|
40
|
-
|
|
39
|
+
var React3 = require("react");
|
|
40
|
+
|
|
41
|
+
// src/KeyboardKeyHybrid.tsx
|
|
42
|
+
var React2 = require("react");
|
|
43
|
+
var import_seeds_react_text2 = __toESM(require("@sproutsocial/seeds-react-text"));
|
|
41
44
|
|
|
42
45
|
// src/styles.ts
|
|
43
46
|
var import_styled_components = __toESM(require("styled-components"));
|
|
@@ -57,14 +60,62 @@ var Container = import_styled_components.default.div`
|
|
|
57
60
|
`;
|
|
58
61
|
var styles_default = Container;
|
|
59
62
|
|
|
60
|
-
// src/
|
|
63
|
+
// src/KeyboardKeyTailwind.tsx
|
|
64
|
+
var React = require("react");
|
|
65
|
+
var import_seeds_react_text = __toESM(require("@sproutsocial/seeds-react-text"));
|
|
61
66
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
function cn(...inputs) {
|
|
68
|
+
const classes = [];
|
|
69
|
+
for (const input of inputs) {
|
|
70
|
+
if (!input) continue;
|
|
71
|
+
if (typeof input === "string") {
|
|
72
|
+
classes.push(input);
|
|
73
|
+
} else if (typeof input === "object") {
|
|
74
|
+
for (const [key, value] of Object.entries(input)) {
|
|
75
|
+
if (value) {
|
|
76
|
+
classes.push(key);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return classes.join(" ");
|
|
82
|
+
}
|
|
83
|
+
var KeyboardKeyTailwind = ({
|
|
84
|
+
children,
|
|
85
|
+
className,
|
|
86
|
+
...rest
|
|
87
|
+
}) => {
|
|
88
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
className: cn("seeds-keyboard-key", className),
|
|
92
|
+
...rest,
|
|
93
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { "data-qa-keyboardkey": children, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_text.default, { children }) })
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
KeyboardKeyTailwind.displayName = "KeyboardKeyTailwind";
|
|
98
|
+
|
|
99
|
+
// src/KeyboardKeyHybrid.tsx
|
|
100
|
+
var import_seeds_react_system_props2 = require("@sproutsocial/seeds-react-system-props");
|
|
101
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
102
|
+
var KeyboardKeyHybrid = ({
|
|
103
|
+
children,
|
|
104
|
+
...rest
|
|
105
|
+
}) => {
|
|
106
|
+
if ((0, import_seeds_react_system_props2.hasStyledProps)(rest)) {
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(styles_default, { ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("kbd", { "data-qa-keyboardkey": children, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_text2.default, { children }) }) });
|
|
108
|
+
}
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(KeyboardKeyTailwind, { ...rest, children });
|
|
64
110
|
};
|
|
111
|
+
KeyboardKeyHybrid.displayName = "KeyboardKey";
|
|
112
|
+
|
|
113
|
+
// src/KeyboardKey.tsx
|
|
114
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
115
|
+
var KeyboardKey = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyboardKeyHybrid, { ...props });
|
|
65
116
|
|
|
66
117
|
// src/KeyboardKeyTypes.ts
|
|
67
|
-
var
|
|
118
|
+
var React4 = require("react");
|
|
68
119
|
|
|
69
120
|
// src/index.ts
|
|
70
121
|
var index_default = KeyboardKey;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/KeyboardKey.tsx","../src/styles.ts","../src/KeyboardKeyTypes.ts"],"sourcesContent":["import { KeyboardKey } from \"./KeyboardKey\";\n\nexport default KeyboardKey;\nexport { KeyboardKey };\nexport * from \"./KeyboardKeyTypes\";\n","import * as React from \"react\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport Container from \"./styles\";\nimport type { TypeKeyboardKeyProps } from \"./KeyboardKeyTypes\";\n\nexport const
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/KeyboardKey.tsx","../src/KeyboardKeyHybrid.tsx","../src/styles.ts","../src/KeyboardKeyTailwind.tsx","../src/KeyboardKeyTypes.ts"],"sourcesContent":["import { KeyboardKey } from \"./KeyboardKey\";\n\nexport default KeyboardKey;\nexport { KeyboardKey };\nexport * from \"./KeyboardKeyTypes\";\n","import * as React from \"react\";\nimport { KeyboardKeyHybrid } from \"./KeyboardKeyHybrid\";\nimport type { TypeKeyboardKeyProps } from \"./KeyboardKeyTypes\";\n\n/**\n * KeyboardKey component. Automatically routes between the Tailwind\n * implementation (preferred) and the styled-components implementation (for\n * consumers using system props or styled() extension).\n */\nexport const KeyboardKey = (props: TypeKeyboardKeyProps) => (\n <KeyboardKeyHybrid {...props} />\n);\n","/**\n * Hybrid KeyboardKey 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 Container from \"./styles\"; // Styled-components version\nimport { KeyboardKeyTailwind } from \"./KeyboardKeyTailwind\"; // Tailwind version\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeKeyboardKeyProps } from \"./KeyboardKeyTypes\";\n\nexport const KeyboardKeyHybrid = ({\n children,\n ...rest\n}: TypeKeyboardKeyProps) => {\n if (hasStyledProps(rest)) {\n return (\n <Container {...rest}>\n <kbd data-qa-keyboardkey={children}>\n <Text>{children}</Text>\n </kbd>\n </Container>\n );\n }\n\n // Use Tailwind version (preferred - better performance)\n return <KeyboardKeyTailwind {...rest}>{children}</KeyboardKeyTailwind>;\n};\n\nKeyboardKeyHybrid.displayName = \"KeyboardKey\";\n","import styled from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\n\nconst Container = styled.div`\n display: inline-flex;\n color: ${(props) => props.theme.colors.text.body};\n background-color: ${(props) => props.theme.colors.container.background.base};\n border: 1px solid ${(props) => props.theme.colors.container.border.base};\n border-radius: ${(props) => props.theme.radii[500]};\n box-shadow: ${(props) => props.theme.shadows.low};\n padding: 0 ${(props) => props.theme.space[200]};\n min-width: 20px;\n justify-content: center;\n\n ${COMMON}\n`;\n\nexport default Container;\n","/**\n * Tailwind CSS implementation of KeyboardKey component\n * Uses Seeds keyboard-key CSS classes from keyboard-key.css\n */\n\nimport * as React from \"react\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport type { TypeKeyboardKeyProps } from \"./KeyboardKeyTypes\";\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 KeyboardKeyTailwind = ({\n children,\n className,\n ...rest\n}: TypeKeyboardKeyProps) => {\n return (\n <div\n className={cn(\"seeds-keyboard-key\", className)}\n {...(rest as React.ComponentPropsWithoutRef<\"div\">)}\n >\n <kbd data-qa-keyboardkey={children}>\n <Text>{children}</Text>\n </kbd>\n </div>\n );\n};\n\nKeyboardKeyTailwind.displayName = \"KeyboardKeyTailwind\";\n","import * as React from \"react\";\nimport type {\n TypeSystemCommonProps,\n TypeStyledComponentsCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\nexport interface TypeKeyboardKeyProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"div\">, \"color\"> {\n /** Text to display inside of key */\n children: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;;;ACKvB,IAAAC,SAAuB;AACvB,IAAAC,2BAAiB;;;ACNjB,+BAAmB;AACnB,sCAAuB;AAEvB,IAAM,YAAY,yBAAAC,QAAO;AAAA;AAAA,WAEd,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,IAAI;AAAA,sBAC5B,CAAC,UAAU,MAAM,MAAM,OAAO,UAAU,WAAW,IAAI;AAAA,sBACvD,CAAC,UAAU,MAAM,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA,mBACtD,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,gBACpC,CAAC,UAAU,MAAM,MAAM,QAAQ,GAAG;AAAA,eACnC,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA,IAI5C,sCAAM;AAAA;AAGV,IAAO,iBAAQ;;;ACZf,YAAuB;AACvB,8BAAiB;AAqCT;AAjCR,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,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA4B;AAC1B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,sBAAsB,SAAS;AAAA,MAC5C,GAAI;AAAA,MAEL,sDAAC,SAAI,uBAAqB,UACxB,sDAAC,wBAAAC,SAAA,EAAM,UAAS,GAClB;AAAA;AAAA,EACF;AAEJ;AAEA,oBAAoB,cAAc;;;AFxClC,IAAAC,mCAA+B;AAWrB,IAAAC,sBAAA;AARH,IAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA,GAAG;AACL,MAA4B;AAC1B,UAAI,iDAAe,IAAI,GAAG;AACxB,WACE,6CAAC,kBAAW,GAAG,MACb,uDAAC,SAAI,uBAAqB,UACxB,uDAAC,yBAAAC,SAAA,EAAM,UAAS,GAClB,GACF;AAAA,EAEJ;AAGA,SAAO,6CAAC,uBAAqB,GAAG,MAAO,UAAS;AAClD;AAEA,kBAAkB,cAAc;;;ADpB9B,IAAAC,sBAAA;AADK,IAAM,cAAc,CAAC,UAC1B,6CAAC,qBAAmB,GAAG,OAAO;;;AIVhC,IAAAC,SAAuB;;;ALEvB,IAAO,gBAAQ;","names":["React","React","import_seeds_react_text","styled","Text","import_seeds_react_system_props","import_jsx_runtime","Text","import_jsx_runtime","React"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds KeyboardKey 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-keyboard-key {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
color: var(--color-text-body);
|
|
16
|
+
background-color: var(--color-container-bg-base);
|
|
17
|
+
border: 1px solid var(--color-container-border-base);
|
|
18
|
+
border-radius: var(--radius-500);
|
|
19
|
+
box-shadow: var(--shadow-low);
|
|
20
|
+
padding: 0 var(--space-200);
|
|
21
|
+
min-width: 20px;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-keyboard-key",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "Seeds React KeyboardKey",
|
|
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/keyboard-key.css": "./dist/keyboard-key.css"
|
|
17
|
+
},
|
|
10
18
|
"scripts": {
|
|
11
|
-
"build": "tsup --dts",
|
|
12
|
-
"build:debug": "tsup --dts --metafile",
|
|
19
|
+
"build": "tsup --dts && cp src/keyboard-key.css dist/keyboard-key.css",
|
|
20
|
+
"build:debug": "tsup --dts --metafile && cp src/keyboard-key.css dist/keyboard-key.css",
|
|
13
21
|
"dev": "tsup --watch --dts",
|
|
14
22
|
"clean": "rm -rf .turbo dist",
|
|
15
23
|
"clean:modules": "rm -rf node_modules",
|
|
@@ -18,7 +26,7 @@
|
|
|
18
26
|
"test:watch": "jest --watch --coverage=false"
|
|
19
27
|
},
|
|
20
28
|
"dependencies": {
|
|
21
|
-
"@sproutsocial/seeds-react-theme": "^4.2.
|
|
29
|
+
"@sproutsocial/seeds-react-theme": "^4.2.1",
|
|
22
30
|
"@sproutsocial/seeds-react-system-props": "^3.1.2",
|
|
23
31
|
"@sproutsocial/seeds-react-text": "^1.5.1"
|
|
24
32
|
},
|
package/src/KeyboardKey.tsx
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
import Container from "./styles";
|
|
2
|
+
import { KeyboardKeyHybrid } from "./KeyboardKeyHybrid";
|
|
4
3
|
import type { TypeKeyboardKeyProps } from "./KeyboardKeyTypes";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
5
|
+
/**
|
|
6
|
+
* KeyboardKey component. Automatically routes between the Tailwind
|
|
7
|
+
* implementation (preferred) and the styled-components implementation (for
|
|
8
|
+
* consumers using system props or styled() extension).
|
|
9
|
+
*/
|
|
10
|
+
export const KeyboardKey = (props: TypeKeyboardKeyProps) => (
|
|
11
|
+
<KeyboardKeyHybrid {...props} />
|
|
12
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hybrid KeyboardKey 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 Container from "./styles"; // Styled-components version
|
|
9
|
+
import { KeyboardKeyTailwind } from "./KeyboardKeyTailwind"; // Tailwind version
|
|
10
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
11
|
+
import type { TypeKeyboardKeyProps } from "./KeyboardKeyTypes";
|
|
12
|
+
|
|
13
|
+
export const KeyboardKeyHybrid = ({
|
|
14
|
+
children,
|
|
15
|
+
...rest
|
|
16
|
+
}: TypeKeyboardKeyProps) => {
|
|
17
|
+
if (hasStyledProps(rest)) {
|
|
18
|
+
return (
|
|
19
|
+
<Container {...rest}>
|
|
20
|
+
<kbd data-qa-keyboardkey={children}>
|
|
21
|
+
<Text>{children}</Text>
|
|
22
|
+
</kbd>
|
|
23
|
+
</Container>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Use Tailwind version (preferred - better performance)
|
|
28
|
+
return <KeyboardKeyTailwind {...rest}>{children}</KeyboardKeyTailwind>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
KeyboardKeyHybrid.displayName = "KeyboardKey";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind CSS implementation of KeyboardKey component
|
|
3
|
+
* Uses Seeds keyboard-key CSS classes from keyboard-key.css
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import Text from "@sproutsocial/seeds-react-text";
|
|
8
|
+
import type { TypeKeyboardKeyProps } from "./KeyboardKeyTypes";
|
|
9
|
+
|
|
10
|
+
// Utility for merging class names properly
|
|
11
|
+
function cn(
|
|
12
|
+
...inputs: (string | undefined | null | false | Record<string, boolean>)[]
|
|
13
|
+
): string {
|
|
14
|
+
const classes: string[] = [];
|
|
15
|
+
|
|
16
|
+
for (const input of inputs) {
|
|
17
|
+
if (!input) continue;
|
|
18
|
+
|
|
19
|
+
if (typeof input === "string") {
|
|
20
|
+
classes.push(input);
|
|
21
|
+
} else if (typeof input === "object") {
|
|
22
|
+
for (const [key, value] of Object.entries(input)) {
|
|
23
|
+
if (value) {
|
|
24
|
+
classes.push(key);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return classes.join(" ");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const KeyboardKeyTailwind = ({
|
|
34
|
+
children,
|
|
35
|
+
className,
|
|
36
|
+
...rest
|
|
37
|
+
}: TypeKeyboardKeyProps) => {
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className={cn("seeds-keyboard-key", className)}
|
|
41
|
+
{...(rest as React.ComponentPropsWithoutRef<"div">)}
|
|
42
|
+
>
|
|
43
|
+
<kbd data-qa-keyboardkey={children}>
|
|
44
|
+
<Text>{children}</Text>
|
|
45
|
+
</kbd>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
KeyboardKeyTailwind.displayName = "KeyboardKeyTailwind";
|
|
@@ -8,4 +8,28 @@ describe("KeyboardKey", () => {
|
|
|
8
8
|
render(<KeyboardKey>{children}</KeyboardKey>);
|
|
9
9
|
expect(screen.getByText(children)).toBeInTheDocument();
|
|
10
10
|
});
|
|
11
|
+
|
|
12
|
+
it("renders the Tailwind path with the seeds-keyboard-key class and qa attribute", () => {
|
|
13
|
+
render(<KeyboardKey>esc</KeyboardKey>);
|
|
14
|
+
const kbd = screen.getByText("esc").closest("kbd");
|
|
15
|
+
expect(kbd).toHaveAttribute("data-qa-keyboardkey", "esc");
|
|
16
|
+
expect(kbd?.parentElement).toHaveClass("seeds-keyboard-key");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("merges a consumer className on the Tailwind path (styled() contract)", () => {
|
|
20
|
+
render(<KeyboardKey className="custom">esc</KeyboardKey>);
|
|
21
|
+
const container = screen.getByText("esc").closest("kbd")?.parentElement;
|
|
22
|
+
expect(container).toHaveClass("seeds-keyboard-key");
|
|
23
|
+
expect(container).toHaveClass("custom");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("routes through the styled-components path when a system prop is present", () => {
|
|
27
|
+
// mt is a system prop, which routes KeyboardKey through the styled-components path
|
|
28
|
+
render(<KeyboardKey mt={200}>esc</KeyboardKey>);
|
|
29
|
+
expect(screen.getByText("esc")).toBeInTheDocument();
|
|
30
|
+
expect(screen.getByText("esc").closest("kbd")).toHaveAttribute(
|
|
31
|
+
"data-qa-keyboardkey",
|
|
32
|
+
"esc"
|
|
33
|
+
);
|
|
34
|
+
});
|
|
11
35
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds KeyboardKey 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-keyboard-key {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
color: var(--color-text-body);
|
|
16
|
+
background-color: var(--color-container-bg-base);
|
|
17
|
+
border: 1px solid var(--color-container-border-base);
|
|
18
|
+
border-radius: var(--radius-500);
|
|
19
|
+
box-shadow: var(--shadow-low);
|
|
20
|
+
padding: 0 var(--space-200);
|
|
21
|
+
min-width: 20px;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
}
|
|
24
|
+
}
|