@comet/admin-color-picker 8.0.0-canary-20240731111743 → 8.0.0-canary-20240920091107
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/ColorField.d.ts +2 -2
- package/lib/ColorField.d.ts.map +1 -1
- package/lib/ColorField.js +7 -4
- package/lib/ColorPicker.d.ts +8 -8
- package/lib/ColorPicker.d.ts.map +1 -1
- package/lib/ColorPicker.js +92 -61
- package/lib/FinalFormColorPicker.d.ts +2 -2
- package/lib/FinalFormColorPicker.d.ts.map +1 -1
- package/lib/FinalFormColorPicker.js +7 -5
- package/lib/index.d.ts +9 -1
- package/lib/index.d.ts.map +1 -1
- package/package.json +5 -5
package/lib/ColorField.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
+
/// <reference types="react" />
|
1
2
|
import { FieldProps } from "@comet/admin";
|
2
|
-
import * as React from "react";
|
3
3
|
export type ColorFieldProps = FieldProps<string, HTMLInputElement>;
|
4
|
-
export declare const ColorField: ({ ...restProps }: ColorFieldProps) =>
|
4
|
+
export declare const ColorField: ({ ...restProps }: ColorFieldProps) => JSX.Element;
|
5
5
|
//# sourceMappingURL=ColorField.d.ts.map
|
package/lib/ColorField.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ColorField.d.ts","sourceRoot":"","sources":["../src/ColorField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"ColorField.d.ts","sourceRoot":"","sources":["../src/ColorField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAS,UAAU,EAAE,MAAM,cAAc,CAAC;AAIjD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAEnE,eAAO,MAAM,UAAU,qBAAsB,eAAe,gBAE3D,CAAC"}
|
package/lib/ColorField.js
CHANGED
@@ -6,15 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.ColorField = void 0;
|
8
8
|
var _admin = require("@comet/admin");
|
9
|
-
var React = _interopRequireWildcard(require("react"));
|
10
9
|
var _FinalFormColorPicker = require("./FinalFormColorPicker");
|
11
|
-
|
12
|
-
function
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
15
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
13
16
|
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
|
14
17
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
15
18
|
var ColorField = function ColorField(_ref) {
|
16
19
|
var restProps = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
17
|
-
return /*#__PURE__*/
|
20
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_admin.Field, _objectSpread({
|
18
21
|
component: _FinalFormColorPicker.FinalFormColorPicker
|
19
22
|
}, restProps));
|
20
23
|
};
|
package/lib/ColorPicker.d.ts
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
import { InputWithPopperComponents, InputWithPopperProps } from "@comet/admin";
|
2
2
|
import { ComponentsOverrides, InputBaseProps } from "@mui/material";
|
3
3
|
import { Theme } from "@mui/material/styles";
|
4
|
-
import
|
4
|
+
import { ComponentType, HTMLAttributes, ReactNode } from "react";
|
5
5
|
import { ColorPickerClassKey, PreviewIndicatorColorProps, PreviewIndicatorEmptyOrInvalidProps, SlotProps } from "./ColorPicker.slots";
|
6
|
-
export interface ColorPickerColorPreviewProps extends Omit<
|
6
|
+
export interface ColorPickerColorPreviewProps extends Omit<HTMLAttributes<HTMLDivElement>, "color">, PreviewIndicatorColorProps {
|
7
7
|
}
|
8
|
-
export interface ColorPickerNoColorPreviewProps extends
|
8
|
+
export interface ColorPickerNoColorPreviewProps extends HTMLAttributes<HTMLDivElement>, PreviewIndicatorEmptyOrInvalidProps {
|
9
9
|
}
|
10
10
|
export interface ColorPickerPropsComponents extends InputWithPopperComponents {
|
11
|
-
ColorPickerColorPreview?:
|
12
|
-
ColorPickerInvalidPreview?:
|
13
|
-
ColorPickerEmptyPreview?:
|
11
|
+
ColorPickerColorPreview?: ComponentType<ColorPickerColorPreviewProps>;
|
12
|
+
ColorPickerInvalidPreview?: ComponentType<ColorPickerNoColorPreviewProps>;
|
13
|
+
ColorPickerEmptyPreview?: ComponentType<ColorPickerNoColorPreviewProps>;
|
14
14
|
}
|
15
15
|
export interface ColorPickerProps extends Omit<InputWithPopperProps, "children" | "onChange" | "value" | "components" | "slotProps"> {
|
16
16
|
value?: string | null;
|
@@ -25,8 +25,8 @@ export interface ColorPickerProps extends Omit<InputWithPopperProps, "children"
|
|
25
25
|
endAdornment?: InputBaseProps["endAdornment"];
|
26
26
|
invalidIndicatorCharacter?: string;
|
27
27
|
required?: boolean;
|
28
|
-
titleText?:
|
29
|
-
clearButtonText?:
|
28
|
+
titleText?: ReactNode;
|
29
|
+
clearButtonText?: ReactNode;
|
30
30
|
components?: ColorPickerPropsComponents;
|
31
31
|
slotProps?: SlotProps;
|
32
32
|
}
|
package/lib/ColorPicker.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../src/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpG,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,KAAK,EAAiB,MAAM,sBAAsB,CAAC;AAC5D,OAAO,
|
1
|
+
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../src/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpG,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,KAAK,EAAiB,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAe,aAAa,EAAc,cAAc,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAK/G,OAAO,EAGH,mBAAmB,EAYnB,0BAA0B,EAC1B,mCAAmC,EAGnC,SAAS,EACZ,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,EAAE,0BAA0B;CAAG;AAClI,MAAM,WAAW,8BAA+B,SAAQ,cAAc,CAAC,cAAc,CAAC,EAAE,mCAAmC;CAAG;AAE9H,MAAM,WAAW,0BAA2B,SAAQ,yBAAyB;IACzE,uBAAuB,CAAC,EAAE,aAAa,CAAC,4BAA4B,CAAC,CAAC;IACtE,yBAAyB,CAAC,EAAE,aAAa,CAAC,8BAA8B,CAAC,CAAC;IAC1E,uBAAuB,CAAC,EAAE,aAAa,CAAC,8BAA8B,CAAC,CAAC;CAC3E;AAUD,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,YAAY,GAAG,WAAW,CAAC;IAChI,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAClD,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC9C,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,YAAa,gBAAgB,gBAoKpD,CAAC;AAEF,OAAO,QAAQ,sBAAsB,CAAC;IAClC,UAAU,uBAAuB;QAC7B,qBAAqB,EAAE,mBAAmB,CAAC;KAC9C;IAED,UAAU,mBAAmB;QACzB,qBAAqB,EAAE,gBAAgB,CAAC;KAC3C;IAED,UAAU,UAAU;QAChB,qBAAqB,CAAC,EAAE;YACpB,YAAY,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,CAAC,CAAC;YACrE,cAAc,CAAC,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,CAAC;SACxE,CAAC;KACL;CACJ"}
|
package/lib/ColorPicker.js
CHANGED
@@ -9,17 +9,20 @@ var _admin = require("@comet/admin");
|
|
9
9
|
var _adminIcons = require("@comet/admin-icons");
|
10
10
|
var _material = require("@mui/material");
|
11
11
|
var _styles = require("@mui/material/styles");
|
12
|
-
var
|
12
|
+
var _react = require("react");
|
13
13
|
var _reactIntl = require("react-intl");
|
14
14
|
var _tinycolor = _interopRequireDefault(require("tinycolor2"));
|
15
15
|
var _useDebounce = require("use-debounce");
|
16
16
|
var _ColorPicker = require("./ColorPicker.slots");
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
17
18
|
var _excluded = ["classes", "value", "colorFormat", "hidePicker", "hideHeader", "hideFooter", "colorPalette", "onChange", "startAdornment", "endAdornment", "onBlur", "required", "titleText", "clearButtonText", "components", "slotProps"],
|
18
19
|
_excluded2 = ["ColorPickerColorPreview", "ColorPickerInvalidPreview", "ColorPickerEmptyPreview"];
|
19
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
20
|
-
function
|
21
|
-
function
|
22
|
-
function
|
21
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
23
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
24
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
25
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
23
26
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
24
27
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
25
28
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
@@ -31,7 +34,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
31
34
|
var DefaultColorPreviewIndicator = function DefaultColorPreviewIndicator(_ref) {
|
32
35
|
var type = _ref.type,
|
33
36
|
color = _ref.color;
|
34
|
-
return /*#__PURE__*/
|
37
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.PreviewIndicator, {
|
35
38
|
ownerState: {
|
36
39
|
type: type,
|
37
40
|
color: color
|
@@ -40,7 +43,7 @@ var DefaultColorPreviewIndicator = function DefaultColorPreviewIndicator(_ref) {
|
|
40
43
|
};
|
41
44
|
var DefaultNoColorPreviewIndicator = function DefaultNoColorPreviewIndicator(_ref2) {
|
42
45
|
var type = _ref2.type;
|
43
|
-
return /*#__PURE__*/
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.PreviewIndicator, {
|
44
47
|
ownerState: {
|
45
48
|
type: type
|
46
49
|
}
|
@@ -65,12 +68,12 @@ var ColorPicker = function ColorPicker(inProps) {
|
|
65
68
|
_onBlur = _useThemeProps.onBlur,
|
66
69
|
required = _useThemeProps.required,
|
67
70
|
_useThemeProps$titleT = _useThemeProps.titleText,
|
68
|
-
titleText = _useThemeProps$titleT === void 0 ? /*#__PURE__*/
|
71
|
+
titleText = _useThemeProps$titleT === void 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
69
72
|
id: "comet.colorPicker.title",
|
70
73
|
defaultMessage: "Choose a color"
|
71
74
|
}) : _useThemeProps$titleT,
|
72
75
|
_useThemeProps$clearB = _useThemeProps.clearButtonText,
|
73
|
-
clearButtonText = _useThemeProps$clearB === void 0 ? /*#__PURE__*/
|
76
|
+
clearButtonText = _useThemeProps$clearB === void 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
74
77
|
id: "comet.colorPicker.clearButton",
|
75
78
|
defaultMessage: "clear color"
|
76
79
|
}) : _useThemeProps$clearB,
|
@@ -85,12 +88,12 @@ var ColorPicker = function ColorPicker(inProps) {
|
|
85
88
|
_components$ColorPick3 = components.ColorPickerEmptyPreview,
|
86
89
|
EmptyPreview = _components$ColorPick3 === void 0 ? DefaultNoColorPreviewIndicator : _components$ColorPick3,
|
87
90
|
inputWithPopperComponents = _objectWithoutProperties(components, _excluded2);
|
88
|
-
var
|
89
|
-
|
90
|
-
displayValue =
|
91
|
-
setDisplayValue =
|
91
|
+
var _useState = (0, _react.useState)(value !== null && value !== void 0 ? value : ""),
|
92
|
+
_useState2 = _slicedToArray(_useState, 2),
|
93
|
+
displayValue = _useState2[0],
|
94
|
+
setDisplayValue = _useState2[1];
|
92
95
|
var previewColor = displayValue ? (0, _tinycolor["default"])(displayValue) : null;
|
93
|
-
|
96
|
+
(0, _react.useEffect)(function () {
|
94
97
|
setDisplayValue(value !== null && value !== void 0 ? value : "");
|
95
98
|
}, [value, setDisplayValue]);
|
96
99
|
|
@@ -112,26 +115,34 @@ var ColorPicker = function ColorPicker(inProps) {
|
|
112
115
|
setDisplayValue("");
|
113
116
|
}
|
114
117
|
};
|
115
|
-
return /*#__PURE__*/
|
118
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.Root, _objectSpread(_objectSpread(_objectSpread({
|
116
119
|
required: required,
|
117
|
-
startAdornment: startAdornment ? startAdornment : /*#__PURE__*/
|
120
|
+
startAdornment: startAdornment ? startAdornment : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.InputAdornment, _objectSpread(_objectSpread({
|
118
121
|
position: "start",
|
119
122
|
disablePointerEvents: true
|
120
|
-
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputAdornment),
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
123
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputAdornment), {}, {
|
124
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.Preview, {
|
125
|
+
children: previewColor ? previewColor.isValid() ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorPreview, _objectSpread(_objectSpread({
|
126
|
+
type: "color",
|
127
|
+
color: previewColor.toRgbString()
|
128
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.previewIndicator), slotProps === null || slotProps === void 0 ? void 0 : slotProps.previewIndicatorColor)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(InvalidPreview, _objectSpread(_objectSpread(_objectSpread({
|
129
|
+
type: "invalid"
|
130
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.previewIndicator), slotProps === null || slotProps === void 0 ? void 0 : slotProps.previewIndicatorInvalid), {}, {
|
131
|
+
children: "?"
|
132
|
+
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)(EmptyPreview, _objectSpread(_objectSpread({
|
133
|
+
type: "empty"
|
134
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.previewIndicator), slotProps === null || slotProps === void 0 ? void 0 : slotProps.previewIndicatorEmpty))
|
135
|
+
})
|
136
|
+
})),
|
137
|
+
endAdornment: !required ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
138
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_admin.ClearInputAdornment, {
|
139
|
+
position: "end",
|
140
|
+
hasClearableContent: Boolean(value),
|
141
|
+
onClick: function onClick() {
|
142
|
+
return onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
143
|
+
}
|
144
|
+
}), endAdornment]
|
145
|
+
}) : endAdornment,
|
135
146
|
value: displayValue,
|
136
147
|
onChange: function onChange(e) {
|
137
148
|
setDisplayValue(e.currentTarget.value);
|
@@ -141,36 +152,56 @@ var ColorPicker = function ColorPicker(inProps) {
|
|
141
152
|
onChangeColor(displayValue);
|
142
153
|
},
|
143
154
|
components: inputWithPopperComponents
|
144
|
-
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.root, restProps),
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
155
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.root), restProps), {}, {
|
156
|
+
children: function children(closePopper) {
|
157
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ColorPicker.PopperRoot, _objectSpread(_objectSpread({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.popperRoot), {}, {
|
158
|
+
children: [!hideHeader && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ColorPicker.Header, _objectSpread(_objectSpread({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.header), {}, {
|
159
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.HeaderTitleText, _objectSpread(_objectSpread({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.headerTitleText), {}, {
|
160
|
+
children: titleText
|
161
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.HeaderCloseButton, _objectSpread(_objectSpread({
|
162
|
+
onClick: function onClick() {
|
163
|
+
return closePopper(true);
|
164
|
+
}
|
165
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.headerCloseButton), {}, {
|
166
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminIcons.Close, {})
|
167
|
+
}))]
|
168
|
+
})), !hidePicker && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ColorPicker.ColorPickerWrapper, _objectSpread(_objectSpread({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.colorPickerWrapper), {}, {
|
169
|
+
children: [colorFormat === "hex" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.HexColorPicker, _objectSpread({
|
170
|
+
color: value !== null && value !== void 0 ? value : "",
|
171
|
+
onChange: onChangeColor
|
172
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.hexColorPicker)), colorFormat === "rgba" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.RgbaStringColorPicker, _objectSpread({
|
173
|
+
color: value !== null && value !== void 0 ? value : "",
|
174
|
+
onChange: onChangeColor
|
175
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rgbaStringColorPicker))]
|
176
|
+
})), (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.ColorPalette, _objectSpread(_objectSpread({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.colorPalette), {}, {
|
177
|
+
children: colorPalette.map(function (color, index) {
|
178
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.ColorPaletteItem, _objectSpread({
|
179
|
+
onClick: function onClick() {
|
180
|
+
onChangeColor(color);
|
181
|
+
closePopper(true);
|
182
|
+
},
|
183
|
+
ownerState: {
|
184
|
+
colorValue: color
|
185
|
+
}
|
186
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.colorPaletteItem), "".concat(index, "_").concat(color));
|
187
|
+
})
|
188
|
+
})), !hideFooter && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.Footer, _objectSpread(_objectSpread({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.footer), {}, {
|
189
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ColorPicker.FooterClearButton, _objectSpread(_objectSpread({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.footerClearButton), {}, {
|
190
|
+
onClick: function onClick() {
|
191
|
+
onChangeColor("");
|
192
|
+
closePopper(true);
|
193
|
+
},
|
194
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.Preview, _objectSpread(_objectSpread({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.preview), {}, {
|
195
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(EmptyPreview, _objectSpread(_objectSpread({
|
196
|
+
type: "empty"
|
197
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.previewIndicator), slotProps === null || slotProps === void 0 ? void 0 : slotProps.previewIndicatorEmpty))
|
198
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
199
|
+
children: clearButtonText
|
200
|
+
})]
|
201
|
+
}))
|
202
|
+
}))]
|
203
|
+
}));
|
204
|
+
}
|
205
|
+
}));
|
175
206
|
};
|
176
207
|
exports.ColorPicker = ColorPicker;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
/// <reference types="react" />
|
2
2
|
import { FieldRenderProps } from "react-final-form";
|
3
3
|
import { ColorPickerProps } from "./ColorPicker";
|
4
4
|
export type FinalFormColorPickerProps = ColorPickerProps & FieldRenderProps<string, HTMLInputElement | HTMLTextAreaElement>;
|
5
|
-
export declare const FinalFormColorPicker: ({ meta, input, ...restProps }: FinalFormColorPickerProps) =>
|
5
|
+
export declare const FinalFormColorPicker: ({ meta, input, ...restProps }: FinalFormColorPickerProps) => JSX.Element;
|
6
6
|
//# sourceMappingURL=FinalFormColorPicker.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FinalFormColorPicker.d.ts","sourceRoot":"","sources":["../src/FinalFormColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"FinalFormColorPicker.d.ts","sourceRoot":"","sources":["../src/FinalFormColorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,MAAM,yBAAyB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,mBAAmB,CAAC,CAAC;AAE5H,eAAO,MAAM,oBAAoB,kCAAmC,yBAAyB,gBAE5F,CAAC"}
|
@@ -5,18 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
6
6
|
});
|
7
7
|
exports.FinalFormColorPicker = void 0;
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
9
8
|
var _ColorPicker = require("./ColorPicker");
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
10
10
|
var _excluded = ["meta", "input"];
|
11
|
-
function
|
12
|
-
function
|
13
|
-
function
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
15
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
14
16
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
15
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
16
18
|
var FinalFormColorPicker = function FinalFormColorPicker(_ref) {
|
17
19
|
var meta = _ref.meta,
|
18
20
|
input = _ref.input,
|
19
21
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
20
|
-
return /*#__PURE__*/
|
22
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorPicker.ColorPicker, _objectSpread(_objectSpread({}, input), restProps));
|
21
23
|
};
|
22
24
|
exports.FinalFormColorPicker = FinalFormColorPicker;
|
package/lib/index.d.ts
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
export { ColorField, ColorFieldProps } from "./ColorField";
|
2
2
|
export { ColorPicker, ColorPickerColorPreviewProps, ColorPickerProps, ColorPickerPropsComponents } from "./ColorPicker";
|
3
3
|
export { ColorPickerClassKey } from "./ColorPicker.slots";
|
4
|
-
export {
|
4
|
+
export {
|
5
|
+
/**
|
6
|
+
* @deprecated Use `<ColorField />` instead of `<Field component={FinalFormColorPicker} />`
|
7
|
+
*/
|
8
|
+
FinalFormColorPicker,
|
9
|
+
/**
|
10
|
+
* @deprecated Use `<ColorField />` instead of `<Field component={FinalFormColorPicker} />`
|
11
|
+
*/
|
12
|
+
FinalFormColorPickerProps, } from "./FinalFormColorPicker";
|
5
13
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO;AACH;;GAEG;AACH,oBAAoB;AACpB;;GAEG;AACH,yBAAyB,GAC5B,MAAM,wBAAwB,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@comet/admin-color-picker",
|
3
|
-
"version": "8.0.0-canary-
|
3
|
+
"version": "8.0.0-canary-20240920091107",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://github.com/vivid-planet/comet",
|
@@ -13,8 +13,8 @@
|
|
13
13
|
"lib"
|
14
14
|
],
|
15
15
|
"dependencies": {
|
16
|
-
"@comet/admin": "8.0.0-canary-
|
17
|
-
"@comet/admin-icons": "8.0.0-canary-
|
16
|
+
"@comet/admin": "8.0.0-canary-20240920091107",
|
17
|
+
"@comet/admin-icons": "8.0.0-canary-20240920091107",
|
18
18
|
"clsx": "^1.1.1",
|
19
19
|
"react-colorful": "^5.5.1",
|
20
20
|
"tinycolor2": "^1.4.1",
|
@@ -23,8 +23,8 @@
|
|
23
23
|
"devDependencies": {
|
24
24
|
"@babel/cli": "^7.17.6",
|
25
25
|
"@babel/core": "^7.20.12",
|
26
|
-
"@comet/admin-babel-preset": "8.0.0-canary-
|
27
|
-
"@comet/eslint-config": "8.0.0-canary-
|
26
|
+
"@comet/admin-babel-preset": "8.0.0-canary-20240920091107",
|
27
|
+
"@comet/eslint-config": "8.0.0-canary-20240920091107",
|
28
28
|
"@mui/material": "^5.0.0",
|
29
29
|
"@types/react": "^17.0.0",
|
30
30
|
"@types/react-dom": "^17.0.0",
|