glints-aries 4.1.65 → 4.1.66
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/es/@next/Select/Select.d.ts +3 -1
- package/es/@next/Select/Select.js +5 -3
- package/es/Input/PhoneNumberInput/PhoneNumberInput.d.ts +2 -1
- package/es/Input/PhoneNumberInput/PhoneNumberInput.js +19 -3
- package/lib/@next/Select/Select.d.ts +3 -1
- package/lib/@next/Select/Select.js +5 -3
- package/lib/Input/PhoneNumberInput/PhoneNumberInput.d.ts +2 -1
- package/lib/Input/PhoneNumberInput/PhoneNumberInput.js +19 -3
- package/package.json +1 -1
|
@@ -59,6 +59,8 @@ export interface SelectProps {
|
|
|
59
59
|
borderRadius?: string;
|
|
60
60
|
required?: boolean;
|
|
61
61
|
isPlaceholderFloating?: boolean;
|
|
62
|
+
/** Allow popover to stretch to the full width of its activator */
|
|
63
|
+
fullWidth?: boolean;
|
|
62
64
|
}
|
|
63
|
-
export declare const Select: ({ allowMultiple, customActivatorIcon, disabled, hasError, helpText, label, listHeight, loadingOptions, name, onBlur, onClose, onFocus, onRemoveTag, onSelect, onSelectClick, isPopoverActive, onPopoverActiveChange, optionListFitContent, options, placeholder, prefix, searchable, searchableProps, optionsPlaceholderProps, showPopoverOnFocus, scrollable, sections, selectedValues, width, height, zIndexOverride, border, borderRadius, required, isPlaceholderFloating, }: SelectProps) => JSX.Element;
|
|
65
|
+
export declare const Select: ({ allowMultiple, customActivatorIcon, disabled, hasError, helpText, label, listHeight, loadingOptions, name, onBlur, onClose, onFocus, onRemoveTag, onSelect, onSelectClick, isPopoverActive, onPopoverActiveChange, optionListFitContent, options, placeholder, prefix, searchable, searchableProps, optionsPlaceholderProps, showPopoverOnFocus, scrollable, sections, selectedValues, width, height, zIndexOverride, border, borderRadius, required, isPlaceholderFloating, fullWidth, }: SelectProps) => JSX.Element;
|
|
64
66
|
export {};
|
|
@@ -50,7 +50,9 @@ export var Select = function Select(_ref) {
|
|
|
50
50
|
border = _ref.border,
|
|
51
51
|
borderRadius = _ref.borderRadius,
|
|
52
52
|
required = _ref.required,
|
|
53
|
-
isPlaceholderFloating = _ref.isPlaceholderFloating
|
|
53
|
+
isPlaceholderFloating = _ref.isPlaceholderFloating,
|
|
54
|
+
_ref$fullWidth = _ref.fullWidth,
|
|
55
|
+
fullWidth = _ref$fullWidth === void 0 ? true : _ref$fullWidth;
|
|
54
56
|
var _useState = useState(false),
|
|
55
57
|
internalPopoverActive = _useState[0],
|
|
56
58
|
setInternalPopoverActive = _useState[1];
|
|
@@ -198,7 +200,7 @@ export var Select = function Select(_ref) {
|
|
|
198
200
|
preventFocusOnClose: true,
|
|
199
201
|
preferredAlignment: "left",
|
|
200
202
|
preferredPosition: "below",
|
|
201
|
-
fullWidth:
|
|
203
|
+
fullWidth: fullWidth,
|
|
202
204
|
fitContent: optionListFitContent,
|
|
203
205
|
zIndexOverride: zIndexOverride
|
|
204
206
|
}, !disabled && /*#__PURE__*/React.createElement(Popover.Pane, {
|
|
@@ -210,7 +212,7 @@ export var Select = function Select(_ref) {
|
|
|
210
212
|
onSelect: onSelect,
|
|
211
213
|
sections: sections,
|
|
212
214
|
selectedValues: selectedValues,
|
|
213
|
-
width: width,
|
|
215
|
+
width: fullWidth ? width : undefined,
|
|
214
216
|
onMenuClose: handleClose,
|
|
215
217
|
noOptionsMessage: optionsPlaceholderProps && (!inputValue ? optionsPlaceholderProps.idle : optionsPlaceholderProps.noResult),
|
|
216
218
|
updateSearchableSelectState: function updateSearchableSelectState(newState) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
export declare const PhoneNumberInput: ({ value, onChange, onFocus, onBlur, callingCodeOptions: callingCodeOptionsExternal, onInputChange, filterValue, isLoadingCallingCodeOptions, label, featuredOptionsLabel, otherOptionsLabel, callingCodeFilterInputPlaceholder, callingCodeNoOptionsLabel, isDisableCallingCode, isPlaceholderFloating, isRequired, error, addon, ...restProps }: Props) => JSX.Element;
|
|
2
|
+
export declare const PhoneNumberInput: ({ value, onChange, onFocus, onBlur, callingCodeOptions: callingCodeOptionsExternal, onInputChange, filterValue, isLoadingCallingCodeOptions, label, featuredOptionsLabel, otherOptionsLabel, callingCodeFilterInputPlaceholder, callingCodeNoOptionsLabel, isDisableCallingCode, isPlaceholderFloating, isRequired, error, addon, showFilterInput, ...restProps }: Props) => JSX.Element;
|
|
3
3
|
export interface Props {
|
|
4
4
|
value: PhoneNumber;
|
|
5
5
|
onChange: (value: PhoneNumber) => void;
|
|
@@ -20,6 +20,7 @@ export interface Props {
|
|
|
20
20
|
isDisableCallingCode?: boolean;
|
|
21
21
|
isPlaceholderFloating?: boolean;
|
|
22
22
|
isRequired?: boolean;
|
|
23
|
+
showFilterInput?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export interface PhoneNumber {
|
|
25
26
|
callingCode: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["value", "onChange", "onFocus", "onBlur", "callingCodeOptions", "onInputChange", "filterValue", "isLoadingCallingCodeOptions", "label", "featuredOptionsLabel", "otherOptionsLabel", "callingCodeFilterInputPlaceholder", "callingCodeNoOptionsLabel", "isDisableCallingCode", "isPlaceholderFloating", "isRequired", "error", "addon"];
|
|
3
|
+
var _excluded = ["value", "onChange", "onFocus", "onBlur", "callingCodeOptions", "onInputChange", "filterValue", "isLoadingCallingCodeOptions", "label", "featuredOptionsLabel", "otherOptionsLabel", "callingCodeFilterInputPlaceholder", "callingCodeNoOptionsLabel", "isDisableCallingCode", "isPlaceholderFloating", "isRequired", "error", "addon", "showFilterInput"];
|
|
4
4
|
import { useCombobox } from 'downshift';
|
|
5
5
|
import { find, orderBy } from 'lodash-es';
|
|
6
6
|
import React, { useEffect, useRef, useState } from 'react';
|
|
@@ -37,6 +37,8 @@ export var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
|
37
37
|
isRequired = _ref.isRequired,
|
|
38
38
|
error = _ref.error,
|
|
39
39
|
addon = _ref.addon,
|
|
40
|
+
_ref$showFilterInput = _ref.showFilterInput,
|
|
41
|
+
showFilterInput = _ref$showFilterInput === void 0 ? true : _ref$showFilterInput,
|
|
40
42
|
restProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
41
43
|
var _useState = useState(false),
|
|
42
44
|
isCallingCodeInputOpen = _useState[0],
|
|
@@ -48,6 +50,20 @@ export var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
|
48
50
|
return setIsCallingCodeInputOpen(false);
|
|
49
51
|
};
|
|
50
52
|
var callingCodeOptions = orderBy(callingCodeOptionsExternal, ['isFeatured', 'label'], ['desc', 'asc']);
|
|
53
|
+
var hasFeaturedOptions = callingCodeOptions.some(function (item) {
|
|
54
|
+
return item.isFeatured;
|
|
55
|
+
});
|
|
56
|
+
var hasOtherOptions = callingCodeOptions.some(function (item) {
|
|
57
|
+
return !item.isFeatured;
|
|
58
|
+
});
|
|
59
|
+
var shouldShowGroupHeaders = hasFeaturedOptions && hasOtherOptions;
|
|
60
|
+
var getGroupHeaderLabel = function getGroupHeaderLabel(item, index) {
|
|
61
|
+
if (!shouldShowGroupHeaders) return '';
|
|
62
|
+
var previousItem = callingCodeOptions[index - 1];
|
|
63
|
+
var isGroupBoundary = item.isFeatured !== (previousItem || {}).isFeatured;
|
|
64
|
+
if (!isGroupBoundary) return '';
|
|
65
|
+
return item.isFeatured ? featuredOptionsLabel : otherOptionsLabel;
|
|
66
|
+
};
|
|
51
67
|
var _useCombobox = useCombobox({
|
|
52
68
|
items: callingCodeOptions,
|
|
53
69
|
selectedItem: find(callingCodeOptions, {
|
|
@@ -119,7 +135,7 @@ export var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
|
119
135
|
isOpen: isCallingCodeInputOpen
|
|
120
136
|
}, getComboboxProps(), {
|
|
121
137
|
"data-testid": "calling-code-input"
|
|
122
|
-
}), /*#__PURE__*/React.createElement(S.CallingCodeFilterInputGroup, null, /*#__PURE__*/React.createElement(S.CallingCodeFilterInput, _extends({}, getInputProps({
|
|
138
|
+
}), showFilterInput && /*#__PURE__*/React.createElement(S.CallingCodeFilterInputGroup, null, /*#__PURE__*/React.createElement(S.CallingCodeFilterInput, _extends({}, getInputProps({
|
|
123
139
|
placeholder: callingCodeFilterInputPlaceholder
|
|
124
140
|
}, _extends({}, refErrorFix)), {
|
|
125
141
|
ref: callingCodeFilterInputRef,
|
|
@@ -136,7 +152,7 @@ export var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
|
136
152
|
index: index
|
|
137
153
|
}), {
|
|
138
154
|
title: item.label,
|
|
139
|
-
withGroupHeader: item
|
|
155
|
+
withGroupHeader: getGroupHeaderLabel(item, index)
|
|
140
156
|
}), /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(S.CallingCodeOptionCallingCode, null, "+", item.callingCode), /*#__PURE__*/React.createElement(S.CallingCodeOptionLabel, null, item.label)));
|
|
141
157
|
}) : /*#__PURE__*/React.createElement(S.NoOptions, {
|
|
142
158
|
"data-testid": "no-options"
|
|
@@ -59,6 +59,8 @@ export interface SelectProps {
|
|
|
59
59
|
borderRadius?: string;
|
|
60
60
|
required?: boolean;
|
|
61
61
|
isPlaceholderFloating?: boolean;
|
|
62
|
+
/** Allow popover to stretch to the full width of its activator */
|
|
63
|
+
fullWidth?: boolean;
|
|
62
64
|
}
|
|
63
|
-
export declare const Select: ({ allowMultiple, customActivatorIcon, disabled, hasError, helpText, label, listHeight, loadingOptions, name, onBlur, onClose, onFocus, onRemoveTag, onSelect, onSelectClick, isPopoverActive, onPopoverActiveChange, optionListFitContent, options, placeholder, prefix, searchable, searchableProps, optionsPlaceholderProps, showPopoverOnFocus, scrollable, sections, selectedValues, width, height, zIndexOverride, border, borderRadius, required, isPlaceholderFloating, }: SelectProps) => JSX.Element;
|
|
65
|
+
export declare const Select: ({ allowMultiple, customActivatorIcon, disabled, hasError, helpText, label, listHeight, loadingOptions, name, onBlur, onClose, onFocus, onRemoveTag, onSelect, onSelectClick, isPopoverActive, onPopoverActiveChange, optionListFitContent, options, placeholder, prefix, searchable, searchableProps, optionsPlaceholderProps, showPopoverOnFocus, scrollable, sections, selectedValues, width, height, zIndexOverride, border, borderRadius, required, isPlaceholderFloating, fullWidth, }: SelectProps) => JSX.Element;
|
|
64
66
|
export {};
|
|
@@ -56,7 +56,9 @@ var Select = function Select(_ref) {
|
|
|
56
56
|
border = _ref.border,
|
|
57
57
|
borderRadius = _ref.borderRadius,
|
|
58
58
|
required = _ref.required,
|
|
59
|
-
isPlaceholderFloating = _ref.isPlaceholderFloating
|
|
59
|
+
isPlaceholderFloating = _ref.isPlaceholderFloating,
|
|
60
|
+
_ref$fullWidth = _ref.fullWidth,
|
|
61
|
+
fullWidth = _ref$fullWidth === void 0 ? true : _ref$fullWidth;
|
|
60
62
|
var _useState = (0, _react.useState)(false),
|
|
61
63
|
internalPopoverActive = _useState[0],
|
|
62
64
|
setInternalPopoverActive = _useState[1];
|
|
@@ -204,7 +206,7 @@ var Select = function Select(_ref) {
|
|
|
204
206
|
preventFocusOnClose: true,
|
|
205
207
|
preferredAlignment: "left",
|
|
206
208
|
preferredPosition: "below",
|
|
207
|
-
fullWidth:
|
|
209
|
+
fullWidth: fullWidth,
|
|
208
210
|
fitContent: optionListFitContent,
|
|
209
211
|
zIndexOverride: zIndexOverride
|
|
210
212
|
}, !disabled && /*#__PURE__*/_react["default"].createElement(_Popover.Popover.Pane, {
|
|
@@ -216,7 +218,7 @@ var Select = function Select(_ref) {
|
|
|
216
218
|
onSelect: onSelect,
|
|
217
219
|
sections: sections,
|
|
218
220
|
selectedValues: selectedValues,
|
|
219
|
-
width: width,
|
|
221
|
+
width: fullWidth ? width : undefined,
|
|
220
222
|
onMenuClose: handleClose,
|
|
221
223
|
noOptionsMessage: optionsPlaceholderProps && (!inputValue ? optionsPlaceholderProps.idle : optionsPlaceholderProps.noResult),
|
|
222
224
|
updateSearchableSelectState: function updateSearchableSelectState(newState) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
export declare const PhoneNumberInput: ({ value, onChange, onFocus, onBlur, callingCodeOptions: callingCodeOptionsExternal, onInputChange, filterValue, isLoadingCallingCodeOptions, label, featuredOptionsLabel, otherOptionsLabel, callingCodeFilterInputPlaceholder, callingCodeNoOptionsLabel, isDisableCallingCode, isPlaceholderFloating, isRequired, error, addon, ...restProps }: Props) => JSX.Element;
|
|
2
|
+
export declare const PhoneNumberInput: ({ value, onChange, onFocus, onBlur, callingCodeOptions: callingCodeOptionsExternal, onInputChange, filterValue, isLoadingCallingCodeOptions, label, featuredOptionsLabel, otherOptionsLabel, callingCodeFilterInputPlaceholder, callingCodeNoOptionsLabel, isDisableCallingCode, isPlaceholderFloating, isRequired, error, addon, showFilterInput, ...restProps }: Props) => JSX.Element;
|
|
3
3
|
export interface Props {
|
|
4
4
|
value: PhoneNumber;
|
|
5
5
|
onChange: (value: PhoneNumber) => void;
|
|
@@ -20,6 +20,7 @@ export interface Props {
|
|
|
20
20
|
isDisableCallingCode?: boolean;
|
|
21
21
|
isPlaceholderFloating?: boolean;
|
|
22
22
|
isRequired?: boolean;
|
|
23
|
+
showFilterInput?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export interface PhoneNumber {
|
|
25
26
|
callingCode: number;
|
|
@@ -14,7 +14,7 @@ var _Flex = require("../../Layout/Flex");
|
|
|
14
14
|
var _useOutsideAlerter = require("../../Utils/useOutsideAlerter");
|
|
15
15
|
var S = _interopRequireWildcard(require("./PhoneNumberInputStyles"));
|
|
16
16
|
var _InputStyle = require("../../@next/Input/InputStyle");
|
|
17
|
-
var _excluded = ["value", "onChange", "onFocus", "onBlur", "callingCodeOptions", "onInputChange", "filterValue", "isLoadingCallingCodeOptions", "label", "featuredOptionsLabel", "otherOptionsLabel", "callingCodeFilterInputPlaceholder", "callingCodeNoOptionsLabel", "isDisableCallingCode", "isPlaceholderFloating", "isRequired", "error", "addon"];
|
|
17
|
+
var _excluded = ["value", "onChange", "onFocus", "onBlur", "callingCodeOptions", "onInputChange", "filterValue", "isLoadingCallingCodeOptions", "label", "featuredOptionsLabel", "otherOptionsLabel", "callingCodeFilterInputPlaceholder", "callingCodeNoOptionsLabel", "isDisableCallingCode", "isPlaceholderFloating", "isRequired", "error", "addon", "showFilterInput"];
|
|
18
18
|
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); }
|
|
19
19
|
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; }
|
|
20
20
|
// Downshift wants a ref to this, but we need one ourselves, and there is no way
|
|
@@ -43,6 +43,8 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
|
43
43
|
isRequired = _ref.isRequired,
|
|
44
44
|
error = _ref.error,
|
|
45
45
|
addon = _ref.addon,
|
|
46
|
+
_ref$showFilterInput = _ref.showFilterInput,
|
|
47
|
+
showFilterInput = _ref$showFilterInput === void 0 ? true : _ref$showFilterInput,
|
|
46
48
|
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
47
49
|
var _useState = (0, _react.useState)(false),
|
|
48
50
|
isCallingCodeInputOpen = _useState[0],
|
|
@@ -54,6 +56,20 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
|
54
56
|
return setIsCallingCodeInputOpen(false);
|
|
55
57
|
};
|
|
56
58
|
var callingCodeOptions = (0, _lodash.orderBy)(callingCodeOptionsExternal, ['isFeatured', 'label'], ['desc', 'asc']);
|
|
59
|
+
var hasFeaturedOptions = callingCodeOptions.some(function (item) {
|
|
60
|
+
return item.isFeatured;
|
|
61
|
+
});
|
|
62
|
+
var hasOtherOptions = callingCodeOptions.some(function (item) {
|
|
63
|
+
return !item.isFeatured;
|
|
64
|
+
});
|
|
65
|
+
var shouldShowGroupHeaders = hasFeaturedOptions && hasOtherOptions;
|
|
66
|
+
var getGroupHeaderLabel = function getGroupHeaderLabel(item, index) {
|
|
67
|
+
if (!shouldShowGroupHeaders) return '';
|
|
68
|
+
var previousItem = callingCodeOptions[index - 1];
|
|
69
|
+
var isGroupBoundary = item.isFeatured !== (previousItem || {}).isFeatured;
|
|
70
|
+
if (!isGroupBoundary) return '';
|
|
71
|
+
return item.isFeatured ? featuredOptionsLabel : otherOptionsLabel;
|
|
72
|
+
};
|
|
57
73
|
var _useCombobox = (0, _downshift.useCombobox)({
|
|
58
74
|
items: callingCodeOptions,
|
|
59
75
|
selectedItem: (0, _lodash.find)(callingCodeOptions, {
|
|
@@ -125,7 +141,7 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
|
125
141
|
isOpen: isCallingCodeInputOpen
|
|
126
142
|
}, getComboboxProps(), {
|
|
127
143
|
"data-testid": "calling-code-input"
|
|
128
|
-
}), /*#__PURE__*/_react["default"].createElement(S.CallingCodeFilterInputGroup, null, /*#__PURE__*/_react["default"].createElement(S.CallingCodeFilterInput, (0, _extends2["default"])({}, getInputProps({
|
|
144
|
+
}), showFilterInput && /*#__PURE__*/_react["default"].createElement(S.CallingCodeFilterInputGroup, null, /*#__PURE__*/_react["default"].createElement(S.CallingCodeFilterInput, (0, _extends2["default"])({}, getInputProps({
|
|
129
145
|
placeholder: callingCodeFilterInputPlaceholder
|
|
130
146
|
}, (0, _extends2["default"])({}, refErrorFix)), {
|
|
131
147
|
ref: callingCodeFilterInputRef,
|
|
@@ -142,7 +158,7 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
|
142
158
|
index: index
|
|
143
159
|
}), {
|
|
144
160
|
title: item.label,
|
|
145
|
-
withGroupHeader: item
|
|
161
|
+
withGroupHeader: getGroupHeaderLabel(item, index)
|
|
146
162
|
}), /*#__PURE__*/_react["default"].createElement(_Flex.Flex, null, /*#__PURE__*/_react["default"].createElement(S.CallingCodeOptionCallingCode, null, "+", item.callingCode), /*#__PURE__*/_react["default"].createElement(S.CallingCodeOptionLabel, null, item.label)));
|
|
147
163
|
}) : /*#__PURE__*/_react["default"].createElement(S.NoOptions, {
|
|
148
164
|
"data-testid": "no-options"
|