@comet/admin-react-select 6.12.1-canary-20240605133817 → 7.0.0-beta.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.
@@ -1,21 +1,19 @@
1
1
  import { SvgIconComponent } from "@mui/icons-material";
2
- import { ComponentsOverrides, InputBaseProps, Theme } from "@mui/material";
2
+ import { ComponentsOverrides, Theme } from "@mui/material";
3
3
  import * as React from "react";
4
4
  import { OptionTypeBase } from "react-select";
5
5
  import { Props as ReactSelectAsyncProps } from "react-select/async";
6
6
  import { Props as ReactSelectProps } from "react-select/base";
7
7
  import { Props as ReactSelectCreatableProps } from "react-select/creatable";
8
- import { SelectClassKey } from "./ReactSelect.styles";
9
- export declare const ControlInput: ({ ...props }: InputBaseProps) => JSX.Element;
10
- export interface SelectProps<OptionType extends OptionTypeBase> {
11
- theme: Theme;
12
- selectComponent: React.ComponentType<ReactSelectProps<OptionType>>;
8
+ export type SelectClassKey = "input" | "valueContainer" | "chip" | "chipFocused" | "noOptionsMessage" | "singleValue" | "placeholder" | "paper" | "indicatorsContainer" | "indicatorSeparator" | "clearIndicator" | "indicator" | "dropdownIndicator" | "option" | "optionSelected" | "optionFocused";
9
+ export interface SelectProps<OptionType extends OptionTypeBase, IsMulti extends boolean = false> {
10
+ selectComponent: React.ComponentType<ReactSelectProps<OptionType, IsMulti>>;
13
11
  clearIcon?: SvgIconComponent;
14
12
  dropdownIcon?: SvgIconComponent;
15
13
  dropdownIconOpen?: SvgIconComponent;
16
14
  }
17
15
  export declare function ReactSelect<OptionType extends OptionTypeBase>(props: ReactSelectProps<OptionType>): JSX.Element;
18
- export declare function ReactSelectAsync<OptionType extends OptionTypeBase, IsMulti extends boolean>(props: ReactSelectAsyncProps<OptionType, IsMulti>): JSX.Element;
16
+ export declare function ReactSelectAsync<OptionType extends OptionTypeBase, IsMulti extends boolean = false>(props: ReactSelectAsyncProps<OptionType, IsMulti>): JSX.Element;
19
17
  export declare function ReactSelectCreatable<OptionType extends OptionTypeBase, IsMulti extends boolean>(props: ReactSelectCreatableProps<OptionType, IsMulti>): JSX.Element;
20
18
  export declare function ReactSelectAsyncCreatable<OptionType extends OptionTypeBase, IsMulti extends boolean>(props: ReactSelectCreatableProps<OptionType, IsMulti> & ReactSelectAsyncProps<OptionType, IsMulti>): JSX.Element;
21
19
  declare module "@mui/material/styles" {
@@ -27,7 +25,7 @@ declare module "@mui/material/styles" {
27
25
  }
28
26
  interface Components {
29
27
  CometAdminSelect?: {
30
- defaultProps?: ComponentsPropsList["CometAdminSelect"];
28
+ defaultProps?: Partial<ComponentsPropsList["CometAdminSelect"]>;
31
29
  styleOverrides?: ComponentsOverrides<Theme>["CometAdminSelect"];
32
30
  };
33
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReactSelect.d.ts","sourceRoot":"","sources":["../src/ReactSelect.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,OAAO,EAAQ,mBAAmB,EAAa,cAAc,EAAmB,KAAK,EAAwB,MAAM,eAAe,CAAC;AAGnI,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACtD,OAAoB,EAAE,KAAK,IAAI,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAwB,EAAE,KAAK,IAAI,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAU7F,OAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAc9D,eAAO,MAAM,YAAY,iBAAkB,cAAc,gBAA4E,CAAC;AA0HtI,MAAM,WAAW,WAAW,CAAC,UAAU,SAAS,cAAc;IAC1D,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,UAAU,CAAC,CA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BAAgB,yBAAyB,CAAC,UAAU,SAAS,cAAc,EAAE,OAAO,SAAS,OAAO,EAChG,KAAK,EAAE,yBAAyB,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,qBAAqB,CAAC,UAAU,EAAE,OAAO,CAAC,eAGrG;AAED,OAAO,QAAQ,sBAAsB,CAAC;IAClC,UAAU,uBAAuB;QAC7B,gBAAgB,EAAE,cAAc,CAAC;KACpC;IAED,UAAU,mBAAmB;QACzB,gBAAgB,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;KACtC;IAED,UAAU,UAAU;QAChB,gBAAgB,CAAC,EAAE;YACf,YAAY,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAChE,cAAc,CAAC,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAAC;SACnE,CAAC;KACL;CACJ"}
@@ -4,25 +4,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.ControlInput = void 0;
8
7
  exports.ReactSelect = ReactSelect;
9
8
  exports.ReactSelectAsync = ReactSelectAsync;
10
9
  exports.ReactSelectAsyncCreatable = ReactSelectAsyncCreatable;
11
10
  exports.ReactSelectCreatable = ReactSelectCreatable;
11
+ var _admin = require("@comet/admin");
12
12
  var _Cancel = _interopRequireDefault(require("@mui/icons-material/Cancel"));
13
13
  var _Clear = _interopRequireDefault(require("@mui/icons-material/Clear"));
14
14
  var _KeyboardArrowDown = _interopRequireDefault(require("@mui/icons-material/KeyboardArrowDown"));
15
15
  var _material = require("@mui/material");
16
- var _styles = require("@mui/styles");
17
- var _classnames = _interopRequireDefault(require("classnames"));
16
+ var _styles = require("@mui/material/styles");
18
17
  var React = _interopRequireWildcard(require("react"));
19
18
  var _reactSelect = _interopRequireDefault(require("react-select"));
20
19
  var _async = _interopRequireDefault(require("react-select/async"));
21
20
  var _asyncCreatable = _interopRequireDefault(require("react-select/async-creatable"));
22
21
  var _creatable = _interopRequireDefault(require("react-select/creatable"));
23
- var _ReactSelect = _interopRequireDefault(require("./ReactSelect.styles"));
24
22
  var _excluded = ["inputRef"],
25
- _excluded2 = ["classes", "theme", "components", "selectComponent"];
23
+ _excluded2 = ["components", "selectComponent"];
24
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14;
26
25
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
26
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -31,37 +30,35 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
31
30
  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; }
32
31
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
33
32
  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); }
