@akinon/ui-checkbox 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +22 -2
- package/dist/cjs/types.d.ts +68 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +22 -2
- package/dist/esm/types.d.ts +68 -0
- package/package.json +5 -10
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { CheckboxProps as AntCheckboxProps } from 'antd';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
2
|
+
import type { CheckboxGroupProps, CheckboxProps } from './types';
|
|
4
3
|
export declare const Checkbox: ({ children, ...restCheckboxProps }: CheckboxProps) => React.JSX.Element;
|
|
4
|
+
export declare const CheckboxGroup: React.FC<CheckboxGroupProps>;
|
|
5
|
+
export type * from './types';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,QAAQ,uCAAwC,aAAa,sBAgCzE,CAAC;AAEF,eAAO,MAAM,aAAa,EAAwB,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;AAE/E,mBAAmB,SAAS,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -11,11 +11,31 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.Checkbox = void 0;
|
|
14
|
+
exports.CheckboxGroup = exports.Checkbox = void 0;
|
|
15
|
+
const ui_theme_1 = require("@akinon/ui-theme");
|
|
16
|
+
const cssinjs_1 = require("@ant-design/cssinjs");
|
|
15
17
|
const antd_1 = require("antd");
|
|
16
18
|
const React = require("react");
|
|
17
19
|
const Checkbox = (_a) => {
|
|
18
20
|
var { children } = _a, restCheckboxProps = __rest(_a, ["children"]);
|
|
19
|
-
|
|
21
|
+
const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
22
|
+
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
23
|
+
const checkboxToken = token.Checkbox;
|
|
24
|
+
const useStyle = (0, cssinjs_1.useStyleRegister)({
|
|
25
|
+
token: token,
|
|
26
|
+
path: ['Checkbox'],
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
theme: theme
|
|
29
|
+
}, () => {
|
|
30
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-checkbox`;
|
|
31
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-checkbox`;
|
|
32
|
+
return {
|
|
33
|
+
[`${prefixCls}-wrapper:has(${prefixClsWithoutHash}-checked)`]: {
|
|
34
|
+
color: checkboxToken.colorChecked
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
return useStyle(React.createElement(antd_1.Checkbox, Object.assign({}, restCheckboxProps), children));
|
|
20
39
|
};
|
|
21
40
|
exports.Checkbox = Checkbox;
|
|
41
|
+
exports.CheckboxGroup = antd_1.Checkbox.Group;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
2
|
+
|
|
3
|
+
export type CheckboxValueType = string | number | boolean;
|
|
4
|
+
|
|
5
|
+
export interface CheckboxProps {
|
|
6
|
+
className?: string;
|
|
7
|
+
defaultChecked?: boolean;
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
title?: string;
|
|
11
|
+
onChange?: (e: CheckboxChangeEvent) => void;
|
|
12
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
13
|
+
onMouseEnter?: React.MouseEventHandler<HTMLElement>;
|
|
14
|
+
onMouseLeave?: React.MouseEventHandler<HTMLElement>;
|
|
15
|
+
onKeyPress?: React.KeyboardEventHandler<HTMLElement>;
|
|
16
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
|
17
|
+
value?: CheckboxValueType;
|
|
18
|
+
tabIndex?: number;
|
|
19
|
+
name?: string;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
id?: string;
|
|
22
|
+
autoFocus?: boolean;
|
|
23
|
+
type?: string;
|
|
24
|
+
skipGroup?: boolean;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
indeterminate?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Never use this prop. Akinon design system does not allow custom styles.
|
|
29
|
+
* @ignore
|
|
30
|
+
*/
|
|
31
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CheckboxChangeEventTarget extends CheckboxProps {
|
|
35
|
+
checked: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface CheckboxChangeEvent {
|
|
39
|
+
target: CheckboxChangeEventTarget;
|
|
40
|
+
stopPropagation: () => void;
|
|
41
|
+
preventDefault: () => void;
|
|
42
|
+
nativeEvent: MouseEvent;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface CheckboxOptionType<
|
|
46
|
+
T extends CheckboxValueType = CheckboxValueType
|
|
47
|
+
> {
|
|
48
|
+
label: React.ReactNode;
|
|
49
|
+
value: T;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
title?: string;
|
|
52
|
+
id?: string;
|
|
53
|
+
onChange?: (e: CheckboxChangeEvent) => void;
|
|
54
|
+
required?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface CheckboxGroupProps<
|
|
58
|
+
T extends CheckboxValueType = CheckboxValueType
|
|
59
|
+
> {
|
|
60
|
+
className?: string;
|
|
61
|
+
options?: (CheckboxOptionType<T> | string | number)[];
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
name?: string;
|
|
64
|
+
defaultValue?: T[];
|
|
65
|
+
value?: T[];
|
|
66
|
+
onChange?: (checkedValue: T[]) => void;
|
|
67
|
+
children?: React.ReactNode;
|
|
68
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { CheckboxProps as AntCheckboxProps } from 'antd';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
2
|
+
import type { CheckboxGroupProps, CheckboxProps } from './types';
|
|
4
3
|
export declare const Checkbox: ({ children, ...restCheckboxProps }: CheckboxProps) => React.JSX.Element;
|
|
4
|
+
export declare const CheckboxGroup: React.FC<CheckboxGroupProps>;
|
|
5
|
+
export type * from './types';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,QAAQ,uCAAwC,aAAa,sBAgCzE,CAAC;AAEF,eAAO,MAAM,aAAa,EAAwB,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;AAE/E,mBAAmB,SAAS,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,9 +9,29 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { useToken } from '@akinon/ui-theme';
|
|
13
|
+
import { useStyleRegister } from '@ant-design/cssinjs';
|
|
14
|
+
import { Checkbox as AntCheckbox, ConfigProvider } from 'antd';
|
|
13
15
|
import * as React from 'react';
|
|
14
16
|
export const Checkbox = (_a) => {
|
|
15
17
|
var { children } = _a, restCheckboxProps = __rest(_a, ["children"]);
|
|
16
|
-
|
|
18
|
+
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
19
|
+
const { token, hashId } = useToken();
|
|
20
|
+
const checkboxToken = token.Checkbox;
|
|
21
|
+
const useStyle = useStyleRegister({
|
|
22
|
+
token: token,
|
|
23
|
+
path: ['Checkbox'],
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
theme: theme
|
|
26
|
+
}, () => {
|
|
27
|
+
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-checkbox`;
|
|
28
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-checkbox`;
|
|
29
|
+
return {
|
|
30
|
+
[`${prefixCls}-wrapper:has(${prefixClsWithoutHash}-checked)`]: {
|
|
31
|
+
color: checkboxToken.colorChecked
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return useStyle(React.createElement(AntCheckbox, Object.assign({}, restCheckboxProps), children));
|
|
17
36
|
};
|
|
37
|
+
export const CheckboxGroup = AntCheckbox.Group;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
2
|
+
|
|
3
|
+
export type CheckboxValueType = string | number | boolean;
|
|
4
|
+
|
|
5
|
+
export interface CheckboxProps {
|
|
6
|
+
className?: string;
|
|
7
|
+
defaultChecked?: boolean;
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
title?: string;
|
|
11
|
+
onChange?: (e: CheckboxChangeEvent) => void;
|
|
12
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
13
|
+
onMouseEnter?: React.MouseEventHandler<HTMLElement>;
|
|
14
|
+
onMouseLeave?: React.MouseEventHandler<HTMLElement>;
|
|
15
|
+
onKeyPress?: React.KeyboardEventHandler<HTMLElement>;
|
|
16
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
|
17
|
+
value?: CheckboxValueType;
|
|
18
|
+
tabIndex?: number;
|
|
19
|
+
name?: string;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
id?: string;
|
|
22
|
+
autoFocus?: boolean;
|
|
23
|
+
type?: string;
|
|
24
|
+
skipGroup?: boolean;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
indeterminate?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Never use this prop. Akinon design system does not allow custom styles.
|
|
29
|
+
* @ignore
|
|
30
|
+
*/
|
|
31
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CheckboxChangeEventTarget extends CheckboxProps {
|
|
35
|
+
checked: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface CheckboxChangeEvent {
|
|
39
|
+
target: CheckboxChangeEventTarget;
|
|
40
|
+
stopPropagation: () => void;
|
|
41
|
+
preventDefault: () => void;
|
|
42
|
+
nativeEvent: MouseEvent;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface CheckboxOptionType<
|
|
46
|
+
T extends CheckboxValueType = CheckboxValueType
|
|
47
|
+
> {
|
|
48
|
+
label: React.ReactNode;
|
|
49
|
+
value: T;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
title?: string;
|
|
52
|
+
id?: string;
|
|
53
|
+
onChange?: (e: CheckboxChangeEvent) => void;
|
|
54
|
+
required?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface CheckboxGroupProps<
|
|
58
|
+
T extends CheckboxValueType = CheckboxValueType
|
|
59
|
+
> {
|
|
60
|
+
className?: string;
|
|
61
|
+
options?: (CheckboxOptionType<T> | string | number)[];
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
name?: string;
|
|
64
|
+
defaultValue?: T[];
|
|
65
|
+
value?: T[];
|
|
66
|
+
onChange?: (checkedValue: T[]) => void;
|
|
67
|
+
children?: React.ReactNode;
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-checkbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -9,16 +9,15 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"antd": "5.17.0"
|
|
12
|
+
"antd": "5.17.0",
|
|
13
|
+
"@akinon/ui-theme": "0.7.0"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"clean-package": "2.2.0",
|
|
16
17
|
"copyfiles": "^2.4.1",
|
|
17
18
|
"rimraf": "^5.0.5",
|
|
18
19
|
"typescript": "^5.2.2",
|
|
19
|
-
"@akinon/
|
|
20
|
-
"@akinon/typescript-config": "0.2.0",
|
|
21
|
-
"@akinon/eslint-config": "0.1.0"
|
|
20
|
+
"@akinon/typescript-config": "0.4.0"
|
|
22
21
|
},
|
|
23
22
|
"peerDependencies": {
|
|
24
23
|
"react": ">=18",
|
|
@@ -38,12 +37,8 @@
|
|
|
38
37
|
"build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
|
|
39
38
|
"build:esm": "tsc --outDir dist/esm",
|
|
40
39
|
"build:commonjs": "tsc --module commonjs --outDir dist/cjs",
|
|
41
|
-
"copy:files": "copyfiles -u 1 src
|
|
40
|
+
"copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
|
|
42
41
|
"clean": "rimraf dist/",
|
|
43
|
-
"lint": "eslint *.ts*",
|
|
44
|
-
"test": "vitest run",
|
|
45
|
-
"test:ui": "vitest --ui",
|
|
46
|
-
"test:watch": "vitest watch",
|
|
47
42
|
"typecheck": "tsc --noEmit"
|
|
48
43
|
}
|
|
49
44
|
}
|