@sprinklrjs/spaceweb 14.12.0 → 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/asyncSelect/hooks/useAsyncOptionHandlers.js +3 -2
- package/baseui/layer/tether.js +5 -5
- package/esm/asyncSelect/hooks/useAsyncOptionHandlers.js +4 -3
- 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
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useRef } from 'react';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import _pick from 'lodash/pick';
|
|
6
6
|
import { Select as DefaultSelect } from '../select';
|
|
7
7
|
import { ListItem } from '../list';
|
|
8
8
|
import { Typography } from '../typography';
|
|
9
|
+
import { Box } from '../box';
|
|
9
10
|
import FlagContainer from './flag-container';
|
|
10
11
|
import { useLocale } from '../locale';
|
|
11
12
|
import { mergeOverrides, useOverrides } from '../overrides';
|
|
12
|
-
import { iso2FlagEmoji, countrySelectFilterOptions } from './utils';
|
|
13
|
+
import { iso2FlagEmoji, countrySelectFilterOptions, resolveCountryLabelParts } from './utils';
|
|
13
14
|
import { COUNTRY_SELECT_OPTIONS } from './constants';
|
|
14
15
|
import { POPOVER_MARGIN } from '../popover/types';
|
|
15
16
|
var SelectListItem = React.forwardRef(function (_a, ref) {
|
|
16
|
-
var mapIsoToLabel = _a.mapIsoToLabel,
|
|
17
|
-
|
|
17
|
+
var mapIsoToLabel = _a.mapIsoToLabel, country = _a.$item, rest = __rest(_a, ["mapIsoToLabel", "$item"]);
|
|
18
|
+
var id = country.id, dialCode = country.dialCode;
|
|
19
|
+
var _b = resolveCountryLabelParts(country, mapIsoToLabel), primaryName = _b.primaryName, nativeName = _b.nativeName, nativeLang = _b.nativeLang;
|
|
20
|
+
return (_jsxs(ListItem, __assign({}, rest, { startEnhancer: iso2FlagEmoji(id), ref: ref }, { children: [dialCode, _jsxs(Typography, __assign({ "data-testid": id, "data-entity-type": "country-label", className: "spr-text-03 ml-1" }, { children: ["(", primaryName, nativeName && nativeLang ? (_jsxs(_Fragment, { children: [' (', _jsx(Box, __assign({ "$as": "span", lang: nativeLang }, { children: nativeName })), ")"] })) : null, _jsx(Box, __assign({ "$as": "span" }, { children: ")" }))] }))] })));
|
|
18
21
|
});
|
|
19
22
|
var CountrySelect = function (props) {
|
|
20
23
|
var size = props.size, disabled = props.disabled, inputRef = props.inputRef, onChange = props.onChange, countries = props.countries, value = props.value, mapIsoToLabel = props.mapIsoToLabel, maxDropdownHeight = props.maxDropdownHeight, maxDropdownWidth = props.maxDropdownWidth, overrides = props.overrides;
|
|
@@ -7,6 +7,14 @@ export type Country = {
|
|
|
7
7
|
id: keyof typeof COUNTRIES;
|
|
8
8
|
label: string;
|
|
9
9
|
dialCode: string;
|
|
10
|
+
/**
|
|
11
|
+
* The portion of `label` (without the wrapping parentheses) that is rendered in a language
|
|
12
|
+
* other than the component's default (English), e.g. `'भारत'` for India. Used to apply the
|
|
13
|
+
* correct `lang` attribute to that segment for screen reader pronunciation (WCAG 3.1.2).
|
|
14
|
+
*/
|
|
15
|
+
nativeName?: string;
|
|
16
|
+
/** BCP 47 language tag for `nativeName`, e.g. `'hi'` for Hindi. */
|
|
17
|
+
nativeLang?: string;
|
|
10
18
|
};
|
|
11
19
|
export type State = {
|
|
12
20
|
country: Country;
|
|
@@ -22,11 +30,26 @@ export type PhoneInputOverrides = {
|
|
|
22
30
|
FlagContainer?: Override<SharedProps & Record<string, any>>;
|
|
23
31
|
DialCode?: Override<SharedProps & Record<string, any>>;
|
|
24
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Custom country label for `mapIsoToLabel`. Provide both `nativeName` and `nativeLang` when a
|
|
35
|
+
* native-language segment should be marked with `lang` (WCAG 3.1.2); otherwise only `label` is used.
|
|
36
|
+
*/
|
|
37
|
+
export type CustomCountryLabel = {
|
|
38
|
+
label: string;
|
|
39
|
+
nativeName?: string;
|
|
40
|
+
nativeLang?: string;
|
|
41
|
+
};
|
|
25
42
|
export type PhoneInputProps = Omit<InputProps, 'value' | 'onChange'> & {
|
|
26
43
|
onInputChange?: (event: React.SyntheticEvent<HTMLInputElement>) => unknown;
|
|
27
44
|
onChange?: (value: Value) => void;
|
|
28
45
|
value?: Value;
|
|
29
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Maps an ISO country code to the dropdown label. Return a `string` to replace the whole label
|
|
48
|
+
* (legacy behavior), or a `CustomCountryLabel` with both `nativeName` and `nativeLang` to mark
|
|
49
|
+
* a native-language segment with `lang` (WCAG 3.1.2). Object results missing either native field
|
|
50
|
+
* are flattened into a single label string.
|
|
51
|
+
*/
|
|
52
|
+
mapIsoToLabel?: (iso: string) => string | CustomCountryLabel;
|
|
30
53
|
maxDropdownHeight?: string;
|
|
31
54
|
countries?: Array<Country>;
|
|
32
55
|
maxDropdownWidth?: string;
|
|
@@ -9,7 +9,7 @@ declare const useStatefulPhoneInput: ({ clearable, disabled, id, initialState, i
|
|
|
9
9
|
intent: import("..").Intent | undefined;
|
|
10
10
|
maxDropdownHeight: string;
|
|
11
11
|
maxDropdownWidth: string;
|
|
12
|
-
mapIsoToLabel: ((iso: string) => string) | undefined;
|
|
12
|
+
mapIsoToLabel: ((iso: string) => string | import("./types").CustomCountryLabel) | undefined;
|
|
13
13
|
name: string | undefined;
|
|
14
14
|
overrides: import("../input").BaseInputOverrides & {
|
|
15
15
|
Root?: import("../overrides").Override<import("../input").SharedProps & Record<string, any>> | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Value as ValueT } from '../select/types';
|
|
2
|
-
import type { Value, Country } from './types';
|
|
2
|
+
import type { Value, Country, CustomCountryLabel } from './types';
|
|
3
3
|
export declare const iso2FlagEmoji: (iso: string) => string | undefined;
|
|
4
4
|
export declare const sanitize: (value?: string) => string;
|
|
5
5
|
export declare const getPhoneNumberWithCountryDialCode: (value: Value) => string | undefined;
|
|
@@ -11,3 +11,27 @@ export declare const getDefaultValue: (countries?: Country[]) => {
|
|
|
11
11
|
country: Country;
|
|
12
12
|
phoneNumber: string;
|
|
13
13
|
};
|
|
14
|
+
export type CountryLabelParts = {
|
|
15
|
+
primaryName: string;
|
|
16
|
+
nativeName?: string;
|
|
17
|
+
nativeLang?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Splits a country's `label` (e.g. `'India (भारत)'`) into the default-language name and the
|
|
21
|
+
* trailing native-language segment (if any), so the native segment can be given its own `lang`
|
|
22
|
+
* attribute for correct screen reader pronunciation (WCAG 3.1.2 - Language of Parts).
|
|
23
|
+
*
|
|
24
|
+
* Requires both `nativeName` and `nativeLang`. Falls back to the whole `label` as `primaryName`
|
|
25
|
+
* if either is missing or `nativeName` is not actually a trailing `label` suffix, so incomplete
|
|
26
|
+
* data never breaks rendering or ships a native segment without a language tag.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getCountryLabelParts: ({ label, nativeName, nativeLang }: Country) => CountryLabelParts;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the label parts to render for a country option, honoring an optional `mapIsoToLabel`
|
|
31
|
+
* override (string or `{ label, nativeName?, nativeLang? }`).
|
|
32
|
+
*
|
|
33
|
+
* String overrides replace the whole label (legacy behavior). Object overrides only split out a
|
|
34
|
+
* `lang`-tagged native segment when both `nativeName` and `nativeLang` are provided; otherwise the
|
|
35
|
+
* visible text is flattened into `primaryName` so display stays correct without invalid markup.
|
|
36
|
+
*/
|
|
37
|
+
export declare const resolveCountryLabelParts: (country: Country, mapIsoToLabel?: ((iso: string) => string | CustomCountryLabel) | undefined) => CountryLabelParts;
|
package/esm/phone-input/utils.js
CHANGED
|
@@ -30,3 +30,52 @@ export var countrySelectFilterOptions = function (options, filterValue, excludeO
|
|
|
30
30
|
export var getDefaultValue = function (countries) {
|
|
31
31
|
return countries && !_isEmpty(countries) ? { country: COUNTRIES[countries[0].id], phoneNumber: '' } : defaultValue;
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Splits a country's `label` (e.g. `'India (भारत)'`) into the default-language name and the
|
|
35
|
+
* trailing native-language segment (if any), so the native segment can be given its own `lang`
|
|
36
|
+
* attribute for correct screen reader pronunciation (WCAG 3.1.2 - Language of Parts).
|
|
37
|
+
*
|
|
38
|
+
* Requires both `nativeName` and `nativeLang`. Falls back to the whole `label` as `primaryName`
|
|
39
|
+
* if either is missing or `nativeName` is not actually a trailing `label` suffix, so incomplete
|
|
40
|
+
* data never breaks rendering or ships a native segment without a language tag.
|
|
41
|
+
*/
|
|
42
|
+
export var getCountryLabelParts = function (_a) {
|
|
43
|
+
var label = _a.label, nativeName = _a.nativeName, nativeLang = _a.nativeLang;
|
|
44
|
+
if (!nativeName || !nativeLang) {
|
|
45
|
+
return { primaryName: label };
|
|
46
|
+
}
|
|
47
|
+
var nativeNameSuffix = "(".concat(nativeName, ")");
|
|
48
|
+
var suffixStartIndex = label.lastIndexOf(nativeNameSuffix);
|
|
49
|
+
var isSuffixAtEnd = suffixStartIndex !== -1 && suffixStartIndex + nativeNameSuffix.length === label.length;
|
|
50
|
+
if (!isSuffixAtEnd) {
|
|
51
|
+
return { primaryName: label };
|
|
52
|
+
}
|
|
53
|
+
return { primaryName: label.slice(0, suffixStartIndex).trimEnd(), nativeName: nativeName, nativeLang: nativeLang };
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Resolves the label parts to render for a country option, honoring an optional `mapIsoToLabel`
|
|
57
|
+
* override (string or `{ label, nativeName?, nativeLang? }`).
|
|
58
|
+
*
|
|
59
|
+
* String overrides replace the whole label (legacy behavior). Object overrides only split out a
|
|
60
|
+
* `lang`-tagged native segment when both `nativeName` and `nativeLang` are provided; otherwise the
|
|
61
|
+
* visible text is flattened into `primaryName` so display stays correct without invalid markup.
|
|
62
|
+
*/
|
|
63
|
+
export var resolveCountryLabelParts = function (country, mapIsoToLabel) {
|
|
64
|
+
if (!mapIsoToLabel) {
|
|
65
|
+
return getCountryLabelParts(country);
|
|
66
|
+
}
|
|
67
|
+
var mapped = mapIsoToLabel(country.id);
|
|
68
|
+
if (typeof mapped === 'string') {
|
|
69
|
+
return { primaryName: mapped };
|
|
70
|
+
}
|
|
71
|
+
if (!mapped.nativeName || !mapped.nativeLang) {
|
|
72
|
+
return {
|
|
73
|
+
primaryName: mapped.nativeName ? "".concat(mapped.label, " (").concat(mapped.nativeName, ")") : mapped.label,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
primaryName: mapped.label,
|
|
78
|
+
nativeName: mapped.nativeName,
|
|
79
|
+
nativeLang: mapped.nativeLang,
|
|
80
|
+
};
|
|
81
|
+
};
|
package/input/base-input.js
CHANGED
|
@@ -143,7 +143,7 @@ var BaseInput = function (_a) {
|
|
|
143
143
|
var hasScroll = inputRef.current && inputRef.current.scrollHeight > inputRef.current.clientHeight;
|
|
144
144
|
var charCount = typeof value === 'string' ? value.length : 0;
|
|
145
145
|
var ariaLabel = 'Clear value';
|
|
146
|
-
return ((0, jsx_runtime_1.jsxs)(InputContainer, tslib_1.__assign({ "data-spaceweb": "base-input" }, sharedProps, inputContainerProps, { children: [(0, jsx_runtime_1.jsx)(Before, tslib_1.__assign({}, sharedProps, beforeProps)), (0, jsx_runtime_1.jsx)(Input, tslib_1.__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 === constants_1.CUSTOM_INPUT_TYPE.textarea ? rows : null }, sharedProps, inputProps)), showClearIcon ? ((0, jsx_runtime_1.jsx)(ClearIconContainer, tslib_1.__assign({ "$alignTop": type === constants_1.CUSTOM_INPUT_TYPE.textarea }, sharedProps, clearIconContainerProps, { children: (0, jsx_runtime_1.jsx)(ClearIcon, tslib_1.__assign({ title: ariaLabel, "aria-label": ariaLabel, onClick: onClearIconClick, onKeyDown: function (event) {
|
|
146
|
+
return ((0, jsx_runtime_1.jsxs)(InputContainer, tslib_1.__assign({ "data-spaceweb": "base-input" }, sharedProps, inputContainerProps, { children: [(0, jsx_runtime_1.jsx)(Before, tslib_1.__assign({}, sharedProps, beforeProps)), (0, jsx_runtime_1.jsx)(Input, tslib_1.__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 === constants_1.CUSTOM_INPUT_TYPE.textarea ? rows : null }, sharedProps, inputProps)), showClearIcon ? ((0, jsx_runtime_1.jsx)(ClearIconContainer, tslib_1.__assign({ "$alignTop": type === constants_1.CUSTOM_INPUT_TYPE.textarea }, sharedProps, clearIconContainerProps, { children: (0, jsx_runtime_1.jsx)(ClearIcon, tslib_1.__assign({ title: ariaLabel, "aria-label": ariaLabel, onClick: onClearIconClick, onKeyDown: function (event) {
|
|
147
147
|
if (event.key && (event.key === 'Enter' || event.key === ' ')) {
|
|
148
148
|
event.preventDefault();
|
|
149
149
|
onClearIconClick();
|
package/list/divider.js
CHANGED
|
@@ -6,15 +6,17 @@ var react_1 = require("react");
|
|
|
6
6
|
var overrides_1 = require("../overrides");
|
|
7
7
|
var list_item_1 = tslib_1.__importDefault(require("./list-item"));
|
|
8
8
|
var styled_component_1 = require("./styled-component");
|
|
9
|
+
var utils_1 = require("./utils");
|
|
9
10
|
var Divider = (0, react_1.forwardRef)(function (_a, ref) {
|
|
10
11
|
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 = tslib_1.__rest(_a, ["children", "first", "overrides", "className"]);
|
|
11
12
|
var _d = tslib_1.__read((0, overrides_1.useOverrides)(overrides.Separator, styled_component_1.StyledListItemDivider), 2), Separator = _d[0], separatorProps = _d[1];
|
|
12
13
|
var _e = tslib_1.__read((0, overrides_1.useOverrides)(overrides.SubHeader, list_item_1.default), 2), SubHeader = _e[0], subHeaderProps = _e[1];
|
|
14
|
+
var propsWithoutContainerAria = (0, utils_1.omitContainerAriaProps)(restProps);
|
|
13
15
|
return children ? ((0, jsx_runtime_1.jsx)(SubHeader, tslib_1.__assign({ className: [
|
|
14
16
|
'spr-border-primary border-solid border-b-0 border-l-0 border-r-0 mx-0 rounded-0',
|
|
15
17
|
first ? 'border-t-0 pt-0' : 'border-t',
|
|
16
18
|
className,
|
|
17
|
-
], "
|
|
19
|
+
], role: "presentation" }, propsWithoutContainerAria, subHeaderProps, { ref: ref }, { children: children }))) : ((0, jsx_runtime_1.jsx)(Separator, tslib_1.__assign({ "data-spaceweb": "divider", role: "presentation", className: className }, propsWithoutContainerAria, { ref: ref }, separatorProps)));
|
|
18
20
|
});
|
|
19
21
|
Divider.displayName = 'Divider';
|
|
20
22
|
exports.default = Divider;
|
package/list/list.js
CHANGED
|
@@ -13,14 +13,14 @@ var constants_1 = require("./constants");
|
|
|
13
13
|
var style_1 = require("../style");
|
|
14
14
|
var getCloneElement = function (item, virtualRow, totalCount) {
|
|
15
15
|
var _a, _b;
|
|
16
|
-
return React.cloneElement(item, {
|
|
17
|
-
style: [{ '--sw-translate-y': "".concat(virtualRow.start, "px") }, item.props.style],
|
|
18
|
-
className: ['w-full absolute top-0 left-0 box-border translate-y-[--sw-translate-y]'],
|
|
16
|
+
return React.cloneElement(item, tslib_1.__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]'],
|
|
19
17
|
// @ts-expect-error TS(2339): Property 'ref' does not exist on type 'ReactElemen... Remove this comment to see the full error message
|
|
20
|
-
ref: (0, useCombinedRef_1.combineRefs)(virtualRow.measureElement, item.ref),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
ref: (0, useCombinedRef_1.combineRefs)(virtualRow.measureElement, item.ref) }, ((0, utils_1.isPresentationalRole)(item.props.role)
|
|
19
|
+
? {}
|
|
20
|
+
: {
|
|
21
|
+
'aria-posinset': (_a = item.props['aria-posinset']) !== null && _a !== void 0 ? _a : virtualRow.index + 1,
|
|
22
|
+
'aria-setsize': (_b = item.props['aria-setsize']) !== null && _b !== void 0 ? _b : totalCount,
|
|
23
|
+
})));
|
|
24
24
|
};
|
|
25
25
|
var List = React.forwardRef(function (_a, forwardedRef) {
|
|
26
26
|
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 ? constants_1.DEFAULT_OVER_SCAN_COUNT : _c, _d = _a.estimateItemSize, estimateItemSize = _d === void 0 ? constants_1.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 = tslib_1.__rest(_a, ["overrides", "children", "virtual", "scrollElement", "overscanCount", "estimateItemSize", "role", "autoScrollToSelectedItem", "style", "className", "keepFirstItemMounted"]);
|
|
@@ -52,13 +52,10 @@ var List = React.forwardRef(function (_a, forwardedRef) {
|
|
|
52
52
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- scrollToIndex on mount only
|
|
53
53
|
}, []);
|
|
54
54
|
if (virtual) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
, tslib_1.__assign({
|
|
58
|
-
// NOTE: resetting margin and padding here. should be removed when normalize css merges
|
|
59
|
-
className: "w-full relative p-0 m-0", style: {
|
|
55
|
+
var _h = (0, utils_1.splitA11yProps)(restProps), a11yProps = _h.a11yProps, otherProps = _h.otherProps;
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(Root, tslib_1.__assign({ "data-spaceweb": "list", "$as": "div" }, otherProps, rootProps, { ref: combinedRef, style: [{ '--sw-min-width': px2rem(styled_component_1.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: (0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({ className: "w-full relative p-0", style: {
|
|
60
57
|
height: "".concat(rowVirtualizer.getTotalSize(), "px"),
|
|
61
|
-
}, "$as": "ul" }, { children: rowVirtualizer
|
|
58
|
+
}, "$as": "ul", role: role }, a11yProps, { children: rowVirtualizer
|
|
62
59
|
.getVirtualItems()
|
|
63
60
|
.map(function (virtualRow) { return getCloneElement(childrenArr[virtualRow.index], virtualRow, childrenArr.length); }) })) })));
|
|
64
61
|
}
|
package/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/list/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.customRangeExtractor = exports.measureElement = void 0;
|
|
3
|
+
exports.omitContainerAriaProps = exports.isPresentationalRole = exports.splitA11yProps = exports.customRangeExtractor = exports.measureElement = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_virtual_1 = require("@tanstack/react-virtual");
|
|
6
6
|
var parseMeasurement = function (str) { return parseFloat(str) || 0; };
|
|
@@ -28,3 +28,33 @@ var customRangeExtractor = function (range) {
|
|
|
28
28
|
return tslib_1.__spreadArray([0], tslib_1.__read(defaultIndices), false);
|
|
29
29
|
};
|
|
30
30
|
exports.customRangeExtractor = customRangeExtractor;
|
|
31
|
+
var isA11yProp = function (key) { return key === 'id' || key === 'tabIndex' || key.startsWith('aria-'); };
|
|
32
|
+
var splitA11yProps = function (props) {
|
|
33
|
+
var e_1, _a;
|
|
34
|
+
var a11yProps = {};
|
|
35
|
+
var otherProps = {};
|
|
36
|
+
try {
|
|
37
|
+
for (var _b = tslib_1.__values(Object.entries(props)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
38
|
+
var _d = tslib_1.__read(_c.value, 2), key = _d[0], value = _d[1];
|
|
39
|
+
(isA11yProp(key) ? a11yProps : otherProps)[key] = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
43
|
+
finally {
|
|
44
|
+
try {
|
|
45
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
46
|
+
}
|
|
47
|
+
finally { if (e_1) throw e_1.error; }
|
|
48
|
+
}
|
|
49
|
+
return { a11yProps: a11yProps, otherProps: otherProps };
|
|
50
|
+
};
|
|
51
|
+
exports.splitA11yProps = splitA11yProps;
|
|
52
|
+
var isPresentationalRole = function (role) {
|
|
53
|
+
return role === 'presentation' || role === 'none' || role === 'separator';
|
|
54
|
+
};
|
|
55
|
+
exports.isPresentationalRole = isPresentationalRole;
|
|
56
|
+
var omitContainerAriaProps = function (_a) {
|
|
57
|
+
var _ariaPosInSet = _a["aria-posinset"], _ariaSetSize = _a["aria-setsize"], rest = tslib_1.__rest(_a, ['aria-posinset', 'aria-setsize']);
|
|
58
|
+
return rest;
|
|
59
|
+
};
|
|
60
|
+
exports.omitContainerAriaProps = omitContainerAriaProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprinklrjs/spaceweb",
|
|
3
|
-
"version": "14.12.
|
|
3
|
+
"version": "14.12.2",
|
|
4
4
|
"description": "Components for SpaceWeb",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"ts-node": "^10.4.0"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@sprinklrjs/spaceweb-themes": "14.12.
|
|
103
|
+
"@sprinklrjs/spaceweb-themes": "14.12.2",
|
|
104
104
|
"react": ">=17.0.2 <19.0.0",
|
|
105
105
|
"react-dom": ">=17.0.2 <19.0.0"
|
|
106
106
|
}
|