34
- function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
33
+ 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); }
35
34
  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; }
36
35
  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; }
37
- 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); }
36
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
37
+ var NoOptionsMessageText = (0, _admin.createComponentSlot)(_material.Typography)({
38
+ componentName: "Select",
39
+ slotName: "noOptionsMessage"
40
+ })(function (_ref) {
41
+ var theme = _ref.theme;
42
+ return (0, _styles.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: ", " ", ";\n color: ", ";\n "])), theme.spacing(1), theme.spacing(2), theme.palette.text.secondary);
43
+ });
38
44
  function NoOptionsMessage(props) {
39
- return /*#__PURE__*/React.createElement(_material.Typography, _extends({
40
- className: props.selectProps.classes.noOptionsMessage
41
- }, props.innerProps), props.children);
45
+ return /*#__PURE__*/React.createElement(NoOptionsMessageText, props.innerProps, props.children);
42
46
  }
43
- function inputComponent(_ref) {
44
- var inputRef = _ref.inputRef,
45
- props = _objectWithoutProperties(_ref, _excluded);
47
+ function inputComponent(_ref2) {
48
+ var inputRef = _ref2.inputRef,
49
+ props = _objectWithoutProperties(_ref2, _excluded);
46
50
  return /*#__PURE__*/React.createElement("div", _extends({
47
51
  ref: inputRef
48
52
  }, props));
49
53
  }
50
- var ControlInput = function ControlInput(_ref2) {
51
- var props = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2));
52
- return /*#__PURE__*/React.createElement(_material.InputBase, _extends({
53
- classes: {
54
- root: "root",
55
- focused: "focused"
56
- }
57
- }, props));
58
- };
59
- exports.ControlInput = ControlInput;
54
+ var ControlInput = (0, _admin.createComponentSlot)(_material.InputBase)({
55
+ componentName: "Select",
56
+ slotName: "input"
57
+ })((0, _styles.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " {\n display: flex;\n padding-right: 0;\n }\n"])), _material.inputBaseClasses.input));
60
58
  function Control(props) {
61
59
  var InputProps = {
62
60
  inputComponent: inputComponent,
63
61
  inputProps: _objectSpread({
64
- className: props.selectProps.classes.input,
65
62
  inputRef: props.innerRef,
66
63
  children: props.children
67
64
  }, props.innerProps)
@@ -71,79 +68,138 @@ function Control(props) {
71
68
  fullWidth: true
72
69
  }, InputProps, props.selectProps.textFieldProps));
