@akinon/ui-divider 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 +2 -7
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +36 -4
- package/dist/cjs/types.d.ts +49 -0
- package/dist/esm/index.d.ts +2 -7
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +37 -5
- package/dist/esm/types.d.ts +49 -0
- package/package.json +4 -9
- package/dist/cjs/index.css +0 -13
- package/dist/esm/index.css +0 -13
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import type { DividerProps as AntDividerProps } from 'antd/lib/divider';
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
type DividerProps
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
export declare const Divider: ({ children, margin, type, ...antdProps }: DividerProps) => React.JSX.Element;
|
|
8
|
-
export {};
|
|
2
|
+
import type { DividerProps } from './types';
|
|
3
|
+
export declare const Divider: ({ children, plainOffset, ...antdProps }: DividerProps) => React.JSX.Element;
|
|
9
4
|
//# 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,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,OAAO,4CAIjB,YAAY,sBA6Cd,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,12 +12,44 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.Divider = void 0;
|
|
15
|
-
require("
|
|
15
|
+
const ui_theme_1 = require("@akinon/ui-theme");
|
|
16
|
+
const cssinjs_1 = require("@ant-design/cssinjs");
|
|
16
17
|
const antd_1 = require("antd");
|
|
17
18
|
const React = require("react");
|
|
18
|
-
// TODO better handle classname injection
|
|
19
19
|
const Divider = (_a) => {
|
|
20
|
-
var { children,
|
|
21
|
-
|
|
20
|
+
var { children, plainOffset } = _a, antdProps = __rest(_a, ["children", "plainOffset"]);
|
|
21
|
+
const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
22
|
+
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
23
|
+
const dividerToken = token.Divider;
|
|
24
|
+
const useStyle = (0, cssinjs_1.useStyleRegister)({
|
|
25
|
+
token: token,
|
|
26
|
+
path: ['Divider'],
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
theme: theme
|
|
29
|
+
}, () => {
|
|
30
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-divider`;
|
|
31
|
+
const prefixCls = `:where(.${hashId})${prefixClsWithoutHash}`;
|
|
32
|
+
return {
|
|
33
|
+
[`${prefixCls}-plain`]: {
|
|
34
|
+
[`&${prefixCls}-horizontal${prefixClsWithoutHash}-with-text-left`]: {
|
|
35
|
+
'&:before': {
|
|
36
|
+
width: plainOffset
|
|
37
|
+
? `${plainOffset - dividerToken.textPaddingInline}px`
|
|
38
|
+
: 'auto',
|
|
39
|
+
marginInlineStart: plainOffset ? `-${plainOffset}px` : '-40px'
|
|
40
|
+
},
|
|
41
|
+
'&:after': {
|
|
42
|
+
width: '100%',
|
|
43
|
+
marginInlineStart: 0,
|
|
44
|
+
marginInlineEnd: plainOffset ? `-${plainOffset}px` : '-40px'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[`${prefixClsWithoutHash}-with-text`]: {
|
|
48
|
+
fontWeight: dividerToken === null || dividerToken === void 0 ? void 0 : dividerToken.fontWeight
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return useStyle(React.createElement(antd_1.Divider, Object.assign({}, antdProps), children));
|
|
22
54
|
};
|
|
23
55
|
exports.Divider = Divider;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
2
|
+
|
|
3
|
+
export type DividerProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Select the type of divider.
|
|
6
|
+
* @default 'horizontal'
|
|
7
|
+
*/
|
|
8
|
+
type?: 'horizontal' | 'vertical';
|
|
9
|
+
/**
|
|
10
|
+
* Select the orientation of divider.
|
|
11
|
+
* @default 'left'
|
|
12
|
+
*/
|
|
13
|
+
orientation?: 'left' | 'right' | 'center';
|
|
14
|
+
/**
|
|
15
|
+
* The margin of divider relative to orientation.
|
|
16
|
+
*/
|
|
17
|
+
orientationMargin?: string | number;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the divider is plain.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
plain?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the divider is dashed.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
dashed?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The negative offset of plain divider.
|
|
30
|
+
* Use this prop to set the negative inline margin of plain divider.
|
|
31
|
+
*/
|
|
32
|
+
plainOffset?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The class name of the divider.
|
|
35
|
+
*/
|
|
36
|
+
className?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The root class name of the divider.
|
|
39
|
+
*/
|
|
40
|
+
rootClassName?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The children of the divider.
|
|
43
|
+
*/
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* @ignore
|
|
47
|
+
*/
|
|
48
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
49
|
+
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import type { DividerProps as AntDividerProps } from 'antd/lib/divider';
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
type DividerProps
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
export declare const Divider: ({ children, margin, type, ...antdProps }: DividerProps) => React.JSX.Element;
|
|
8
|
-
export {};
|
|
2
|
+
import type { DividerProps } from './types';
|
|
3
|
+
export declare const Divider: ({ children, plainOffset, ...antdProps }: DividerProps) => React.JSX.Element;
|
|
9
4
|
//# 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,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,OAAO,4CAIjB,YAAY,sBA6Cd,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,11 +9,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import '
|
|
13
|
-
import {
|
|
12
|
+
import { useToken } from '@akinon/ui-theme';
|
|
13
|
+
import { useStyleRegister } from '@ant-design/cssinjs';
|
|
14
|
+
import { ConfigProvider, Divider as AntDivider } from 'antd';
|
|
14
15
|
import * as React from 'react';
|
|
15
|
-
// TODO better handle classname injection
|
|
16
16
|
export const Divider = (_a) => {
|
|
17
|
-
var { children,
|
|
18
|
-
|
|
17
|
+
var { children, plainOffset } = _a, antdProps = __rest(_a, ["children", "plainOffset"]);
|
|
18
|
+
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
19
|
+
const { token, hashId } = useToken();
|
|
20
|
+
const dividerToken = token.Divider;
|
|
21
|
+
const useStyle = useStyleRegister({
|
|
22
|
+
token: token,
|
|
23
|
+
path: ['Divider'],
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
theme: theme
|
|
26
|
+
}, () => {
|
|
27
|
+
const prefixClsWithoutHash = `.${getPrefixCls()}-divider`;
|
|
28
|
+
const prefixCls = `:where(.${hashId})${prefixClsWithoutHash}`;
|
|
29
|
+
return {
|
|
30
|
+
[`${prefixCls}-plain`]: {
|
|
31
|
+
[`&${prefixCls}-horizontal${prefixClsWithoutHash}-with-text-left`]: {
|
|
32
|
+
'&:before': {
|
|
33
|
+
width: plainOffset
|
|
34
|
+
? `${plainOffset - dividerToken.textPaddingInline}px`
|
|
35
|
+
: 'auto',
|
|
36
|
+
marginInlineStart: plainOffset ? `-${plainOffset}px` : '-40px'
|
|
37
|
+
},
|
|
38
|
+
'&:after': {
|
|
39
|
+
width: '100%',
|
|
40
|
+
marginInlineStart: 0,
|
|
41
|
+
marginInlineEnd: plainOffset ? `-${plainOffset}px` : '-40px'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
[`${prefixClsWithoutHash}-with-text`]: {
|
|
45
|
+
fontWeight: dividerToken === null || dividerToken === void 0 ? void 0 : dividerToken.fontWeight
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
return useStyle(React.createElement(AntDivider, Object.assign({}, antdProps), children));
|
|
19
51
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
2
|
+
|
|
3
|
+
export type DividerProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Select the type of divider.
|
|
6
|
+
* @default 'horizontal'
|
|
7
|
+
*/
|
|
8
|
+
type?: 'horizontal' | 'vertical';
|
|
9
|
+
/**
|
|
10
|
+
* Select the orientation of divider.
|
|
11
|
+
* @default 'left'
|
|
12
|
+
*/
|
|
13
|
+
orientation?: 'left' | 'right' | 'center';
|
|
14
|
+
/**
|
|
15
|
+
* The margin of divider relative to orientation.
|
|
16
|
+
*/
|
|
17
|
+
orientationMargin?: string | number;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the divider is plain.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
plain?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the divider is dashed.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
dashed?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The negative offset of plain divider.
|
|
30
|
+
* Use this prop to set the negative inline margin of plain divider.
|
|
31
|
+
*/
|
|
32
|
+
plainOffset?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The class name of the divider.
|
|
35
|
+
*/
|
|
36
|
+
className?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The root class name of the divider.
|
|
39
|
+
*/
|
|
40
|
+
rootClassName?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The children of the divider.
|
|
43
|
+
*/
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* @ignore
|
|
47
|
+
*/
|
|
48
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-divider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -16,9 +16,8 @@
|
|
|
16
16
|
"copyfiles": "^2.4.1",
|
|
17
17
|
"rimraf": "^5.0.5",
|
|
18
18
|
"typescript": "^5.2.2",
|
|
19
|
-
"@akinon/
|
|
20
|
-
"@akinon/
|
|
21
|
-
"@akinon/typescript-config": "0.2.0"
|
|
19
|
+
"@akinon/ui-theme": "0.7.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
|
}
|
package/dist/cjs/index.css
DELETED