@node-core/ui-components 1.0.1-6cb8b0a0c75c24f5ccc84bb07a1ea9b4b810abd2 → 1.0.1-76b9440b92d63dfcc72150e14795f6958c55c2ce

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.
@@ -73,12 +73,6 @@
73
73
  }
74
74
  }
75
75
 
76
- .notification {
77
- @apply flex
78
- items-center
79
- gap-3;
80
- }
81
-
82
76
  .icon {
83
77
  @apply size-4;
84
78
  }
@@ -1,11 +1,8 @@
1
1
  'use client';
2
2
 
3
- import {
4
- DocumentDuplicateIcon,
5
- CodeBracketIcon,
6
- } from '@heroicons/react/24/outline';
3
+ import { DocumentDuplicateIcon } from '@heroicons/react/24/outline';
7
4
  import classNames from 'classnames';
8
- import type { FC, PropsWithChildren, ReactElement, ReactNode } from 'react';
5
+ import type { FC, PropsWithChildren, ReactElement } from 'react';
9
6
  import { Fragment, isValidElement, useRef } from 'react';
10
7
 
11
8
  import BaseButton from '#ui/Common/BaseButton';
@@ -69,10 +66,9 @@ const transformCode = <T extends ReactElement<PropsWithChildren>>(
69
66
  interface CodeBoxProps {
70
67
  language: string;
71
68
  className?: string;
72
- onCopy: (text: string, message: ReactNode) => void;
69
+ onCopy: (text: string) => void;
73
70
  as?: LinkLike;
74
- copyText: string;
75
- copiedText: string;
71
+ buttonText: string;
76
72
  showCopyButton?: boolean;
77
73
  }
78
74
 
@@ -81,8 +77,7 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
81
77
  language,
82
78
  className,
83
79
  onCopy,
84
- copiedText,
85
- copyText,
80
+ buttonText,
86
81
  as = 'a',
87
82
  showCopyButton = true,
88
83
  }: PropsWithChildren<CodeBoxProps>) => {
@@ -91,13 +86,7 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
91
86
  const handleCopy = (): void => {
92
87
  const text = containerRef.current?.textContent;
93
88
  if (text) {
94
- onCopy(
95
- text,
96
- <div className={styles.notification}>
97
- <CodeBracketIcon className={styles.icon} />
98
- {copiedText}
99
- </div>
100
- );
89
+ onCopy(text);
101
90
  }
102
91
  };
103
92
 
@@ -121,7 +110,7 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
121
110
  onClick={handleCopy}
122
111
  >
123
112
  <DocumentDuplicateIcon className={styles.icon} />
124
- {copyText}
113
+ {buttonText}
125
114
  </BaseButton>
126
115
  )}
127
116
  </div>
