c063 1.1.2 → 1.1.4

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.
@@ -3,7 +3,7 @@ export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K
3
3
  /** 用於重載同名屬性(用於覆蓋類型 T 中與類型 P 相同名稱的屬性,並保留其餘屬性*/
4
4
  export type OverrideProps<T, P> = DistributiveOmit<T, keyof P> & P;
5
5
  /** 支援元件型別 (可複寫屬性)*/
6
- export type AsComponentProps<Component extends React.ElementType, PermanentProps extends object = {}> = OverrideProps<React.ComponentProps<Component>, {
6
+ export type AsComponentProps<As extends React.ElementType, PermanentProps extends object = {}> = OverrideProps<React.ComponentPropsWithRef<As>, PermanentProps> & {
7
7
  /** 指定用於渲染的 React 元件(可為任意元件*/
8
- as?: Component;
9
- } & PermanentProps>;
8
+ as?: As;
9
+ };
@@ -6,13 +6,13 @@ export type CodeTokenType = `keyword-${KeywordColorType}` | "string" | "number"
6
6
  *
7
7
  * @template T HTML 或客製元素,例如 span、a、Link 等
8
8
  */
9
- export type CodeTokenProps<T extends React.ElementType = React.ElementType<React.HTMLAttributes<HTMLElement>>> = AsComponentProps<T, {
9
+ export type CodeTokenProps<T extends React.ElementType = React.ElementType> = AsComponentProps<T, {
10
10
  /**
11
11
  * 語法 token 的語意類型,用於指定樣式顏色。
12
12
  */
13
13
  type?: CodeTokenType;
14
14
  }>;
15
- export type CodeTokenBuilder = (children: CodeTokenProps["children"], props?: DistributiveOmit<CodeTokenProps, "type">) => CodeTokenProps;
15
+ export type CodeTokenBuilder<T extends React.ElementType = "span"> = (children: CodeTokenProps<T>["children"], props?: DistributiveOmit<CodeTokenProps<T>, "type">) => CodeTokenProps<T>;
16
16
  /**
17
17
  * 用於單一程式碼行的屬性,用在 <CodeLine /> 或類似元件中。
18
18
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "c063",
4
- "version": "1.1.2",
4
+ "version": "1.1.4",
5
5
  "description": "A React component for displaying code snippets with syntax highlighting.",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -8,12 +8,9 @@ export type OverrideProps<T, P> = DistributiveOmit<T, keyof P> & P;
8
8
 
9
9
  /** 支援元件型別 (可複寫屬性)*/
10
10
  export type AsComponentProps<
11
- Component extends React.ElementType,
11
+ As extends React.ElementType,
12
12
  PermanentProps extends object = {}
13
- > = OverrideProps<
14
- React.ComponentProps<Component>,
15
- {
16
- /** 指定用於渲染的 React 元件(可為任意元件*/
17
- as?: Component;
18
- } & PermanentProps
19
- >;
13
+ > = OverrideProps<React.ComponentPropsWithRef<As>, PermanentProps> & {
14
+ /** 指定用於渲染的 React 元件(可為任意元件*/
15
+ as?: As;
16
+ };
@@ -21,24 +21,21 @@ export type CodeTokenType =
21
21
  *
22
22
  * @template T HTML 或客製元素,例如 span、a、Link 等
23
23
  */
24
- export type CodeTokenProps<
25
- T extends React.ElementType = React.ElementType<
26
- React.HTMLAttributes<HTMLElement>
27
- >
28
- > = AsComponentProps<
29
- T,
30
- {
31
- /**
32
- * 語法 token 的語意類型,用於指定樣式顏色。
33
- */
34
- type?: CodeTokenType;
35
- }
36
- >;
24
+ export type CodeTokenProps<T extends React.ElementType = React.ElementType> =
25
+ AsComponentProps<
26
+ T,
27
+ {
28
+ /**
29
+ * 語法 token 的語意類型,用於指定樣式顏色。
30
+ */
31
+ type?: CodeTokenType;
32
+ }
33
+ >;
37
34
 
38
- export type CodeTokenBuilder = (
39
- children: CodeTokenProps["children"],
40
- props?: DistributiveOmit<CodeTokenProps, "type">
41
- ) => CodeTokenProps;
35
+ export type CodeTokenBuilder<T extends React.ElementType = "span"> = (
36
+ children: CodeTokenProps<T>["children"],
37
+ props?: DistributiveOmit<CodeTokenProps<T>, "type">
38
+ ) => CodeTokenProps<T>;
42
39
 
43
40
  /**
44
41
  * 用於單一程式碼行的屬性,用在 <CodeLine /> 或類似元件中。