@jswork/antd-components 1.0.217 → 1.0.219
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/main.cjs.js +1 -1
- package/dist/main.d.mts +49 -22
- package/dist/main.d.ts +49 -22
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/color-picker.tsx +64 -0
- package/src/lib/extra-search.tsx +1 -0
- package/src/main.ts +5 -0
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import noop from '@jswork/noop';
|
|
2
|
+
import { ColorPicker, ColorPickerProps } from 'antd';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
const CLASS_NAME = 'ac-color-picker';
|
|
7
|
+
type StdEventTarget = { target: { value: string } };
|
|
8
|
+
type StdCallback = (inEvent: StdEventTarget) => void;
|
|
9
|
+
|
|
10
|
+
export type AcColorPickerProps = {
|
|
11
|
+
className?: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
onChange?: StdCallback;
|
|
14
|
+
} & Omit<ColorPickerProps, 'value' | 'onChange'>;
|
|
15
|
+
|
|
16
|
+
export class AcColorPicker extends React.Component<AcColorPickerProps> {
|
|
17
|
+
static displayName = CLASS_NAME;
|
|
18
|
+
static formSchema = CLASS_NAME;
|
|
19
|
+
static defaultProps = {
|
|
20
|
+
onChange: noop,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
state = { value: this.props.value };
|
|
24
|
+
|
|
25
|
+
shouldComponentUpdate(inProps: Readonly<AcColorPickerProps>): boolean {
|
|
26
|
+
const { value } = inProps;
|
|
27
|
+
if (value !== this.props.value) this.setState({ value });
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
handleChange = (inColor) => {
|
|
32
|
+
const { onChange } = this.props;
|
|
33
|
+
const value = inColor ? inColor.toHexString() : '';
|
|
34
|
+
const target = { value };
|
|
35
|
+
this.setState({ value });
|
|
36
|
+
onChange!({ target });
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
handleClear = () => {
|
|
40
|
+
const { onChange } = this.props;
|
|
41
|
+
const target = { value: '' };
|
|
42
|
+
this.setState({ value: '' });
|
|
43
|
+
onChange!({ target });
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
render() {
|
|
47
|
+
const { className, value, onChange, onClear, ...props } = this.props;
|
|
48
|
+
const { value: stateValue } = this.state;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<ColorPicker
|
|
52
|
+
className={cx(CLASS_NAME, className)}
|
|
53
|
+
value={stateValue || undefined}
|
|
54
|
+
onChange={this.handleChange}
|
|
55
|
+
onClear={this.handleClear}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const AcColorPickerFc = (props: AcColorPickerProps) => {
|
|
63
|
+
return <AcColorPicker {...props} />;
|
|
64
|
+
};
|
package/src/lib/extra-search.tsx
CHANGED
package/src/main.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { AcCheckableTagList, AcCheckableTagListFc } from './lib/checkable-tag-li
|
|
|
5
5
|
import { AcCheckbox, AcCheckboxFc } from './lib/checkbox';
|
|
6
6
|
import { AcCheckboxGroup, AcCheckboxGroupFc } from './lib/checkbox-group';
|
|
7
7
|
import { AcCodeFlask, AcCodeFlaskFc } from './lib/codeflask';
|
|
8
|
+
import { AcColorPicker, AcColorPickerFc } from './lib/color-picker';
|
|
8
9
|
import { AcConfirmButton } from './lib/confirm-button';
|
|
9
10
|
import { AcDatePicker, AcDatePickerFc } from './lib/date-picker';
|
|
10
11
|
import { AcEditableTagGroup, AcEditableTagGroupFc } from './lib/editable-tag-group';
|
|
@@ -44,6 +45,7 @@ import type { AcCheckableTagProps } from './lib/checkable-tag';
|
|
|
44
45
|
import type { AcCheckableTagListProps } from './lib/checkable-tag-list';
|
|
45
46
|
import type { AcCheckboxProps } from './lib/checkbox';
|
|
46
47
|
import type { AcCheckboxGroupProps } from './lib/checkbox-group';
|
|
48
|
+
import type { AcColorPickerProps } from './lib/color-picker';
|
|
47
49
|
import type { AcConfirmButtonProps } from './lib/confirm-button';
|
|
48
50
|
import type { AcDatePickerProps } from './lib/date-picker';
|
|
49
51
|
import type { AcEditableTagGroupProps } from './lib/editable-tag-group';
|
|
@@ -115,6 +117,9 @@ export {
|
|
|
115
117
|
AcCheckboxProps,
|
|
116
118
|
AcCodeFlask,
|
|
117
119
|
AcCodeFlaskFc,
|
|
120
|
+
AcColorPicker,
|
|
121
|
+
AcColorPickerFc,
|
|
122
|
+
AcColorPickerProps,
|
|
118
123
|
AcConfirmButton,
|
|
119
124
|
AcConfirmButtonProps,
|
|
120
125
|
AcDatePicker,
|