@@ -40,8 +40,7 @@ server.listen(port, hostname, () => {
40
40
 
41
41
  const boxProps = {
42
42
  onCopy: console.log,
43
- copyText: '[Copy Text]',
44
- copiedText: '[Copied Text]',
43
+ buttonText: '[Button Text]',
45
44
  };
46
45
 
47
46
  const TabsContent: FC = () => (
@@ -0,0 +1,56 @@
1
+ @reference "../../styles/index.css";
2
+
3
+ .dataTag {
4
+ @apply flex
5
+ items-center
6
+ justify-center
7
+ rounded-full
8
+ font-semibold
9
+ text-white;
10
+
11
+ &.lg {
12
+ @apply size-12
13
+ text-2xl;
14
+ }
15
+
16
+ &.md {
17
+ @apply size-10
18
+ text-xl;
19
+ }
20
+
21
+ &.sm {
22
+ @apply size-8;
23
+ }
24
+
25
+ &.event {
26
+ @apply bg-accent1-600;
27
+ }
28
+
29
+ &.method {
30
+ @apply bg-info-600;
31
+ }
32
+
33
+ &.property {
34
+ @apply bg-green-600;
35
+ }
36
+
37
+ &.class {
38
+ @apply bg-warning-600;
39
+ }
40
+
41
+ &.module {
42
+ @apply bg-red-600;
43
+ }
44
+
45
+ &.classMethod {
46
+ @apply bg-blue-600;
47
+ }
48
+
49
+ &.ctor {
50
+ @apply bg-accent2-600;
51
+ }
52
+
53
+ &.global {
54
+ @apply bg-amber-600;
55
+ }
56
+ }
@@ -0,0 +1,40 @@
1
+ import type { Meta as MetaObj, StoryObj } from '@storybook/react';
2
+
3
+ import DataTag, { type DataTagProps } from '#ui/Common/DataTag';
4
+
5
+ type Story = StoryObj<typeof DataTag>;
6
+ type Meta = MetaObj<typeof DataTag>;
7
+
8
+ export const DataTags: Story = {
9
+ render: () => (
10
+ <div className="grid grid-cols-3 gap-6 p-6">
11
+ {[
12
+ 'event',
13
+ 'method',
14
+ 'property',
15
+ 'class',
16
+ 'module',
17
+ 'classMethod',
18
+ 'ctor',
19
+ 'global',
20
+ ]
21
+ .map(kind =>
22
+ ['sm', 'md', 'lg'].map(size => (
23
+ <div
24
+ key={`${kind}-${size}`}
25
+ className="flex justify-center"
26
+ title={kind}
27
+ >
28
+ <DataTag
29
+ kind={kind as DataTagProps['kind']}
30
+ size={size as DataTagProps['size']}
31
+ />
32
+ </div>
33
+ ))
34
+ )
35
+ .flat()}
36
+ </div>
37
+ ),
38
+ };
39
+
40
+ export default { component: DataTag } as Meta;
@@ -0,0 +1,39 @@
1
+ import classNames from 'classnames';
2
+ import type { FC } from 'react';
3
+
4
+ import styles from './index.module.css';
5
+
6
+ export type DataTagProps = {
7
+ kind:
8
+ | 'event'
9
+ | 'method'
10
+ | 'property'
11
+ | 'class'
12
+ | 'module'
13
+ | 'classMethod'
14
+ | 'global'
15
+ | 'ctor';
16
+ size?: 'lg' | 'md' | 'sm';
17
+ };
18
+
19
+ // These symbols match up with the types used in
20
+ // node core, and the ones defined at
21
+ // https://github.com/nodejs/api-docs-tooling/blob/main/src/types.d.ts#L22 (`HeadingMetadataEntry['type']`)
22
+ const symbolMap = {
23
+ event: 'E',
24
+ method: 'M',
25
+ property: 'P',
26
+ class: 'C',
27
+ module: 'M',
28
+ classMethod: 'S',
29
+ global: 'G',
30
+ ctor: 'C',
31
+ } as const;
32
+
33
+ const DataTag: FC<DataTagProps> = ({ kind, size = 'md' }) => (
34
+ <div className={classNames(styles.dataTag, styles[size], styles[kind])}>
35
+ <span>{symbolMap[kind]}</span>
36
+ </div>
37
+ );
38
+
39
+ export default DataTag;
@@ -1,7 +1,8 @@
1
1
  @reference "../../styles/index.css";
2
2
 
3
3
  .tabsRoot {
4
- @apply max-w-full;
4
+ @apply grid
5
+ max-w-full;
5
6
 
6
7
  .tabsList {
7
8
  @apply font-open-sans
@@ -0,0 +1,47 @@
1
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
2
+ import type { FC, ReactElement } from 'react';
3
+
4
+ import CodeTabs from '#ui/Common/CodeTabs';
5
+
6
+ type MDXCodeTabsProps = {
7
+ children: Array<ReactElement<unknown>>;
8
+ languages: string;
9
+ displayNames?: string;
10
+ defaultTab?: string;
11
+ };
12
+
13
+ const MDXCodeTabs: FC<MDXCodeTabsProps> = ({
14
+ languages: rawLanguages,
15
+ displayNames: rawDisplayNames,
16
+ children: codes,
17
+ defaultTab = '0',
18
+ ...props
19
+ }) => {
20
+ const languages = rawLanguages.split('|');
21
+ const displayNames = rawDisplayNames?.split('|') ?? [];
22
+
23
+ const tabs = languages.map((language, index) => {
24
+ const displayName = displayNames[index];
25
+
26
+ return {
27
+ key: `${language}-${index}`,
28
+ label: displayName?.length ? displayName : language.toUpperCase(),
29
+ };
30
+ });
31
+
32
+ return (
33
+ <CodeTabs
34
+ tabs={tabs}
35
+ defaultValue={tabs[Number(defaultTab)].key}
36
+ {...props}
37
+ >
38
+ {languages.map((_, index) => (
39
+ <TabsPrimitive.Content key={tabs[index].key} value={tabs[index].key}>
40
+ {codes[index]}
41
+ </TabsPrimitive.Content>
42
+ ))}
43
+ </CodeTabs>
44
+ );
45
+ };
46
+
47
+ export default MDXCodeTabs;
package/package.json CHANGED
@@ -13,6 +13,7 @@
13
13
  "files": [
14
14
  "Common",
15
15
  "Containers",
16
+ "MDX",
16
17
  "Icons",
17
18
  "styles",
18
19
  "types.ts",
@@ -20,49 +21,46 @@
20
21
  ],
21
22
  "dependencies": {
22
23
  "@heroicons/react": "^2.2.0",
23
- "@radix-ui/react-avatar": "^1.1.9",
24
- "@radix-ui/react-dialog": "^1.1.7",
25
- "@radix-ui/react-dropdown-menu": "~2.1.6",
26
- "@radix-ui/react-label": "~2.1.2",
27
- "@radix-ui/react-select": "~2.2.2",
28
- "@radix-ui/react-separator": "~1.1.3",
29
- "@radix-ui/react-tabs": "~1.1.3",
30
- "@radix-ui/react-toast": "~1.2.6",
31
- "@radix-ui/react-tooltip": "~1.2.4",
32
- "@tailwindcss/postcss": "~4.1.5",
24
+ "@radix-ui/react-avatar": "^1.1.10",
25
+ "@radix-ui/react-dialog": "^1.1.14",
26
+ "@radix-ui/react-dropdown-menu": "~2.1.15",
27
+ "@radix-ui/react-label": "~2.1.7",
28
+ "@radix-ui/react-select": "~2.2.5",
29
+ "@radix-ui/react-separator": "~1.1.7",
30
+ "@radix-ui/react-tabs": "~1.1.12",
31
+ "@radix-ui/react-toast": "~1.2.14",
32
+ "@radix-ui/react-tooltip": "~1.2.7",
33
+ "@tailwindcss/postcss": "~4.1.8",
33
34
  "@vcarl/remark-headings": "~0.1.0",
34
35
  "classnames": "~2.5.1",
35
36
  "postcss-calc": "^10.1.1",
36
37
  "tailwindcss": "~4.0.17"
37
38
  },
38
39
  "devDependencies": {
39
- "@storybook/addon-controls": "^8.6.12",
40
- "@storybook/addon-interactions": "^8.6.12",
40
+ "@storybook/addon-themes": "^9.0.3",
41
41
  "@storybook/addon-styling-webpack": "^1.0.1",
42
- "@storybook/addon-themes": "^8.6.12",
43
- "@storybook/addon-viewport": "^8.6.12",
44
42
  "@storybook/addon-webpack5-compiler-swc": "^3.0.0",
45
- "@storybook/react": "^8.6.12",
46
- "@storybook/react-webpack5": "^8.6.12",
43
+ "@storybook/react": "^9.0.3",
44
+ "@storybook/react-webpack5": "^9.0.3",
47
45
  "@testing-library/user-event": "~14.6.1",
48
46
  "@types/node": "22.15.3",
49
- "@types/react": "^19.1.0",
47
+ "@types/react": "^19.1.6",
50
48
  "cross-env": "^7.0.3",
51
49
  "css-loader": "~7.1.2",
52
50
  "eslint-plugin-react": "~7.37.4",
53
- "eslint-plugin-storybook": "~0.12.0",
51
+ "eslint-plugin-storybook": "~9.0.3",
54
52
  "global-jsdom": "^26.0.0",
55
53
  "postcss-loader": "~8.1.1",
56
54
  "react": "^19.1.0",
57
- "storybook": "^8.6.11",
55
+ "storybook": "^9.0.3",
58
56
  "style-loader": "~4.0.0",
59
- "stylelint": "^16.19.1",
57
+ "stylelint": "^16.20.0",
60
58
  "stylelint-config-standard": "^38.0.0",
61
59
  "stylelint-order": "7.0.0",
62
60
  "stylelint-selector-bem-pattern": "4.0.1",
63
61
  "tsx": "^4.19.3",
64
62
  "typescript": "~5.8.2",
65
- "typescript-eslint": "~8.31.1"
63
+ "typescript-eslint": "~8.33.1"
66
64
  },
67
65
  "imports": {
68
66
  "#ui/*": [
@@ -76,7 +74,7 @@
76
74
  "engines": {
77
75
  "node": ">=20"
78
76
  },
79
- "version": "1.0.1-6cb8b0a0c75c24f5ccc84bb07a1ea9b4b810abd2",
77
+ "version": "1.0.1-76b9440b92d63dfcc72150e14795f6958c55c2ce",
80
78
  "scripts": {
81
79
  "check-types": "tsc --noEmit",
82
80
  "lint": "turbo run lint:js lint:css",