@hw-component/form 0.0.3 → 0.0.5

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;
@@ -17,7 +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("option");
20
+ var optionsClassName = useClassName("hw-option");
21
21
  var change = function change() {
22
22
  if (!checked) {
23
23
  var subItemOps = itemOpProvider(options, fieldNames);
package/es/config.d.ts CHANGED
@@ -11,5 +11,4 @@ export declare const baseConfig: {
11
11
  checked: boolean;
12
12
  noChecked: boolean;
13
13
  };
14
- prefixCls: string;
15
14
  };
package/es/config.js CHANGED
@@ -11,8 +11,7 @@ var baseConfig = {
11
11
  defaultValueSwitchMap: {
12
12
  checked: true,
13
13
  noChecked: false
14
- },
15
- prefixCls: "hw"
14
+ }
16
15
  };
17
16
 
18
17
  export { baseConfig };
@@ -1,12 +1,13 @@
1
1
  // welcome to ww-building-blocks-tmp
2
2
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
3
- import { useMemo } from 'react';
4
- import { baseConfig } from '../config.js';
3
+ import { useContext, useMemo } from 'react';
4
+ import { ConfigContext } from 'antd/es/config-provider';
5
5
 
6
6
  var useClassName = function useClassName(className) {
7
+ var config = useContext(ConfigContext);
7
8
  return useMemo(function () {
8
9
  var _context;
9
- return _concatInstanceProperty(_context = "".concat(baseConfig.prefixCls, "-")).call(_context, className);
10
+ return _concatInstanceProperty(_context = "".concat(config.getPrefixCls(), "-")).call(_context, className);
10
11
  }, [className]);
11
12
  };
12
13
 
package/es/index.css CHANGED
@@ -1,3 +1,3 @@
1
- .hw-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;
@@ -20,7 +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("option");
23
+ var optionsClassName = useClassName.useClassName("hw-option");
24
24
  var change = function change() {
25
25
  if (!checked) {
26
26
  var subItemOps = utils.itemOpProvider(options, fieldNames);
package/lib/config.d.ts CHANGED
@@ -11,5 +11,4 @@ export declare const baseConfig: {
11
11
  checked: boolean;
12
12
  noChecked: boolean;
13
13
  };
14
- prefixCls: string;
15
14
  };
package/lib/config.js CHANGED
@@ -12,8 +12,7 @@ var baseConfig = {
12
12
  defaultValueSwitchMap: {
13
13
  checked: true,
14
14
  noChecked: false
15
- },
16
- prefixCls: "hw"
15
+ }
17
16
  };
18
17
 
19
18
  exports.baseConfig = baseConfig;
@@ -2,12 +2,13 @@
2
2
 
3
3
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/concat');
4
4
  var React = require('react');
5
- var config = require('../config.js');
5
+ var configProvider = require('antd/es/config-provider');
6
6
 
7
7
  var useClassName = function useClassName(className) {
8
+ var config = React.useContext(configProvider.ConfigContext);
8
9
  return React.useMemo(function () {
9
10
  var _context;
10
- return _concatInstanceProperty(_context = "".concat(config.baseConfig.prefixCls, "-")).call(_context, className);
11
+ return _concatInstanceProperty(_context = "".concat(config.getPrefixCls(), "-")).call(_context, className);
11
12
  }, [className]);
12
13
  };
13
14
 
package/lib/index.css CHANGED
@@ -1,3 +1,3 @@
1
- .hw-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.3",
3
+ "version": "0.0.5",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,7 +8,7 @@ const autoprefixer = require("autoprefixer");
8
8
  const inject = require("@rollup/plugin-inject");
9
9
  const url = require("@rollup/plugin-url");
10
10
  const pkg = require("../package.json");
11
- const postcss=require("rollup-plugin-postcss");
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");
@@ -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,8 +1,8 @@
1
1
  import type { HSelectProps } from "@/components/Select/modal";
2
2
  import { Checkbox, Space } from "antd";
3
- import "../index.less"
3
+ import "../index.less";
4
4
  import { itemOpProvider } from "../utils";
5
- import {useClassName} from "@/components/hooks/useClassName";
5
+ import { useClassName } from "../../hooks/useClassName";
6
6
  interface IProps extends HSelectProps {
7
7
  checked?: boolean;
8
8
  }
@@ -20,7 +20,7 @@ export default ({
20
20
  }
21
21
  const opLen = options?.length || 0;
22
22
  const checked = (value as any[])?.length >= opLen;
23
- const optionsClassName=useClassName("option");
23
+ const optionsClassName = useClassName("hw-option");
24
24
  const change = () => {
25
25
  if (!checked) {
26
26
  const subItemOps = itemOpProvider(options, fieldNames);
@@ -1,5 +1,5 @@
1
- @import url("../config.less");
2
- .@{hw-prefix}-option {
1
+ @import '../styles/local.less';
2
+ .@{ant-prefix}-hw-option {
3
3
  &:hover {
4
4
  background-color: #f5f5f5;
5
5
  }
@@ -11,5 +11,4 @@ export const baseConfig = {
11
11
  checked: true,
12
12
  noChecked: false,
13
13
  },
14
- prefixCls:"hw"
15
14
  };
@@ -1,8 +1,9 @@
1
- import {useMemo} from "react";
2
- import {baseConfig} from "@/components/config";
1
+ import {useContext, useMemo} from "react";
2
+ import {ConfigContext} from "antd/es/config-provider";
3
3
 
4
- export const useClassName=(className:string)=>{
5
- return useMemo(()=>{
6
- return `${baseConfig.prefixCls}-${className}`
7
- },[className])
8
- }
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
+ @import "../Select/index.less";
@@ -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 +0,0 @@
1
- @hw-prefix: hw;