73
70
  }
71
+ var OptionMenuItem = (0, _admin.createComponentSlot)(_material.MenuItem)({
72
+ componentName: "Select",
73
+ slotName: "option",
74
+ classesResolver: function classesResolver(ownerState) {
75
+ return [ownerState.focused && "optionFocused", ownerState.selected && "optionSelected"];
76
+ }
77
+ })(function (_ref3) {
78
+ var theme = _ref3.theme,
79
+ ownerState = _ref3.ownerState;
80
+ return (0, _styles.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n\n ", "\n "])), ownerState.selected && (0, _styles.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-weight: ", ";\n "])), theme.typography.fontWeightMedium), ownerState.focused && (0, _styles.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), theme.palette.action.selected));
81
+ });
74
82
  function Option(props) {
75
- var rootClasses = [props.selectProps.classes.option];
76
- if (props.isFocused) rootClasses.push(props.selectProps.classes.optionFocused);
77
- if (props.isSelected) rootClasses.push(props.selectProps.classes.optionSelected);
78
- return /*#__PURE__*/React.createElement(_material.MenuItem, _extends({
79
- classes: {
80
- root: rootClasses.join(" ")
81
- },
83
+ return /*#__PURE__*/React.createElement(OptionMenuItem, _extends({
82
84
  ref: props.innerRef,
83
85
  selected: props.isSelected,
84
- disabled: props.isDisabled,
86
+ ownerState: {
87
+ focused: props.isFocused,
88
+ selected: props.isSelected
89
+ },
90
+ disabled: props.isDisabled
91
+ // @ts-expect-error The type is not correctly passed through to `MenuItem` when using `styled()`, see: https://mui.com/material-ui/guides/typescript/#complications-with-the-component-prop
92
+ ,
85
93
  component: "div"
86
94
  }, props.innerProps), props.children);
87
95
  }
96
+ var PlaceholderSlot = (0, _admin.createComponentSlot)("div")({
97
+ componentName: "Select",
98
+ slotName: "placeholder"
99
+ })(function (_ref4) {
100
+ var theme = _ref4.theme;
101
+ return (0, _styles.css)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n color: ", ";\n "])), theme.palette.text.disabled);
102
+ });
88
103
  function Placeholder(props) {
89
- return /*#__PURE__*/React.createElement("div", _extends({
90
- className: props.selectProps.classes.placeholder
91
- }, props.innerProps), props.children);
104
+ return /*#__PURE__*/React.createElement(PlaceholderSlot, props.innerProps, props.children);
92
105
  }
106
+ var SingleValueSlot = (0, _admin.createComponentSlot)("div")({
107
+ componentName: "Select",
108
+ slotName: "singleValue"
109
+ })((0, _styles.css)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n"]))));
93
110
  function SingleValue(props) {
94
- return /*#__PURE__*/React.createElement("div", _extends({
95
- className: props.selectProps.classes.singleValue
96
- }, props.innerProps), props.children);
111
+ return /*#__PURE__*/React.createElement(SingleValueSlot, props.innerProps, props.children);
97
112
  }
113
+ var ValueContainerSlot = (0, _admin.createComponentSlot)("div")({
114
+ componentName: "Select",
115
+ slotName: "valueContainer"
116
+ })((0, _styles.css)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: nowrap;\n flex: 1;\n align-items: center;\n overflow: hidden;\n"]))));
98
117
  function ValueContainer(props) {
99
- return /*#__PURE__*/React.createElement("div", {
100
- className: props.selectProps.classes.valueContainer
101
- }, props.children);
118
+ return /*#__PURE__*/React.createElement(ValueContainerSlot, null, props.children);
102
119
  }
120
+ var MultiValueChip = (0, _admin.createComponentSlot)(_material.Chip)({
121
+ componentName: "Select",
122
+ slotName: "chip",
123
+ classesResolver: function classesResolver(ownerState) {
124
+ return [ownerState.focused && "chipFocused"];
125
+ }
126
+ })(function (_ref5) {
127
+ var theme = _ref5.theme,
128
+ ownerState = _ref5.ownerState;
129
+ return (0, _styles.css)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n margin: ", " ", ";\n\n ", "\n "])), theme.spacing(0.5), theme.spacing(0.25), ownerState.focused && (0, _styles.css)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), theme.palette.mode === "light" ? theme.palette.grey[300] : theme.palette.grey[700]));
130
+ });
103
131
  function MultiValue(props) {
104
- return /*#__PURE__*/React.createElement(_material.Chip, {
132
+ return /*#__PURE__*/React.createElement(MultiValueChip, {
105
133
  tabIndex: -1,
134
+ ownerState: {
135
+ focused: props.isFocused
136
+ },
106
137
  label: props.children,
107
- className: (0, _classnames["default"])(props.selectProps.classes.chip, _defineProperty({}, props.selectProps.classes.chipFocused, props.isFocused)),
108
138
  onDelete: props.removeProps.onClick,
109
139
  deleteIcon: /*#__PURE__*/React.createElement(_Cancel["default"], props.removeProps)
110
140
  });
111
141
  }
142
+ var MenuSlot = (0, _admin.createComponentSlot)(_material.Paper)({
143
+ componentName: "Select",
144
+ slotName: "paper"
145
+ })();
112
146
  function Menu(props) {
113
- return /*#__PURE__*/React.createElement(_material.Paper, _extends({
114
- className: props.selectProps.classes.paper
115
- }, props.innerProps), props.children);
147
+ return /*#__PURE__*/React.createElement(MenuSlot, props.innerProps, props.children);
116
148
  }
149
+ var IndicatorsContainerSlot = (0, _admin.createComponentSlot)("div")({
150
+ componentName: "Select",
151
+ slotName: "indicatorsContainer"
152
+ })((0, _styles.css)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n"]))));
117
153
  function IndicatorsContainer(props) {
118
- return /*#__PURE__*/React.createElement("div", {
119
- className: props.selectProps.classes.indicatorsContainer
120
- }, props.children);
154
+ return /*#__PURE__*/React.createElement(IndicatorsContainerSlot, null, props.children);
121
155
  }
156
+ var IndicatorSeparatorSlot = (0, _admin.createComponentSlot)("span")({
157
+ componentName: "Select",
158
+ slotName: "indicatorSeparator"
159
+ })(function (_ref6) {
160
+ var theme = _ref6.theme;
161
+ return (0, _styles.css)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n width: 1px;\n flex-grow: 1;\n background-color: ", ";\n "])), theme.palette.divider);
162
+ });
122
163
  function IndicatorSeparator(props) {
123
- return /*#__PURE__*/React.createElement("span", {
124
- className: props.selectProps.classes.indicatorSeparator
125
- });
164
+ return /*#__PURE__*/React.createElement(IndicatorSeparatorSlot, null);
126
165
  }
127
- function ClearIndicator(_ref3) {
128
- var selectProps = _ref3.selectProps,
129
- clearValue = _ref3.clearValue;
166
+ var ClearIndicatorSlot = (0, _admin.createComponentSlot)("div")({
167
+ componentName: "Select",
168
+ slotName: "clearIndicator",
169
+ classesResolver: function classesResolver() {
170
+ return ["indicator"];
171
+ }
172
+ })(function (_ref7) {
173
+ var theme = _ref7.theme;
174
+ return (0, _styles.css)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n color: ", ";\n width: 32px;\n cursor: pointer;\n font-size: 18px;\n "])), theme.palette.grey[500]);
175
+ });
176
+ function ClearIndicator(_ref8) {
177
+ var selectProps = _ref8.selectProps,
178
+ clearValue = _ref8.clearValue;
130
179
  var Icon = selectProps.clearIcon ? selectProps.clearIcon : _Clear["default"];
131
- return /*#__PURE__*/React.createElement("div", {
132
- className: "".concat(selectProps.classes.indicator, " ").concat(selectProps.classes.clearIndicator),
180
+ return /*#__PURE__*/React.createElement(ClearIndicatorSlot, {
133
181
  onClick: clearValue
134
182
  }, /*#__PURE__*/React.createElement(Icon, {
135
183
  fontSize: "inherit",
136
184
  color: "inherit"
137
185
  }));
138
186
  }
139
- function DropdownIndicator(_ref4) {
140
- var selectProps = _ref4.selectProps;
187
+ var DropdownIndicatorSlot = (0, _admin.createComponentSlot)("div")({
188
+ componentName: "Select",
189
+ slotName: "dropdownIndicator",
190
+ classesResolver: function classesResolver() {
191
+ return ["indicator"];
192
+ }
193
+ })(function (_ref9) {
194
+ var theme = _ref9.theme;
195
+ return (0, _styles.css)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n color: ", ";\n width: 32px;\n cursor: pointer;\n font-size: 20px;\n "])), theme.palette.grey[500]);
196
+ });
197
+ function DropdownIndicator(_ref10) {
198
+ var selectProps = _ref10.selectProps;
141
199
  var DefaultIcon = selectProps.dropdownIcon ? selectProps.dropdownIcon : _KeyboardArrowDown["default"];
142
200
  var OpenIcon = selectProps.dropdownIconOpen ? selectProps.dropdownIconOpen : _KeyboardArrowDown["default"];
143
201
  var Icon = selectProps.menuIsOpen ? OpenIcon : DefaultIcon;
144
- return /*#__PURE__*/React.createElement("div", {
145
- className: "".concat(selectProps.classes.indicator, " ").concat(selectProps.classes.dropdownIndicator)
146
- }, /*#__PURE__*/React.createElement(Icon, {
202
+ return /*#__PURE__*/React.createElement(DropdownIndicatorSlot, null, /*#__PURE__*/React.createElement(Icon, {
147
203
  fontSize: "inherit",
148
204
  color: "inherit"
149
205
  }));
@@ -162,62 +218,42 @@ var components = {
162
218
  ClearIndicator: ClearIndicator,
163
219
  DropdownIndicator: DropdownIndicator
164
220
  };
165
- function SelectWrapper(_ref5) {
166
- var classes = _ref5.classes,
167
- theme = _ref5.theme,
168
- origComponents = _ref5.components,
169
- SelectComponent = _ref5.selectComponent,
170
- rest = _objectWithoutProperties(_ref5, _excluded2);
221
+ function SelectWrapper(_ref11) {
222
+ var origComponents = _ref11.components,
223
+ SelectComponent = _ref11.selectComponent,
224
+ rest = _objectWithoutProperties(_ref11, _excluded2);
225
+ var _useTheme = (0, _material.useTheme)(),
226
+ zIndex = _useTheme.zIndex;
171
227
  return /*#__PURE__*/React.createElement(SelectComponent, _extends({
172
- classes: classes,
173
228
  menuPortalTarget: document.body,
174
229
  components: _objectSpread(_objectSpread({}, components), origComponents),
175
- placeholder: ""
230
+ placeholder: "",
231
+ styles: {
232
+ menuPortal: function menuPortal(styles) {
233
+ return _objectSpread(_objectSpread({}, styles), {}, {
234
+ zIndex: zIndex.modal
235
+ });
236
+ }
237
+ }
176
238
  }, rest));
177
239
  }
178
- var ExtendedSelectWrapper = (0, _styles.withStyles)(_ReactSelect["default"], {
179
- name: "CometAdminSelect"
180
- })(SelectWrapper);
181
- var useReactSelectStyles = function useReactSelectStyles() {
182
- var _useTheme = (0, _material.useTheme)(),
183
- zIndex = _useTheme.zIndex;
184
- return {
185
- menuPortal: function menuPortal(styles) {
186
- return _objectSpread(_objectSpread({}, styles), {}, {
187
- zIndex: zIndex.modal
188
- });
189
- }
190
- };
191
- };
192
240
  function ReactSelect(props) {
193
- var reactSelectStyles = useReactSelectStyles();
194
- return /*#__PURE__*/React.createElement(ExtendedSelectWrapper, _extends({
241
+ return /*#__PURE__*/React.createElement(SelectWrapper, _extends({
195
242
  selectComponent: _reactSelect["default"]
196
- }, props, {
197
- styles: _objectSpread({}, reactSelectStyles)
198
- }));
243
+ }, props));
199
244
  }
200
245
  function ReactSelectAsync(props) {
201
- var reactSelectStyles = useReactSelectStyles();
202
- return /*#__PURE__*/React.createElement(ExtendedSelectWrapper, _extends({
246
+ return /*#__PURE__*/React.createElement(SelectWrapper, _extends({
203
247
  selectComponent: _async["default"]
204
- }, props, {
205
- styles: _objectSpread({}, reactSelectStyles)
206
- }));
248
+ }, props));
207
249
  }
208
250
  function ReactSelectCreatable(props) {
209
- var reactSelectStyles = useReactSelectStyles();
210
- return /*#__PURE__*/React.createElement(ExtendedSelectWrapper, _extends({
251
+ return /*#__PURE__*/React.createElement(SelectWrapper, _extends({
211
252
  selectComponent: _creatable["default"]
212
- }, props, {
213
- styles: _objectSpread({}, reactSelectStyles)
214
- }));
253
+ }, props));
215
254
  }
216
255
  function ReactSelectAsyncCreatable(props) {
217
- var reactSelectStyles = useReactSelectStyles();
218
- return /*#__PURE__*/React.createElement(ExtendedSelectWrapper, _extends({
256
+ return /*#__PURE__*/React.createElement(SelectWrapper, _extends({
219
257
  selectComponent: _asyncCreatable["default"]
220
- }, props, {
221
- styles: _objectSpread({}, reactSelectStyles)
222
- }));
258
+ }, props));
223
259
  }
package/lib/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export { FinalFormReactSelect, FinalFormReactSelectAsync, FinalFormReactSelectAsyncCreatable, FinalFormReactSelectCreatable, } from "./FinalFormReactSelect";
2
2
  export { FinalFormReactSelectStaticOptions } from "./FinalFormReactSelectStaticOptions";
3
- export { ControlInput, ReactSelect, ReactSelectAsync, ReactSelectAsyncCreatable, ReactSelectCreatable, SelectProps } from "./ReactSelect";
4
- export { SelectClassKey } from "./ReactSelect.styles";
3
+ export { ReactSelect, ReactSelectAsync, ReactSelectAsyncCreatable, ReactSelectCreatable, SelectClassKey, SelectProps } from "./ReactSelect";
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EACzB,kCAAkC,EAClC,6BAA6B,GAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1I,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EACzB,kCAAkC,EAClC,6BAA6B,GAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
package/lib/index.js CHANGED
@@ -3,12 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "ControlInput", {
7
- enumerable: true,
8
- get: function get() {
9
- return _ReactSelect.ControlInput;
10
- }
11
- });
12
6
  Object.defineProperty(exports, "FinalFormReactSelect", {
13
7
  enumerable: true,
14
8
  get: function get() {
@@ -66,7 +60,7 @@ Object.defineProperty(exports, "ReactSelectCreatable", {
66
60
  Object.defineProperty(exports, "SelectClassKey", {
67
61
  enumerable: true,
68
62
  get: function get() {
69
- return _ReactSelect2.SelectClassKey;
63
+ return _ReactSelect.SelectClassKey;
70
64
  }
71
65
  });
72
66
  Object.defineProperty(exports, "SelectProps", {
@@ -77,5 +71,4 @@ Object.defineProperty(exports, "SelectProps", {
77
71
  });
78
72
  var _FinalFormReactSelect = require("./FinalFormReactSelect");
79
73
  var _FinalFormReactSelectStaticOptions = require("./FinalFormReactSelectStaticOptions");
80
- var _ReactSelect = require("./ReactSelect");
81
- var _ReactSelect2 = require("./ReactSelect.styles");
74
+ var _ReactSelect = require("./ReactSelect");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/admin-react-select",
3
- "version": "6.12.1-canary-20240605133817",
3
+ "version": "7.0.0-beta.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vivid-planet/comet",
@@ -13,17 +13,16 @@
13
13
  "lib"
14
14
  ],
15
15
  "dependencies": {
16
- "@comet/admin": "6.12.1-canary-20240605133817",
16
+ "@comet/admin": "^7.0.0-beta.0",
17
17
  "classnames": "^2.2.6"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@babel/cli": "^7.17.6",
21
21
  "@babel/core": "^7.20.12",
22
- "@comet/admin-babel-preset": "6.12.1-canary-20240605133817",
23
- "@comet/eslint-config": "6.12.1-canary-20240605133817",
22
+ "@comet/admin-babel-preset": "^7.0.0-beta.0",
23
+ "@comet/eslint-config": "^7.0.0-beta.0",
24
24
  "@mui/icons-material": "^5.0.0",
25
25
  "@mui/material": "^5.0.0",
26
- "@mui/styles": "^5.0.0",
27
26
  "@types/react": "^17.0.0",
28
27
  "@types/react-dom": "^17.0.0",
29
28
  "@types/react-select": "^3.1.2",
@@ -41,7 +40,6 @@
41
40
  "peerDependencies": {
42
41
  "@mui/icons-material": "^5.0.0",
43
42
  "@mui/material": "^5.0.0",
44
- "@mui/styles": "^5.0.0",
45
43
  "final-form": "^4.16.1",
46
44
  "react": "^17.0",
47
45
  "react-dom": "^17.0",
@@ -1,5 +0,0 @@
1
- import { Theme } from "@mui/material";
2
- export type SelectClassKey = "input" | "valueContainer" | "chip" | "chipFocused" | "noOptionsMessage" | "singleValue" | "placeholder" | "paper" | "indicatorsContainer" | "indicatorSeparator" | "clearIndicator" | "indicator" | "dropdownIndicator" | "option" | "optionSelected" | "optionFocused";
3
- declare const styles: (theme: Theme) => import("@mui/styles").StyleRules<Record<string, unknown>, SelectClassKey>;
4
- export default styles;
5
- //# sourceMappingURL=ReactSelect.styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReactSelect.styles.d.ts","sourceRoot":"","sources":["../src/ReactSelect.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAItC,MAAM,MAAM,cAAc,GACpB,OAAO,GACP,gBAAgB,GAChB,MAAM,GACN,aAAa,GACb,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,OAAO,GACP,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,GAChB,WAAW,GACX,mBAAmB,GACnB,QAAQ,GACR,gBAAgB,GAChB,eAAe,CAAC;AAEtB,QAAA,MAAM,MAAM,UAAW,KAAK,8EA6DtB,CAAC;AAEP,eAAe,MAAM,CAAC"}
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _styles = require("@mui/material/styles");
8
- var _styles2 = require("@mui/styles");
9
- var styles = function styles(theme) {
10
- return (0, _styles2.createStyles)({
11
- input: {
12
- display: "flex",
13
- paddingRight: 0
14
- },
15
- valueContainer: {
16
- display: "flex",
17
- flexWrap: "nowrap",
18
- flex: 1,
19
- alignItems: "center",
20
- overflow: "hidden"
21
- },
22
- chip: {
23
- margin: "".concat(theme.spacing(0.5), " ").concat(theme.spacing(0.25))
24
- },
25
- chipFocused: {
26
- backgroundColor: (0, _styles.emphasize)(theme.palette.mode === "light" ? theme.palette.grey[300] : theme.palette.grey[700], 0.08)
27
- },
28
- noOptionsMessage: {
29
- padding: "".concat(theme.spacing(1), " ").concat(theme.spacing(2)),
30
- color: theme.palette.text.secondary
31
- },
32
- singleValue: {
33
- overflow: "hidden",
34
- textOverflow: "ellipsis",
35
- whiteSpace: "nowrap"
36
- },
37
- placeholder: {
38
- color: theme.palette.text.disabled
39
- },
40
- paper: {},
41
- indicatorsContainer: {
42
- display: "flex"
43
- },
44
- indicatorSeparator: {
45
- width: 1,
46
- flexGrow: 1,
47
- backgroundColor: theme.palette.divider
48
- },
49
- indicator: {
50
- display: "flex",
51
- alignItems: "center",
52
- justifyContent: "center",
53
- color: theme.palette.grey[500],
54
- width: 32,
55
- cursor: "pointer"
56
- },
57
- clearIndicator: {
58
- fontSize: 18
59
- },
60
- dropdownIndicator: {
61
- fontSize: 20
62
- },
63
- option: {},
64
- optionSelected: {
65
- fontWeight: theme.typography.fontWeightMedium
66
- },
67
- optionFocused: {
68
- backgroundColor: theme.palette.grey[50]
69
- }
70
- });
71
- };
72
- var _default = styles;
73
- exports["default"] = _default;