react-science 0.33.0 → 0.34.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/lib/components/color-picker/color-picker-dropdown/ColorPickerDropdown.d.ts +4 -1
- package/lib/components/color-picker/color-picker-dropdown/ColorPickerDropdown.d.ts.map +1 -1
- package/lib/components/color-picker/color-picker-dropdown/ColorPickerDropdown.js +3 -17
- package/lib/components/color-picker/color-picker-dropdown/ColorPickerDropdown.js.map +1 -1
- package/lib-esm/components/color-picker/color-picker-dropdown/ColorPickerDropdown.d.ts +4 -1
- package/lib-esm/components/color-picker/color-picker-dropdown/ColorPickerDropdown.d.ts.map +1 -1
- package/lib-esm/components/color-picker/color-picker-dropdown/ColorPickerDropdown.js +4 -18
- package/lib-esm/components/color-picker/color-picker-dropdown/ColorPickerDropdown.js.map +1 -1
- package/package.json +1 -1
- package/src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx +17 -37
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { PopoverProps } from '@blueprintjs/core';
|
|
1
2
|
import { ColorPickerProps } from '../react-color/ColorPicker';
|
|
2
|
-
|
|
3
|
+
interface ColorPickerDropdownProps extends Pick<ColorPickerProps, 'color' | 'presetColors' | 'disableAlpha' | 'onChange' | 'onChangeComplete'> {
|
|
4
|
+
popoverProps?: Omit<PopoverProps, 'content'>;
|
|
5
|
+
}
|
|
3
6
|
export declare function ColorPickerDropdown(props: ColorPickerDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
4
7
|
export {};
|
|
5
8
|
//# sourceMappingURL=ColorPickerDropdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerDropdown.d.ts","sourceRoot":"","sources":["../../../../src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColorPickerDropdown.d.ts","sourceRoot":"","sources":["../../../../src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI1D,OAAO,EAAe,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG3E,UAAU,wBACR,SAAQ,IAAI,CACV,gBAAgB,EAChB,OAAO,GAAG,cAAc,GAAG,cAAc,GAAG,UAAU,GAAG,kBAAkB,CAC5E;IACD,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;CAC9C;AAiBD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CAmBlE"}
|
|
@@ -28,12 +28,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ColorPickerDropdown = void 0;
|
|
30
30
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
const core_1 = require("@blueprintjs/core");
|
|
31
32
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
32
|
-
const react_1 = require("react");
|
|
33
|
-
const useModifiedPopper_1 = require("../../hooks/useModifiedPopper");
|
|
34
|
-
const useOnClickOutside_1 = require("../../hooks/useOnClickOutside");
|
|
35
|
-
const useOnOff_1 = require("../../hooks/useOnOff");
|
|
36
|
-
const Portal_1 = require("../../root-layout/Portal");
|
|
37
33
|
const FixedColorPreview_1 = __importDefault(require("../preview/FixedColorPreview"));
|
|
38
34
|
const ColorPicker_1 = require("../react-color/ColorPicker");
|
|
39
35
|
const colorHelper = __importStar(require("../react-color/helpers/color"));
|
|
@@ -51,19 +47,9 @@ const ColorPickerPreview = styled_1.default.div `
|
|
|
51
47
|
border-radius: 0.125rem;
|
|
52
48
|
`;
|
|
53
49
|
function ColorPickerDropdown(props) {
|
|
54
|
-
const { color, ...otherProps } = props;
|
|
55
|
-
const ref = (0, react_1.useRef)(null);
|
|
56
|
-
const [isOpened, , close, toggle] = (0, useOnOff_1.useOnOff)(false);
|
|
50
|
+
const { color, popoverProps, ...otherProps } = props;
|
|
57
51
|
const { hex } = colorHelper.toState(color || 'white');
|
|
58
|
-
|
|
59
|
-
placement: 'bottom-start',
|
|
60
|
-
offset: 6,
|
|
61
|
-
});
|
|
62
|
-
(0, useOnClickOutside_1.useOnClickOutside)(ref, close);
|
|
63
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ColorPickerRoot, { type: "button", ref: setReferenceElement, onClick: toggle, children: (0, jsx_runtime_1.jsx)(ColorPickerPreview, { children: (0, jsx_runtime_1.jsx)(FixedColorPreview_1.default, { color: hex }) }) }), isOpened && ((0, jsx_runtime_1.jsx)(Portal_1.Portal, { children: (0, jsx_runtime_1.jsx)("div", { ref: (div) => {
|
|
64
|
-
setPopperElement(div);
|
|
65
|
-
ref.current = div;
|
|
66
|
-
}, ...popperProps, children: (0, jsx_runtime_1.jsx)(ColorPicker_1.ColorPicker, { color: color, ...otherProps }) }) }))] }));
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(core_1.Popover, { targetProps: { style: { width: '100%' } }, content: (0, jsx_runtime_1.jsx)(ColorPicker_1.ColorPicker, { color: color, ...otherProps }), minimal: true, ...popoverProps, children: (0, jsx_runtime_1.jsx)(ColorPickerRoot, { type: "button", children: (0, jsx_runtime_1.jsx)(ColorPickerPreview, { children: (0, jsx_runtime_1.jsx)(FixedColorPreview_1.default, { color: hex }) }) }) }));
|
|
67
53
|
}
|
|
68
54
|
exports.ColorPickerDropdown = ColorPickerDropdown;
|
|
69
55
|
//# sourceMappingURL=ColorPickerDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerDropdown.js","sourceRoot":"","sources":["../../../../src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"ColorPickerDropdown.js","sourceRoot":"","sources":["../../../../src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA0D;AAC1D,6DAAqC;AAErC,qFAA6D;AAC7D,4DAA2E;AAC3E,0EAA4D;AAU5D,MAAM,eAAe,GAAG,gBAAM,CAAC,MAAM,CAAA;;;;;;;CAOpC,CAAC;AAEF,MAAM,kBAAkB,GAAG,gBAAM,CAAC,GAAG,CAAA;;;;CAIpC,CAAC;AAEF,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAErD,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC;IAEtD,OAAO,CACL,uBAAC,cAAO,IACN,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EACzC,OAAO,EAAE,uBAAC,yBAAW,IAAC,KAAK,EAAE,KAAK,KAAM,UAAU,GAAI,EACtD,OAAO,WACH,YAAY,YAEhB,uBAAC,eAAe,IAAC,IAAI,EAAC,QAAQ,YAC5B,uBAAC,kBAAkB,cACjB,uBAAC,2BAAiB,IAAC,KAAK,EAAE,GAAG,GAAI,GACd,GACL,GACV,CACX,CAAC;AACJ,CAAC;AAnBD,kDAmBC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { PopoverProps } from '@blueprintjs/core';
|
|
1
2
|
import { ColorPickerProps } from '../react-color/ColorPicker';
|
|
2
|
-
|
|
3
|
+
interface ColorPickerDropdownProps extends Pick<ColorPickerProps, 'color' | 'presetColors' | 'disableAlpha' | 'onChange' | 'onChangeComplete'> {
|
|
4
|
+
popoverProps?: Omit<PopoverProps, 'content'>;
|
|
5
|
+
}
|
|
3
6
|
export declare function ColorPickerDropdown(props: ColorPickerDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
4
7
|
export {};
|
|
5
8
|
//# sourceMappingURL=ColorPickerDropdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerDropdown.d.ts","sourceRoot":"","sources":["../../../../src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColorPickerDropdown.d.ts","sourceRoot":"","sources":["../../../../src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI1D,OAAO,EAAe,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG3E,UAAU,wBACR,SAAQ,IAAI,CACV,gBAAgB,EAChB,OAAO,GAAG,cAAc,GAAG,cAAc,GAAG,UAAU,GAAG,kBAAkB,CAC5E;IACD,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;CAC9C;AAiBD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CAmBlE"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Popover } from '@blueprintjs/core';
|
|
2
3
|
import styled from '@emotion/styled';
|
|
3
|
-
import { useRef } from 'react';
|
|
4
|
-
import { useModifiedPopper } from '../../hooks/useModifiedPopper';
|
|
5
|
-
import { useOnClickOutside } from '../../hooks/useOnClickOutside';
|
|
6
|
-
import { useOnOff } from '../../hooks/useOnOff';
|
|
7
|
-
import { Portal } from '../../root-layout/Portal';
|
|
8
4
|
import FixedColorPreview from '../preview/FixedColorPreview';
|
|
9
5
|
import { ColorPicker } from '../react-color/ColorPicker';
|
|
10
6
|
import * as colorHelper from '../react-color/helpers/color';
|
|
@@ -22,18 +18,8 @@ const ColorPickerPreview = styled.div `
|
|
|
22
18
|
border-radius: 0.125rem;
|
|
23
19
|
`;
|
|
24
20
|
export function ColorPickerDropdown(props) {
|
|
25
|
-
const { color, ...otherProps } = props;
|
|
26
|
-
const ref = useRef(null);
|
|
27
|
-
const [isOpened, , close, toggle] = useOnOff(false);
|
|
21
|
+
const { color, popoverProps, ...otherProps } = props;
|
|
28
22
|
const { hex } = colorHelper.toState(color || 'white');
|
|
29
|
-
|
|
30
|
-
placement: 'bottom-start',
|
|
31
|
-
offset: 6,
|
|
32
|
-
});
|
|
33
|
-
useOnClickOutside(ref, close);
|
|
34
|
-
return (_jsxs(_Fragment, { children: [_jsx(ColorPickerRoot, { type: "button", ref: setReferenceElement, onClick: toggle, children: _jsx(ColorPickerPreview, { children: _jsx(FixedColorPreview, { color: hex }) }) }), isOpened && (_jsx(Portal, { children: _jsx("div", { ref: (div) => {
|
|
35
|
-
setPopperElement(div);
|
|
36
|
-
ref.current = div;
|
|
37
|
-
}, ...popperProps, children: _jsx(ColorPicker, { color: color, ...otherProps }) }) }))] }));
|
|
23
|
+
return (_jsx(Popover, { targetProps: { style: { width: '100%' } }, content: _jsx(ColorPicker, { color: color, ...otherProps }), minimal: true, ...popoverProps, children: _jsx(ColorPickerRoot, { type: "button", children: _jsx(ColorPickerPreview, { children: _jsx(FixedColorPreview, { color: hex }) }) }) }));
|
|
38
24
|
}
|
|
39
25
|
//# sourceMappingURL=ColorPickerDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerDropdown.js","sourceRoot":"","sources":["../../../../src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ColorPickerDropdown.js","sourceRoot":"","sources":["../../../../src/components/color-picker/color-picker-dropdown/ColorPickerDropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAgB,MAAM,mBAAmB,CAAC;AAC1D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAoB,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC;AAU5D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAA;;;;;;;CAOpC,CAAC;AAEF,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIpC,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAErD,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC;IAEtD,OAAO,CACL,KAAC,OAAO,IACN,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EACzC,OAAO,EAAE,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,KAAM,UAAU,GAAI,EACtD,OAAO,WACH,YAAY,YAEhB,KAAC,eAAe,IAAC,IAAI,EAAC,QAAQ,YAC5B,KAAC,kBAAkB,cACjB,KAAC,iBAAiB,IAAC,KAAK,EAAE,GAAG,GAAI,GACd,GACL,GACV,CACX,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import { Popover, PopoverProps } from '@blueprintjs/core';
|
|
1
2
|
import styled from '@emotion/styled';
|
|
2
|
-
import { useRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import { useModifiedPopper } from '../../hooks/useModifiedPopper';
|
|
5
|
-
import { useOnClickOutside } from '../../hooks/useOnClickOutside';
|
|
6
|
-
import { useOnOff } from '../../hooks/useOnOff';
|
|
7
|
-
import { Portal } from '../../root-layout/Portal';
|
|
8
4
|
import FixedColorPreview from '../preview/FixedColorPreview';
|
|
9
5
|
import { ColorPicker, ColorPickerProps } from '../react-color/ColorPicker';
|
|
10
6
|
import * as colorHelper from '../react-color/helpers/color';
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
interface ColorPickerDropdownProps
|
|
9
|
+
extends Pick<
|
|
10
|
+
ColorPickerProps,
|
|
11
|
+
'color' | 'presetColors' | 'disableAlpha' | 'onChange' | 'onChangeComplete'
|
|
12
|
+
> {
|
|
13
|
+
popoverProps?: Omit<PopoverProps, 'content'>;
|
|
14
|
+
}
|
|
16
15
|
|
|
17
16
|
const ColorPickerRoot = styled.button`
|
|
18
17
|
position: relative;
|
|
@@ -30,41 +29,22 @@ const ColorPickerPreview = styled.div`
|
|
|
30
29
|
`;
|
|
31
30
|
|
|
32
31
|
export function ColorPickerDropdown(props: ColorPickerDropdownProps) {
|
|
33
|
-
const { color, ...otherProps } = props;
|
|
34
|
-
|
|
35
|
-
const ref = useRef<HTMLDivElement | null>(null);
|
|
36
|
-
const [isOpened, , close, toggle] = useOnOff(false);
|
|
32
|
+
const { color, popoverProps, ...otherProps } = props;
|
|
37
33
|
|
|
38
34
|
const { hex } = colorHelper.toState(color || 'white');
|
|
39
35
|
|
|
40
|
-
const { setReferenceElement, setPopperElement, popperProps } =
|
|
41
|
-
useModifiedPopper<HTMLButtonElement>({
|
|
42
|
-
placement: 'bottom-start',
|
|
43
|
-
offset: 6,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
useOnClickOutside(ref, close);
|
|
47
|
-
|
|
48
36
|
return (
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
<Popover
|
|
38
|
+
targetProps={{ style: { width: '100%' } }}
|
|
39
|
+
content={<ColorPicker color={color} {...otherProps} />}
|
|
40
|
+
minimal
|
|
41
|
+
{...popoverProps}
|
|
42
|
+
>
|
|
43
|
+
<ColorPickerRoot type="button">
|
|
51
44
|
<ColorPickerPreview>
|
|
52
45
|
<FixedColorPreview color={hex} />
|
|
53
46
|
</ColorPickerPreview>
|
|
54
47
|
</ColorPickerRoot>
|
|
55
|
-
|
|
56
|
-
<Portal>
|
|
57
|
-
<div
|
|
58
|
-
ref={(div) => {
|
|
59
|
-
setPopperElement(div);
|
|
60
|
-
ref.current = div;
|
|
61
|
-
}}
|
|
62
|
-
{...popperProps}
|
|
63
|
-
>
|
|
64
|
-
<ColorPicker color={color} {...otherProps} />
|
|
65
|
-
</div>
|
|
66
|
-
</Portal>
|
|
67
|
-
)}
|
|
68
|
-
</>
|
|
48
|
+
</Popover>
|
|
69
49
|
);
|
|
70
50
|
}
|