@akinon/ui-divider 0.2.0 → 0.4.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.
@@ -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 = Omit<AntDividerProps, 'prefixCls' | 'className' | 'classNames' | 'rootClassName' | 'style' | 'styles'> & {
5
- margin?: boolean;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,YAAY,GAAG,IAAI,CACtB,eAAe,EACb,WAAW,GACX,WAAW,GACX,YAAY,GACZ,eAAe,GACf,OAAO,GACP,QAAQ,CACX,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAGzB,eAAO,MAAM,OAAO,6CAKjB,YAAY,sBAUd,CAAC"}
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("./index.css");
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, margin, type } = _a, antdProps = __rest(_a, ["children", "margin", "type"]);
21
- return (React.createElement(antd_1.Divider, Object.assign({}, antdProps, { type: type, className: `ant-divider-custom ${margin === false && 'no-margin'}` }), children));
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;
@@ -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 = Omit<AntDividerProps, 'prefixCls' | 'className' | 'classNames' | 'rootClassName' | 'style' | 'styles'> & {
5
- margin?: boolean;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,YAAY,GAAG,IAAI,CACtB,eAAe,EACb,WAAW,GACX,WAAW,GACX,YAAY,GACZ,eAAe,GACf,OAAO,GACP,QAAQ,CACX,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAGzB,eAAO,MAAM,OAAO,6CAKjB,YAAY,sBAUd,CAAC"}
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 './index.css';
13
- import { Divider as AntDivider } from 'antd';
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, margin, type } = _a, antdProps = __rest(_a, ["children", "margin", "type"]);
18
- return (React.createElement(AntDivider, Object.assign({}, antdProps, { type: type, className: `ant-divider-custom ${margin === false && 'no-margin'}` }), children));
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-divider",
3
- "version": "0.2.0",
3
+ "version": "0.4.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.11.0"
12
+ "antd": "5.17.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "clean-package": "2.2.0",
16
16
  "copyfiles": "^2.4.1",
17
17
  "rimraf": "^5.0.5",
18
18
  "typescript": "^5.2.2",
19
- "@akinon/vite-config": "0.3.0",
20
- "@akinon/eslint-config": "0.1.0",
21
- "@akinon/typescript-config": "0.1.0"
19
+ "@akinon/ui-theme": "0.6.0",
20
+ "@akinon/typescript-config": "0.3.0"
22
21
  },
23
22
  "peerDependencies": {
24
23
  "react": ">=18",
@@ -40,10 +39,6 @@
40
39
  "build:commonjs": "tsc --module commonjs --outDir dist/cjs",
41
40
  "copy:files": "copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css 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
  }
@@ -1,13 +0,0 @@
1
- .akinon-divider-custom {
2
- height: 1.5em;
3
- border-color: var(--color-gray-900);
4
-
5
- &::after,
6
- &::before {
7
- background-color: var(--color-gray-900);
8
- }
9
-
10
- &.no-margin {
11
- margin: 0;
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- .akinon-divider-custom {
2
- height: 1.5em;
3
- border-color: var(--color-gray-900);
4
-
5
- &::after,
6
- &::before {
7
- background-color: var(--color-gray-900);
8
- }
9
-
10
- &.no-margin {
11
- margin: 0;
12
- }
13
- }