@sprinklrjs/spaceweb 14.12.1 → 14.12.2
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/baseui/layer/tether.js +5 -5
- package/esm/baseui/layer/tether.js +5 -5
- package/esm/input/base-input.js +1 -1
- package/esm/list/divider.js +3 -1
- package/esm/list/list.js +11 -14
- package/esm/list/utils.d.ts +8 -0
- package/esm/list/utils.js +28 -1
- package/esm/phone-input/constants.d.ts +476 -0
- package/esm/phone-input/constants.js +397 -105
- package/esm/phone-input/country-select.js +7 -4
- package/esm/phone-input/types.d.ts +24 -1
- package/esm/phone-input/useStatefulPhoneInput.d.ts +1 -1
- package/esm/phone-input/utils.d.ts +25 -1
- package/esm/phone-input/utils.js +49 -0
- package/input/base-input.js +1 -1
- package/list/divider.js +3 -1
- package/list/list.js +10 -13
- package/list/utils.d.ts +8 -0
- package/list/utils.js +31 -1
- package/package.json +2 -2
- package/phone-input/constants.d.ts +476 -0
- package/phone-input/constants.js +397 -105
- package/phone-input/country-select.js +5 -2
- package/phone-input/types.d.ts +24 -1
- package/phone-input/useStatefulPhoneInput.d.ts +1 -1
- package/phone-input/utils.d.ts +25 -1
- package/phone-input/utils.js +52 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/baseui/layer/tether.js
CHANGED
|
@@ -122,7 +122,7 @@ var Tether = /** @class */ (function (_super) {
|
|
|
122
122
|
var modifiers = popperOptions.modifiers, restOptions = tslib_1.__rest(popperOptions, ["modifiers"]);
|
|
123
123
|
if (!this.props.anchorRef || !this.props.popperRef)
|
|
124
124
|
return;
|
|
125
|
-
var popperInitOptions = tslib_1.__assign(
|
|
125
|
+
var popperInitOptions = tslib_1.__assign({
|
|
126
126
|
// Recommended placement (popper may ignore if it causes a viewport overflow, etc)
|
|
127
127
|
placement: (0, utils_1.toPopperPlacement)(placement), modifiers: tslib_1.__assign({
|
|
128
128
|
// Passing the arrow ref will measure the arrow when calculating styles
|
|
@@ -140,7 +140,7 @@ var Tether = /** @class */ (function (_super) {
|
|
|
140
140
|
enabled: true,
|
|
141
141
|
fn: this.onPopperUpdate,
|
|
142
142
|
order: 900,
|
|
143
|
-
}, preventOverflow: { enabled: true } }, modifiers)
|
|
143
|
+
}, preventOverflow: { enabled: true } }, modifiers), positionFixed: this.props.positionFixed }, restOptions);
|
|
144
144
|
this.popper = new popper_js_1.default(this.props.anchorRef, this.props.popperRef, popperInitOptions);
|
|
145
145
|
};
|
|
146
146
|
Tether.prototype.destroyPopover = function () {
|
|
@@ -153,13 +153,13 @@ var Tether = /** @class */ (function (_super) {
|
|
|
153
153
|
return this.props.children || null;
|
|
154
154
|
};
|
|
155
155
|
Tether.defaultProps = {
|
|
156
|
-
// @ts-ignore
|
|
156
|
+
// @ts-ignore -- To be fixed in the baseui move
|
|
157
157
|
anchorRef: null,
|
|
158
|
-
// @ts-ignore
|
|
158
|
+
// @ts-ignore -- To be fixed in the baseui move
|
|
159
159
|
onPopperUpdate: function () { return null; },
|
|
160
160
|
// this placement should only be used only for Popper.js configuration
|
|
161
161
|
placement: constants_1.TETHER_PLACEMENT.auto,
|
|
162
|
-
// @ts-ignore
|
|
162
|
+
// @ts-ignore -- To be fixed in the baseui move
|
|
163
163
|
popperRef: null,
|
|
164
164
|
popperOptions: {},
|
|
165
165
|
positionFixed: false,
|
|
@@ -120,7 +120,7 @@ var Tether = /** @class */ (function (_super) {
|
|
|
120
120
|
var modifiers = popperOptions.modifiers, restOptions = __rest(popperOptions, ["modifiers"]);
|
|
121
121
|
if (!this.props.anchorRef || !this.props.popperRef)
|
|
122
122
|
return;
|
|
123
|
-
var popperInitOptions = __assign(
|
|
123
|
+
var popperInitOptions = __assign({
|
|
124
124
|
// Recommended placement (popper may ignore if it causes a viewport overflow, etc)
|
|
125
125
|
placement: toPopperPlacement(placement), modifiers: __assign({
|
|
126
126
|
// Passing the arrow ref will measure the arrow when calculating styles
|
|
@@ -138,7 +138,7 @@ var Tether = /** @class */ (function (_super) {
|
|
|
138
138
|
enabled: true,
|
|
139
139
|
fn: this.onPopperUpdate,
|
|
140
140
|
order: 900,
|
|
141
|
-
}, preventOverflow: { enabled: true } }, modifiers)
|
|
141
|
+
}, preventOverflow: { enabled: true } }, modifiers), positionFixed: this.props.positionFixed }, restOptions);
|
|
142
142
|
this.popper = new Popper(this.props.anchorRef, this.props.popperRef, popperInitOptions);
|
|
143
143
|
};
|
|
144
144
|
Tether.prototype.destroyPopover = function () {
|
|
@@ -151,13 +151,13 @@ var Tether = /** @class */ (function (_super) {
|
|
|
151
151
|
return this.props.children || null;
|
|
152
152
|
};
|
|
153
153
|
Tether.defaultProps = {
|
|
154
|
-
// @ts-ignore
|
|
154
|
+
// @ts-ignore -- To be fixed in the baseui move
|
|
155
155
|
anchorRef: null,
|
|
156
|
-
// @ts-ignore
|
|
156
|
+
// @ts-ignore -- To be fixed in the baseui move
|
|
157
157
|
onPopperUpdate: function () { return null; },
|
|
158
158
|
// this placement should only be used only for Popper.js configuration
|
|
159
159
|
placement: TETHER_PLACEMENT.auto,
|
|
160
|
-
// @ts-ignore
|
|
160
|
+
// @ts-ignore -- To be fixed in the baseui move
|
|
161
161
|
popperRef: null,
|
|
162
162
|
popperOptions: {},
|
|
163
163
|
positionFixed: false,
|
package/esm/input/base-input.js
CHANGED
|
@@ -141,7 +141,7 @@ var BaseInput = function (_a) {
|
|
|
141
141
|
var hasScroll = inputRef.current && inputRef.current.scrollHeight > inputRef.current.clientHeight;
|
|
142
142
|
var charCount = typeof value === 'string' ? value.length : 0;
|
|
143
143
|
var ariaLabel = 'Clear value';
|
|
144
|
-
return (_jsxs(InputContainer, __assign({ "data-spaceweb": "base-input" }, sharedProps, inputContainerProps, { children: [_jsx(Before, __assign({}, sharedProps, beforeProps)), _jsx(Input, __assign({ ref: inputRef, "aria-activedescendant": props['aria-activedescendant'], "aria-autocomplete": props['aria-autocomplete'], "aria-controls": props['aria-controls'], "aria-errormessage": props['aria-errormessage'], "aria-haspopup": props['aria-haspopup'], "aria-label": props['aria-label'], "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], "aria-required": props['aria-required'], "aria-invalid": props['aria-invalid'], autoComplete: _autoComplete, disabled: disabled, readOnly: readOnly, id: id, inputMode: inputMode, maxLength: maxLength, name: name, onBlur: handleOnBlur, onChange: handleChange, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onScroll: handleBoxShadow, onKeyPress: onKeyPress, onKeyUp: onKeyUp, pattern: pattern, placeholder: placeholder, type: getInputType(), required: required, role: role, value: value, min: min, max: max, step: step, draggable: draggable, onDragStart: draggable ? handleOnDragStart : undefined, rows: type === CUSTOM_INPUT_TYPE.textarea ? rows : null }, sharedProps, inputProps)), showClearIcon ? (_jsx(ClearIconContainer, __assign({ "$alignTop": type === CUSTOM_INPUT_TYPE.textarea }, sharedProps, clearIconContainerProps, { children: _jsx(ClearIcon, __assign({ title: ariaLabel, "aria-label": ariaLabel, onClick: onClearIconClick, onKeyDown: function (event) {
|
|
144
|
+
return (_jsxs(InputContainer, __assign({ "data-spaceweb": "base-input" }, sharedProps, inputContainerProps, { children: [_jsx(Before, __assign({}, sharedProps, beforeProps)), _jsx(Input, __assign({ ref: inputRef, "aria-activedescendant": props['aria-activedescendant'], "aria-autocomplete": props['aria-autocomplete'], "aria-controls": props['aria-controls'], "aria-errormessage": props['aria-errormessage'], "aria-haspopup": props['aria-haspopup'], "aria-label": props['aria-label'], "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], "aria-required": props['aria-required'], "aria-invalid": props['aria-invalid'], "aria-expanded": props['aria-expanded'], autoComplete: _autoComplete, disabled: disabled, readOnly: readOnly, id: id, inputMode: inputMode, maxLength: maxLength, name: name, onBlur: handleOnBlur, onChange: handleChange, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onScroll: handleBoxShadow, onKeyPress: onKeyPress, onKeyUp: onKeyUp, pattern: pattern, placeholder: placeholder, type: getInputType(), required: required, role: role, value: value, min: min, max: max, step: step, draggable: draggable, onDragStart: draggable ? handleOnDragStart : undefined, rows: type === CUSTOM_INPUT_TYPE.textarea ? rows : null }, sharedProps, inputProps)), showClearIcon ? (_jsx(ClearIconContainer, __assign({ "$alignTop": type === CUSTOM_INPUT_TYPE.textarea }, sharedProps, clearIconContainerProps, { children: _jsx(ClearIcon, __assign({ title: ariaLabel, "aria-label": ariaLabel, onClick: onClearIconClick, onKeyDown: function (event) {
|
|
145
145
|
if (event.key && (event.key === 'Enter' || event.key === ' ')) {
|
|
146
146
|
event.preventDefault();
|
|
147
147
|
onClearIconClick();
|
package/esm/list/divider.js
CHANGED
|
@@ -4,15 +4,17 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { useOverrides } from '../overrides';
|
|
5
5
|
import ListItem from './list-item';
|
|
6
6
|
import { StyledListItemDivider } from './styled-component';
|
|
7
|
+
import { omitContainerAriaProps } from './utils';
|
|
7
8
|
var Divider = forwardRef(function (_a, ref) {
|
|
8
9
|
var children = _a.children, _b = _a.first, first = _b === void 0 ? false : _b, _c = _a.overrides, overrides = _c === void 0 ? {} : _c, className = _a.className, restProps = __rest(_a, ["children", "first", "overrides", "className"]);
|
|
9
10
|
var _d = __read(useOverrides(overrides.Separator, StyledListItemDivider), 2), Separator = _d[0], separatorProps = _d[1];
|
|
10
11
|
var _e = __read(useOverrides(overrides.SubHeader, ListItem), 2), SubHeader = _e[0], subHeaderProps = _e[1];
|
|
12
|
+
var propsWithoutContainerAria = omitContainerAriaProps(restProps);
|
|
11
13
|
return children ? (_jsx(SubHeader, __assign({ className: [
|
|
12
14
|
'spr-border-primary border-solid border-b-0 border-l-0 border-r-0 mx-0 rounded-0',
|
|
13
15
|
first ? 'border-t-0 pt-0' : 'border-t',
|
|
14
16
|
className,
|
|
15
|
-
], "
|
|
17
|
+
], role: "presentation" }, propsWithoutContainerAria, subHeaderProps, { ref: ref }, { children: children }))) : (_jsx(Separator, __assign({ "data-spaceweb": "divider", role: "presentation", className: className }, propsWithoutContainerAria, { ref: ref }, separatorProps)));
|
|
16
18
|
});
|
|
17
19
|
Divider.displayName = 'Divider';
|
|
18
20
|
export default Divider;
|
package/esm/list/list.js
CHANGED
|
@@ -6,19 +6,19 @@ import { useOverrides } from '../overrides';
|
|
|
6
6
|
import useCombinedRef, { combineRefs } from '../hooks/useCombinedRef';
|
|
7
7
|
import { LIST_MIN_WIDTH, StyledList } from './styled-component';
|
|
8
8
|
import { Box } from '../box';
|
|
9
|
-
import { customRangeExtractor, measureElement } from './utils';
|
|
9
|
+
import { customRangeExtractor, measureElement, splitA11yProps, isPresentationalRole } from './utils';
|
|
10
10
|
import { DEFAULT_LIST_ITEM_HEIGHT, DEFAULT_OVER_SCAN_COUNT } from './constants';
|
|
11
11
|
import { useStyle } from '../style';
|
|
12
12
|
var getCloneElement = function (item, virtualRow, totalCount) {
|
|
13
13
|
var _a, _b;
|
|
14
|
-
return React.cloneElement(item, {
|
|
15
|
-
style: [{ '--sw-translate-y': "".concat(virtualRow.start, "px") }, item.props.style],
|
|
16
|
-
className: ['w-full absolute top-0 left-0 box-border translate-y-[--sw-translate-y]'],
|
|
14
|
+
return React.cloneElement(item, __assign({ style: [{ '--sw-translate-y': "".concat(virtualRow.start, "px") }, item.props.style], className: ['w-full absolute top-0 left-0 box-border translate-y-[--sw-translate-y]'],
|
|
17
15
|
// @ts-expect-error TS(2339): Property 'ref' does not exist on type 'ReactElemen... Remove this comment to see the full error message
|
|
18
|
-
ref: combineRefs(virtualRow.measureElement, item.ref),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
ref: combineRefs(virtualRow.measureElement, item.ref) }, (isPresentationalRole(item.props.role)
|
|
17
|
+
? {}
|
|
18
|
+
: {
|
|
19
|
+
'aria-posinset': (_a = item.props['aria-posinset']) !== null && _a !== void 0 ? _a : virtualRow.index + 1,
|
|
20
|
+
'aria-setsize': (_b = item.props['aria-setsize']) !== null && _b !== void 0 ? _b : totalCount,
|
|
21
|
+
})));
|
|
22
22
|
};
|
|
23
23
|
var List = React.forwardRef(function (_a, forwardedRef) {
|
|
24
24
|
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, children = _a.children, virtual = _a.virtual, scrollElement = _a.scrollElement, _c = _a.overscanCount, overscanCount = _c === void 0 ? DEFAULT_OVER_SCAN_COUNT : _c, _d = _a.estimateItemSize, estimateItemSize = _d === void 0 ? DEFAULT_LIST_ITEM_HEIGHT : _d, _e = _a.role, role = _e === void 0 ? 'list' : _e, autoScrollToSelectedItem = _a.autoScrollToSelectedItem, style = _a.style, className = _a.className, _f = _a.keepFirstItemMounted, keepFirstItemMounted = _f === void 0 ? false : _f, restProps = __rest(_a, ["overrides", "children", "virtual", "scrollElement", "overscanCount", "estimateItemSize", "role", "autoScrollToSelectedItem", "style", "className", "keepFirstItemMounted"]);
|
|
@@ -50,13 +50,10 @@ var List = React.forwardRef(function (_a, forwardedRef) {
|
|
|
50
50
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- scrollToIndex on mount only
|
|
51
51
|
}, []);
|
|
52
52
|
if (virtual) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
, __assign({
|
|
56
|
-
// NOTE: resetting margin and padding here. should be removed when normalize css merges
|
|
57
|
-
className: "w-full relative p-0 m-0", style: {
|
|
53
|
+
var _h = splitA11yProps(restProps), a11yProps = _h.a11yProps, otherProps = _h.otherProps;
|
|
54
|
+
return (_jsx(Root, __assign({ "data-spaceweb": "list", "$as": "div" }, otherProps, rootProps, { ref: combinedRef, style: [{ '--sw-min-width': px2rem(LIST_MIN_WIDTH) }, style, rootProps === null || rootProps === void 0 ? void 0 : rootProps.style], className: [className, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className] }, { children: _jsx(Box, __assign({ className: "w-full relative p-0", style: {
|
|
58
55
|
height: "".concat(rowVirtualizer.getTotalSize(), "px"),
|
|
59
|
-
}, "$as": "ul" }, { children: rowVirtualizer
|
|
56
|
+
}, "$as": "ul", role: role }, a11yProps, { children: rowVirtualizer
|
|
60
57
|
.getVirtualItems()
|
|
61
58
|
.map(function (virtualRow) { return getCloneElement(childrenArr[virtualRow.index], virtualRow, childrenArr.length); }) })) })));
|
|
62
59
|
}
|
package/esm/list/utils.d.ts
CHANGED
|
@@ -4,3 +4,11 @@ export declare const measureElement: typeof measureElementType;
|
|
|
4
4
|
* Keeps the first item mounted even when it falls outside the range.
|
|
5
5
|
*/
|
|
6
6
|
export declare const customRangeExtractor: (range: Range) => number[];
|
|
7
|
+
export declare const splitA11yProps: (props: Record<string, unknown>) => {
|
|
8
|
+
a11yProps: Record<string, unknown>;
|
|
9
|
+
otherProps: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export declare const isPresentationalRole: (role?: string | null) => boolean;
|
|
12
|
+
export declare const omitContainerAriaProps: ({ "aria-posinset": _ariaPosInSet, "aria-setsize": _ariaSetSize, ...rest }: Record<string, unknown>) => {
|
|
13
|
+
[x: string]: unknown;
|
|
14
|
+
};
|
package/esm/list/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __read, __spreadArray } from "tslib";
|
|
1
|
+
import { __read, __rest, __spreadArray, __values } from "tslib";
|
|
2
2
|
import { defaultRangeExtractor } from '@tanstack/react-virtual';
|
|
3
3
|
var parseMeasurement = function (str) { return parseFloat(str) || 0; };
|
|
4
4
|
// by default react-virtual uses getBoundingClientRect to calculate dimensions.
|
|
@@ -23,3 +23,30 @@ export var customRangeExtractor = function (range) {
|
|
|
23
23
|
// Otherwise, prepend the first item to the default indices.
|
|
24
24
|
return __spreadArray([0], __read(defaultIndices), false);
|
|
25
25
|
};
|
|
26
|
+
var isA11yProp = function (key) { return key === 'id' || key === 'tabIndex' || key.startsWith('aria-'); };
|
|
27
|
+
export var splitA11yProps = function (props) {
|
|
28
|
+
var e_1, _a;
|
|
29
|
+
var a11yProps = {};
|
|
30
|
+
var otherProps = {};
|
|
31
|
+
try {
|
|
32
|
+
for (var _b = __values(Object.entries(props)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
33
|
+
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
34
|
+
(isA11yProp(key) ? a11yProps : otherProps)[key] = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
38
|
+
finally {
|
|
39
|
+
try {
|
|
40
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
41
|
+
}
|
|
42
|
+
finally { if (e_1) throw e_1.error; }
|
|
43
|
+
}
|
|
44
|
+
return { a11yProps: a11yProps, otherProps: otherProps };
|
|
45
|
+
};
|
|
46
|
+
export var isPresentationalRole = function (role) {
|
|
47
|
+
return role === 'presentation' || role === 'none' || role === 'separator';
|
|
48
|
+
};
|
|
49
|
+
export var omitContainerAriaProps = function (_a) {
|
|
50
|
+
var _ariaPosInSet = _a["aria-posinset"], _ariaSetSize = _a["aria-setsize"], rest = __rest(_a, ['aria-posinset', 'aria-setsize']);
|
|
51
|
+
return rest;
|
|
52
|
+
};
|