@hw-component/form 0.0.2 → 0.0.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.
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { IRangePickerProps } from "@/components/DatePicker/modal";
2
+ import type { IRangePickerProps } from "@/components/DatePicker/modal";
3
3
  declare const _default: ({ value, onChange, showTime, ...props }: IRangePickerProps) => JSX.Element;
4
4
  export default _default;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { IDatePickerProps } from "@/components/DatePicker/modal";
2
+ import type { IDatePickerProps } from "@/components/DatePicker/modal";
3
3
  declare const _default: ({ value, onChange, showTime, format, ...props }: IDatePickerProps) => JSX.Element;
4
4
  export default _default;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { HSelectProps } from "@/components/Select/modal";
3
+ import "../index.less";
3
4
  interface IProps extends HSelectProps {
4
5
  checked?: boolean;
5
6
  }
@@ -1,8 +1,8 @@
1
1
  // welcome to ww-building-blocks-tmp
2
2
  import React from 'react';
3
3
  import { Space, Checkbox } from 'antd';
4
- import styles from '../index.less.js';
5
4
  import { itemOpProvider } from '../utils.js';
5
+ import { useClassName } from '../../hooks/useClassName.js';
6
6
 
7
7
  var AllSelect = (function (_ref) {
8
8
  var allSelect = _ref.allSelect,
@@ -17,6 +17,7 @@ var AllSelect = (function (_ref) {
17
17
  }
18
18
  var opLen = (options === null || options === void 0 ? void 0 : options.length) || 0;
19
19
  var checked = (value === null || value === void 0 ? void 0 : value.length) >= opLen;
20
+ var optionsClassName = useClassName("hw-option");
20
21
  var change = function change() {
21
22
  if (!checked) {
22
23
  var subItemOps = itemOpProvider(options, fieldNames);
@@ -26,7 +27,7 @@ var AllSelect = (function (_ref) {
26
27
  onChange === null || onChange === void 0 ? void 0 : onChange([], []);
27
28
  };
28
29
  return /*#__PURE__*/React.createElement("div", {
29
- className: "ant-select-item ant-select-item-option ".concat(styles.option),
30
+ className: "ant-select-item ant-select-item-option ".concat(optionsClassName),
30
31
  onClick: change
31
32
  }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Checkbox, {
32
33
  checked: checked
@@ -0,0 +1 @@
1
+ export declare const useClassName: (className: string) => string;
@@ -0,0 +1,15 @@
1
+ // welcome to ww-building-blocks-tmp
2
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
3
+ import { useContext, useMemo } from 'react';
4
+ import { ConfigContext } from 'antd/es/config-provider';
5
+
6
+ var useClassName = function useClassName(className) {
7
+ var config = useContext(ConfigContext);
8
+ return useMemo(function () {
9
+ var _context;
10
+ return _concatInstanceProperty(_context = "".concat(config.getPrefixCls(), "-")).call(_context, className);
11
+ }, [className]);
12
+ };
13
+
14
+ export { useClassName };
15
+ // powered by ww
package/es/index.css CHANGED
@@ -1,3 +1,3 @@
1
- .option:hover {
1
+ .ant-hw-option:hover {
2
2
  background-color: #f5f5f5;
3
3
  }
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { IRangePickerProps } from "@/components/DatePicker/modal";
2
+ import type { IRangePickerProps } from "@/components/DatePicker/modal";
3
3
  declare const _default: ({ value, onChange, showTime, ...props }: IRangePickerProps) => JSX.Element;
4
4
  export default _default;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { IDatePickerProps } from "@/components/DatePicker/modal";
2
+ import type { IDatePickerProps } from "@/components/DatePicker/modal";
3
3
  declare const _default: ({ value, onChange, showTime, format, ...props }: IDatePickerProps) => JSX.Element;
4
4
  export default _default;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { HSelectProps } from "@/components/Select/modal";
3
+ import "../index.less";
3
4
  interface IProps extends HSelectProps {
4
5
  checked?: boolean;
5
6
  }
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var antd = require('antd');
7
- var index = require('../index.less.js');
8
7
  var utils = require('../utils.js');
8
+ var useClassName = require('../../hooks/useClassName.js');
9
9
 
10
10
  var AllSelect = (function (_ref) {
11
11
  var allSelect = _ref.allSelect,
@@ -20,6 +20,7 @@ var AllSelect = (function (_ref) {
20
20
  }
21
21
  var opLen = (options === null || options === void 0 ? void 0 : options.length) || 0;
22
22
  var checked = (value === null || value === void 0 ? void 0 : value.length) >= opLen;
23
+ var optionsClassName = useClassName.useClassName("hw-option");
23
24
  var change = function change() {
24
25
  if (!checked) {
25
26
  var subItemOps = utils.itemOpProvider(options, fieldNames);
@@ -29,7 +30,7 @@ var AllSelect = (function (_ref) {
29
30
  onChange === null || onChange === void 0 ? void 0 : onChange([], []);
30
31
  };
31
32
  return /*#__PURE__*/React.createElement("div", {
32
- className: "ant-select-item ant-select-item-option ".concat(index.default.option),
33
+ className: "ant-select-item ant-select-item-option ".concat(optionsClassName),
33
34
  onClick: change
34
35
  }, /*#__PURE__*/React.createElement(antd.Space, null, /*#__PURE__*/React.createElement(antd.Checkbox, {
35
36
  checked: checked
@@ -0,0 +1 @@
1
+ export declare const useClassName: (className: string) => string;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/concat');
4
+ var React = require('react');
5
+ var configProvider = require('antd/es/config-provider');
6
+
7
+ var useClassName = function useClassName(className) {
8
+ var config = React.useContext(configProvider.ConfigContext);
9
+ return React.useMemo(function () {
10
+ var _context;
11
+ return _concatInstanceProperty(_context = "".concat(config.getPrefixCls(), "-")).call(_context, className);
12
+ }, [className]);
13
+ };
14
+
15
+ exports.useClassName = useClassName;
16
+ // powered by h
package/lib/index.css CHANGED
@@ -1,3 +1,3 @@
1
- .option:hover {
1
+ .ant-hw-option:hover {
2
2
  background-color: #f5f5f5;
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,7 +66,7 @@
66
66
  "postcss-less": "^6.0.0",
67
67
  "rollup": "^3.23.0",
68
68
  "rollup-plugin-clear": "^2.0.7",
69
- "rollup-plugin-postcss": "^4.0.2",
69
+ "rollup-plugin-postcss": "4.0.0",
70
70
  "rollup-plugin-typescript2": "^0.34.1",
71
71
  "style-loader": "^3.3.3",
72
72
  "stylelint": "13.13.1",
@@ -4,11 +4,11 @@ const { nodeResolve } = require("@rollup/plugin-node-resolve");
4
4
  const { babel } = require("@rollup/plugin-babel");
5
5
  const commonjs = require("@rollup/plugin-commonjs");
6
6
  const typescript = require("rollup-plugin-typescript2");
7
- const postcss = require("rollup-plugin-postcss");
8
7
  const autoprefixer = require("autoprefixer");
9
8
  const inject = require("@rollup/plugin-inject");
10
9
  const url = require("@rollup/plugin-url");
11
10
  const pkg = require("../package.json");
11
+ const postcss = require("rollup-plugin-postcss");
12
12
  const prefix = pkg.cssPrefix;
13
13
  const input = path.resolve(__dirname, "../src/components/index.tsx");
14
14
  const outDir = path.resolve(__dirname, "../lib");
@@ -43,9 +43,6 @@ module.exports = {
43
43
  }),
44
44
  postcss({
45
45
  extract: "index.css",
46
- modules: {
47
- generateScopedName: `${prefix}_[local]`,
48
- },
49
46
  plugins: [
50
47
  autoprefixer({
51
48
  overrideBrowserslist: [
@@ -46,7 +46,14 @@ module.exports = {
46
46
  modules: true,
47
47
  },
48
48
  },
49
- "less-loader",
49
+ {
50
+ loader: "less-loader",
51
+ options:{
52
+ lessOptions:{
53
+ javascriptEnabled: true,
54
+ }
55
+ }
56
+ }
50
57
  ],
51
58
  },
52
59
  ],
@@ -1,7 +1,19 @@
1
- import {DatePicker} from 'antd';
2
- import {IRangePickerProps} from "@/components/DatePicker/modal";
1
+ import { DatePicker } from "antd";
2
+ import type { IRangePickerProps } from "@/components/DatePicker/modal";
3
3
  const { RangePicker } = DatePicker;
4
4
 
5
- export default ({value,onChange,showTime=true,...props}:IRangePickerProps)=>{
6
- return <RangePicker value={value} onChange={value} showTime={showTime} {...props}/>
7
- }
5
+ export default ({
6
+ value,
7
+ onChange,
8
+ showTime = true,
9
+ ...props
10
+ }: IRangePickerProps) => {
11
+ return (
12
+ <RangePicker
13
+ value={value}
14
+ onChange={value}
15
+ showTime={showTime}
16
+ {...props}
17
+ />
18
+ );
19
+ };
@@ -4,7 +4,7 @@ import { DatePicker } from "antd";
4
4
  import { useMemo } from "react";
5
5
  import type { Moment } from "moment";
6
6
  import moment from "moment";
7
- import {IDatePickerProps} from "@/components/DatePicker/modal";
7
+ import type { IDatePickerProps } from "@/components/DatePicker/modal";
8
8
 
9
9
  export default ({
10
10
  value,
@@ -1,16 +1,17 @@
1
- import {RangePickerProps} from "antd/es/date-picker";
2
- import {SharedTimeProps} from "rc-picker/lib/panels/TimePanel";
3
- import {Moment} from "moment";
4
- import {DatePickerProps} from "antd";
1
+ import type { RangePickerProps } from "antd/es/date-picker";
2
+ import type { SharedTimeProps } from "rc-picker/lib/panels/TimePanel";
3
+ import type { Moment } from "moment";
4
+ import type { DatePickerProps } from "antd";
5
5
 
6
- export interface IDatePickerProps extends Omit<DatePickerProps, "onChange" | "format"> {
7
- onChange?: (time?: Moment | string | number) => void;
8
- format?: string;
9
- showTime?: boolean | SharedTimeProps<Moment>;
6
+ export interface IDatePickerProps
7
+ extends Omit<DatePickerProps, "onChange" | "format"> {
8
+ onChange?: (time?: Moment | string | number) => void;
9
+ format?: string;
10
+ showTime?: boolean | SharedTimeProps<Moment>;
10
11
  }
11
12
 
12
- export interface IRangePickerProps extends RangePickerProps{
13
- value?:any;
14
- onChange?:(val:any)=>void;
15
- showTime?: boolean | { defaultValue?: Moment[]};
16
- }
13
+ export interface IRangePickerProps extends RangePickerProps {
14
+ value?: any;
15
+ onChange?: (val: any) => void;
16
+ showTime?: boolean | { defaultValue?: Moment[] };
17
+ }
@@ -1,7 +1,8 @@
1
1
  import type { HSelectProps } from "@/components/Select/modal";
2
2
  import { Checkbox, Space } from "antd";
3
- import styles from "../index.less";
3
+ import "../index.less";
4
4
  import { itemOpProvider } from "../utils";
5
+ import { useClassName } from "../../hooks/useClassName";
5
6
  interface IProps extends HSelectProps {
6
7
  checked?: boolean;
7
8
  }
@@ -19,6 +20,7 @@ export default ({
19
20
  }
20
21
  const opLen = options?.length || 0;
21
22
  const checked = (value as any[])?.length >= opLen;
23
+ const optionsClassName = useClassName("hw-option");
22
24
  const change = () => {
23
25
  if (!checked) {
24
26
  const subItemOps = itemOpProvider(options, fieldNames);
@@ -29,7 +31,7 @@ export default ({
29
31
  };
30
32
  return (
31
33
  <div
32
- className={`ant-select-item ant-select-item-option ${styles.option}`}
34
+ className={`ant-select-item ant-select-item-option ${optionsClassName}`}
33
35
  onClick={change}
34
36
  >
35
37
  <Space>
@@ -1,4 +1,5 @@
1
- .option {
1
+ @import '../styles/local.less';
2
+ .@{ant-prefix}-hw-option {
2
3
  &:hover {
3
4
  background-color: #f5f5f5;
4
5
  }
@@ -0,0 +1,9 @@
1
+ import {useContext, useMemo} from "react";
2
+ import {ConfigContext} from "antd/es/config-provider";
3
+
4
+ export const useClassName = (className: string) => {
5
+ const config=useContext(ConfigContext);
6
+ return useMemo(() => {
7
+ return `${config.getPrefixCls()}-${className}`;
8
+ }, [className]);
9
+ };
@@ -9,4 +9,3 @@ export { default as HRadioGroup } from "./RadioGroup";
9
9
  export { default as HSwitch } from "./Switch";
10
10
  export { default as HDatePicker } from "./DatePicker";
11
11
  export { default as HRangePicker } from "./DatePicker/RangePicker";
12
-
@@ -0,0 +1 @@
1
+ @ant-prefix:ant;
@@ -1,5 +1,5 @@
1
1
  import { Space } from "antd";
2
- import { HDatePicker ,HRangePicker} from "../../components";
2
+ import { HDatePicker, HRangePicker } from "../../components";
3
3
  export default () => {
4
4
  return (
5
5
  <Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
@@ -9,7 +9,7 @@ export default () => {
9
9
  console.log(val);
10
10
  }}
11
11
  />
12
- <HRangePicker/>
12
+ <HRangePicker />
13
13
  </Space>
14
14
  );
15
15
  };
@@ -1,5 +0,0 @@
1
- // welcome to ww-building-blocks-tmp
2
- var styles = undefined;
3
-
4
- export { styles as default };
5
- // powered by ww
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var styles = undefined;
6
-
7
- exports.default = styles;
8
- // powered by h