@sprinklrjs/spaceweb 14.11.3 → 14.11.5
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/useAsyncSelect.d.ts +3 -3
- package/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +3 -3
- package/checkbox/checkbox.d.ts +1 -1
- package/checkbox/checkbox.js +5 -4
- package/checkbox/types.d.ts +8 -6
- package/esm/asyncSelect/hooks/useAsyncSelect.d.ts +3 -3
- package/esm/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +3 -3
- package/esm/checkbox/checkbox.d.ts +1 -1
- package/esm/checkbox/checkbox.js +6 -5
- package/esm/checkbox/types.d.ts +8 -6
- package/esm/form-control/form-control.d.ts +1 -1
- package/esm/form-control/form-control.js +1 -1
- package/esm/menu/StatefulSubMenu.d.ts +1 -1
- package/esm/menu/SubMenu.d.ts +1 -1
- package/esm/menu/index.d.ts +1 -1
- package/esm/menu/menu-item.js +35 -33
- package/esm/menu/menu.d.ts +1 -1
- package/esm/menu/types.d.ts +10 -2
- package/esm/select/selectMenuAdapter/CollapsibleSelectMenu.d.ts +1 -1
- package/esm/select/selectMenuAdapter/SelectMenuItem.d.ts +2 -0
- package/esm/tag/tag.d.ts +1 -0
- package/esm/tag/tag.js +2 -2
- package/esm/tag/types.d.ts +5 -4
- package/form-control/form-control.d.ts +1 -1
- package/form-control/form-control.js +1 -1
- package/menu/StatefulSubMenu.d.ts +1 -1
- package/menu/SubMenu.d.ts +1 -1
- package/menu/index.d.ts +1 -1
- package/menu/menu-item.js +34 -32
- package/menu/menu.d.ts +1 -1
- package/menu/types.d.ts +10 -2
- package/package.json +3 -2
- package/select/selectMenuAdapter/CollapsibleSelectMenu.d.ts +1 -1
- package/select/selectMenuAdapter/SelectMenuItem.d.ts +2 -0
- package/tag/tag.d.ts +1 -0
- package/tag/tag.js +2 -2
- package/tag/types.d.ts +5 -4
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -151,7 +151,7 @@ export declare const useAsyncSelect: ({ loadOptions, initialOptions, resolveSele
|
|
|
151
151
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
152
152
|
virtual?: boolean | undefined;
|
|
153
153
|
selectOnTab?: boolean | undefined;
|
|
154
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
154
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
155
155
|
captureScroll?: boolean | undefined;
|
|
156
156
|
popoverMinWidth?: string | undefined;
|
|
157
157
|
createOption?: ((label: string) => import("../../select").Options | Promise<import("../../select").Options>) | undefined;
|
|
@@ -329,7 +329,7 @@ export declare const useAsyncSelect: ({ loadOptions, initialOptions, resolveSele
|
|
|
329
329
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
330
330
|
virtual?: boolean | undefined;
|
|
331
331
|
selectOnTab?: boolean | undefined;
|
|
332
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
332
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
333
333
|
captureScroll?: boolean | undefined;
|
|
334
334
|
overlayWidth?: string | undefined;
|
|
335
335
|
scrollContainer?: "overlayContainer" | "menuContainer" | undefined;
|
|
@@ -510,7 +510,7 @@ export declare const useAsyncSelect: ({ loadOptions, initialOptions, resolveSele
|
|
|
510
510
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
511
511
|
virtual?: boolean | undefined;
|
|
512
512
|
selectOnTab?: boolean | undefined;
|
|
513
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
513
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
514
514
|
captureScroll?: boolean | undefined;
|
|
515
515
|
overlayWidth?: string | undefined;
|
|
516
516
|
scrollContainer?: "overlayContainer" | "menuContainer" | undefined;
|
|
@@ -119,7 +119,7 @@ export declare const useGroupedAsyncSelect: ({ onChange, showSelectAll, selectAl
|
|
|
119
119
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
120
120
|
virtual?: boolean | undefined;
|
|
121
121
|
selectOnTab?: boolean | undefined;
|
|
122
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
122
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
123
123
|
captureScroll?: boolean | undefined;
|
|
124
124
|
popoverMinWidth?: string | undefined;
|
|
125
125
|
createOption?: ((label: string) => import("../../select").Options | Promise<import("../../select").Options>) | undefined;
|
|
@@ -265,7 +265,7 @@ export declare const useGroupedAsyncSelect: ({ onChange, showSelectAll, selectAl
|
|
|
265
265
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
266
266
|
virtual?: boolean | undefined;
|
|
267
267
|
selectOnTab?: boolean | undefined;
|
|
268
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
268
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
269
269
|
captureScroll?: boolean | undefined;
|
|
270
270
|
overlayWidth?: string | undefined;
|
|
271
271
|
popoverMinWidth?: string | undefined;
|
|
@@ -413,7 +413,7 @@ export declare const useGroupedAsyncSelect: ({ onChange, showSelectAll, selectAl
|
|
|
413
413
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
414
414
|
virtual?: boolean | undefined;
|
|
415
415
|
selectOnTab?: boolean | undefined;
|
|
416
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
416
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
417
417
|
captureScroll?: boolean | undefined;
|
|
418
418
|
overlayWidth?: string | undefined;
|
|
419
419
|
popoverMinWidth?: string | undefined;
|
package/checkbox/checkbox.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CheckboxProps } from './types';
|
|
2
2
|
declare const Checkbox: {
|
|
3
|
-
({ overrides, checked, containsInteractiveElement, disabled, autoFocus, isIndeterminate, error, checkmarkType, onChange, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onFocus, onBlur, required, labelPlacement, value, id, name, children, title, "aria-label": _ariaLabel, "aria-describedby": ariaDescribedby, "aria-errormessage": ariaErrormessage, ariaLabel, inputRef, className, style, size, intent: _intent, $outlineStyle, $outlineColor, $outlineOffset, $outlineWidth, "data-spaceweb": dataSpaceweb, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ overrides, checked, containsInteractiveElement, disabled, autoFocus, isIndeterminate, error, checkmarkType, onChange, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onFocus, onBlur, required, labelPlacement, value, id, name, children, title, "aria-label": _ariaLabel, "aria-describedby": ariaDescribedby, "aria-errormessage": ariaErrormessage, ariaLabel, inputRef, className, style, size, intent: _intent, $outlineStyle, $outlineColor, $outlineOffset, $outlineWidth, "data-spaceweb": dataSpaceweb, ...restProps }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
__standard: string;
|
|
6
6
|
};
|
package/checkbox/checkbox.js
CHANGED
|
@@ -13,9 +13,10 @@ var context_1 = require("../form-control/context");
|
|
|
13
13
|
var style_1 = require("../style");
|
|
14
14
|
var tick_1 = tslib_1.__importDefault(require("../icon/components/tick"));
|
|
15
15
|
var subtract_1 = tslib_1.__importDefault(require("../icon/components/subtract"));
|
|
16
|
+
var box_1 = require("../box");
|
|
16
17
|
var stopPropagation = function (e) { return e.stopPropagation(); };
|
|
17
18
|
var Checkbox = function (_a) {
|
|
18
|
-
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, _d = _a.containsInteractiveElement, containsInteractiveElement = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, _g = _a.isIndeterminate, isIndeterminate = _g === void 0 ? false : _g, _h = _a.error, error = _h === void 0 ? false : _h, _j = _a.checkmarkType, checkmarkType = _j === void 0 ? constants_1.STYLE_TYPE.default : _j, _k = _a.onChange, onChange = _k === void 0 ? noop_1.default : _k, _l = _a.onMouseEnter, onMouseEnter = _l === void 0 ? noop_1.default : _l, _m = _a.onMouseLeave, onMouseLeave = _m === void 0 ? noop_1.default : _m, _o = _a.onMouseDown, onMouseDown = _o === void 0 ? noop_1.default : _o, _p = _a.onMouseUp, onMouseUp = _p === void 0 ? noop_1.default : _p, _q = _a.onFocus, onFocus = _q === void 0 ? noop_1.default : _q, _r = _a.onBlur, onBlur = _r === void 0 ? noop_1.default : _r, required = _a.required, _s = _a.labelPlacement, labelPlacement = _s === void 0 ? 'right' : _s, value = _a.value, id = _a.id, name = _a.name, children = _a.children, title = _a.title, _ariaLabel = _a["aria-label"], ariaDescribedby = _a["aria-describedby"], ariaErrormessage = _a["aria-errormessage"], ariaLabel = _a.ariaLabel, inputRef = _a.inputRef, className = _a.className, style = _a.style, _t = _a.size, size = _t === void 0 ? 'md' : _t, _intent = _a.intent, $outlineStyle = _a.$outlineStyle, $outlineColor = _a.$outlineColor, $outlineOffset = _a.$outlineOffset, $outlineWidth = _a.$outlineWidth, dataSpaceweb = _a["data-spaceweb"];
|
|
19
|
+
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, _d = _a.containsInteractiveElement, containsInteractiveElement = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, _g = _a.isIndeterminate, isIndeterminate = _g === void 0 ? false : _g, _h = _a.error, error = _h === void 0 ? false : _h, _j = _a.checkmarkType, checkmarkType = _j === void 0 ? constants_1.STYLE_TYPE.default : _j, _k = _a.onChange, onChange = _k === void 0 ? noop_1.default : _k, _l = _a.onMouseEnter, onMouseEnter = _l === void 0 ? noop_1.default : _l, _m = _a.onMouseLeave, onMouseLeave = _m === void 0 ? noop_1.default : _m, _o = _a.onMouseDown, onMouseDown = _o === void 0 ? noop_1.default : _o, _p = _a.onMouseUp, onMouseUp = _p === void 0 ? noop_1.default : _p, _q = _a.onFocus, onFocus = _q === void 0 ? noop_1.default : _q, _r = _a.onBlur, onBlur = _r === void 0 ? noop_1.default : _r, required = _a.required, _s = _a.labelPlacement, labelPlacement = _s === void 0 ? 'right' : _s, value = _a.value, id = _a.id, name = _a.name, children = _a.children, title = _a.title, _ariaLabel = _a["aria-label"], ariaDescribedby = _a["aria-describedby"], ariaErrormessage = _a["aria-errormessage"], ariaLabel = _a.ariaLabel, inputRef = _a.inputRef, className = _a.className, style = _a.style, _t = _a.size, size = _t === void 0 ? 'md' : _t, _intent = _a.intent, $outlineStyle = _a.$outlineStyle, $outlineColor = _a.$outlineColor, $outlineOffset = _a.$outlineOffset, $outlineWidth = _a.$outlineWidth, dataSpaceweb = _a["data-spaceweb"], restProps = tslib_1.__rest(_a, ["overrides", "checked", "containsInteractiveElement", "disabled", "autoFocus", "isIndeterminate", "error", "checkmarkType", "onChange", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "required", "labelPlacement", "value", "id", "name", "children", "title", 'aria-label', 'aria-describedby', 'aria-errormessage', "ariaLabel", "inputRef", "className", "style", "size", "intent", "$outlineStyle", "$outlineColor", "$outlineOffset", "$outlineWidth", 'data-spaceweb']);
|
|
19
20
|
var intent = (0, context_1.useContextualFormProps)({
|
|
20
21
|
intent: _intent,
|
|
21
22
|
}).intent;
|
|
@@ -109,7 +110,7 @@ var Checkbox = function (_a) {
|
|
|
109
110
|
};
|
|
110
111
|
var labelComp = children && ((0, jsx_runtime_1.jsx)(Label, tslib_1.__assign({}, sharedProps, labelProps, { children: containsInteractiveElement ? (
|
|
111
112
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- prevents the event from bubbling up to the label and moving focus to the radio button
|
|
112
|
-
(0, jsx_runtime_1.jsx)(
|
|
113
|
+
(0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({ onClick: function (e) { return e.preventDefault(); } }, { children: children }))) : (children) })));
|
|
113
114
|
var getCheckmarkIcon = function () {
|
|
114
115
|
if (isIndeterminate) {
|
|
115
116
|
return (0, jsx_runtime_1.jsx)(subtract_1.default, { size: size === 'medium' || size === 'large' ? 10 : 8 });
|
|
@@ -133,10 +134,10 @@ var Checkbox = function (_a) {
|
|
|
133
134
|
},
|
|
134
135
|
style,
|
|
135
136
|
rootProps === null || rootProps === void 0 ? void 0 : rootProps.style,
|
|
136
|
-
], className: [className, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className] }, { children: [(labelPlacement === 'top' || labelPlacement === 'left') && labelComp, checkmarkType === constants_1.STYLE_TYPE.toggle ? ((0, jsx_runtime_1.jsx)(ToggleTrack, tslib_1.__assign({}, sharedProps, toggleTrackProps, { children: (0, jsx_runtime_1.jsx)(Toggle, tslib_1.__assign({}, sharedProps, toggleProps)) }))) : (checkmarkComp), (0, jsx_runtime_1.jsx)(Input, tslib_1.__assign({ value: value, id: id, name: name, checked: checked, required: required,
|
|
137
|
+
], className: [className, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className] }, { children: [(labelPlacement === 'top' || labelPlacement === 'left') && labelComp, checkmarkType === constants_1.STYLE_TYPE.toggle ? ((0, jsx_runtime_1.jsx)(ToggleTrack, tslib_1.__assign({}, sharedProps, toggleTrackProps, { children: (0, jsx_runtime_1.jsx)(Toggle, tslib_1.__assign({}, sharedProps, toggleProps)) }))) : (checkmarkComp), (0, jsx_runtime_1.jsx)(Input, tslib_1.__assign({ value: value, id: id, name: name, checked: checked, required: required, disabled: disabled, type: "checkbox", ref: mergedRef,
|
|
137
138
|
// Prevent a second click event from firing when label is clicked.
|
|
138
139
|
// See https://github.com/uber/baseweb/issues/3847
|
|
139
|
-
onClick: stopPropagation, role: checkmarkType === constants_1.STYLE_TYPE.toggle ? 'switch' : undefined }, sharedProps, inputEvents, inputProps)), (labelPlacement === 'bottom' || labelPlacement === 'right') && labelComp] })));
|
|
140
|
+
onClick: stopPropagation, role: checkmarkType === constants_1.STYLE_TYPE.toggle ? 'switch' : undefined }, restProps, { "aria-label": ariaLabel || _ariaLabel, "aria-describedby": ariaDescribedby, "aria-checked": !!checked, "aria-errormessage": ariaErrormessage, "aria-invalid": error || null, "aria-required": required || null }, sharedProps, inputEvents, inputProps)), (labelPlacement === 'bottom' || labelPlacement === 'right') && labelComp] })));
|
|
140
141
|
};
|
|
141
142
|
exports.default = Checkbox;
|
|
142
143
|
Checkbox.displayName = 'Checkbox';
|
package/checkbox/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { SharedProps as BaseSharedProps } from '../baseui/input';
|
|
3
|
-
import { OutlineProps } from '../helpers/commonStyles';
|
|
4
|
-
import { Override } from '../overrides';
|
|
5
|
-
import { Intent, SpacewebComponentProps } from '../types';
|
|
6
|
-
import { STYLE_TYPE } from './constants';
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { SharedProps as BaseSharedProps } from '../baseui/input';
|
|
3
|
+
import type { OutlineProps } from '../helpers/commonStyles';
|
|
4
|
+
import type { Override } from '../overrides';
|
|
5
|
+
import type { Intent, SpacewebComponentProps } from '../types';
|
|
6
|
+
import type { STYLE_TYPE } from './constants';
|
|
7
7
|
export type StyleType = keyof typeof STYLE_TYPE;
|
|
8
8
|
export type LabelPlacement = 'top' | 'right' | 'bottom' | 'left';
|
|
9
9
|
/** @deprecated */
|
|
@@ -39,8 +39,10 @@ export type CheckboxOverrides = {
|
|
|
39
39
|
type BaseCheckboxProps = {
|
|
40
40
|
'aria-describedby'?: string;
|
|
41
41
|
'aria-errormessage'?: string;
|
|
42
|
+
'aria-hidden'?: boolean | 'true' | 'false';
|
|
42
43
|
ariaLabel?: string;
|
|
43
44
|
'aria-label'?: string;
|
|
45
|
+
tabIndex?: number;
|
|
44
46
|
children?: React.ReactNode;
|
|
45
47
|
containsInteractiveElement?: boolean;
|
|
46
48
|
overrides?: CheckboxOverrides;
|
|
@@ -151,7 +151,7 @@ export declare const useAsyncSelect: ({ loadOptions, initialOptions, resolveSele
|
|
|
151
151
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
152
152
|
virtual?: boolean | undefined;
|
|
153
153
|
selectOnTab?: boolean | undefined;
|
|
154
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
154
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
155
155
|
captureScroll?: boolean | undefined;
|
|
156
156
|
popoverMinWidth?: string | undefined;
|
|
157
157
|
createOption?: ((label: string) => import("../../select").Options | Promise<import("../../select").Options>) | undefined;
|
|
@@ -329,7 +329,7 @@ export declare const useAsyncSelect: ({ loadOptions, initialOptions, resolveSele
|
|
|
329
329
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
330
330
|
virtual?: boolean | undefined;
|
|
331
331
|
selectOnTab?: boolean | undefined;
|
|
332
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
332
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
333
333
|
captureScroll?: boolean | undefined;
|
|
334
334
|
overlayWidth?: string | undefined;
|
|
335
335
|
scrollContainer?: "overlayContainer" | "menuContainer" | undefined;
|
|
@@ -510,7 +510,7 @@ export declare const useAsyncSelect: ({ loadOptions, initialOptions, resolveSele
|
|
|
510
510
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
511
511
|
virtual?: boolean | undefined;
|
|
512
512
|
selectOnTab?: boolean | undefined;
|
|
513
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
513
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
514
514
|
captureScroll?: boolean | undefined;
|
|
515
515
|
overlayWidth?: string | undefined;
|
|
516
516
|
scrollContainer?: "overlayContainer" | "menuContainer" | undefined;
|
|
@@ -119,7 +119,7 @@ export declare const useGroupedAsyncSelect: ({ onChange, showSelectAll, selectAl
|
|
|
119
119
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
120
120
|
virtual?: boolean | undefined;
|
|
121
121
|
selectOnTab?: boolean | undefined;
|
|
122
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
122
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
123
123
|
captureScroll?: boolean | undefined;
|
|
124
124
|
popoverMinWidth?: string | undefined;
|
|
125
125
|
createOption?: ((label: string) => import("../../select").Options | Promise<import("../../select").Options>) | undefined;
|
|
@@ -265,7 +265,7 @@ export declare const useGroupedAsyncSelect: ({ onChange, showSelectAll, selectAl
|
|
|
265
265
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
266
266
|
virtual?: boolean | undefined;
|
|
267
267
|
selectOnTab?: boolean | undefined;
|
|
268
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
268
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
269
269
|
captureScroll?: boolean | undefined;
|
|
270
270
|
overlayWidth?: string | undefined;
|
|
271
271
|
popoverMinWidth?: string | undefined;
|
|
@@ -413,7 +413,7 @@ export declare const useGroupedAsyncSelect: ({ onChange, showSelectAll, selectAl
|
|
|
413
413
|
endEnhancerButtonProps?: import("../../select").SelectEnhancerButtonConfig | undefined;
|
|
414
414
|
virtual?: boolean | undefined;
|
|
415
415
|
selectOnTab?: boolean | undefined;
|
|
416
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
416
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
417
417
|
captureScroll?: boolean | undefined;
|
|
418
418
|
overlayWidth?: string | undefined;
|
|
419
419
|
popoverMinWidth?: string | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CheckboxProps } from './types';
|
|
2
2
|
declare const Checkbox: {
|
|
3
|
-
({ overrides, checked, containsInteractiveElement, disabled, autoFocus, isIndeterminate, error, checkmarkType, onChange, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onFocus, onBlur, required, labelPlacement, value, id, name, children, title, "aria-label": _ariaLabel, "aria-describedby": ariaDescribedby, "aria-errormessage": ariaErrormessage, ariaLabel, inputRef, className, style, size, intent: _intent, $outlineStyle, $outlineColor, $outlineOffset, $outlineWidth, "data-spaceweb": dataSpaceweb, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ overrides, checked, containsInteractiveElement, disabled, autoFocus, isIndeterminate, error, checkmarkType, onChange, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onFocus, onBlur, required, labelPlacement, value, id, name, children, title, "aria-label": _ariaLabel, "aria-describedby": ariaDescribedby, "aria-errormessage": ariaErrormessage, ariaLabel, inputRef, className, style, size, intent: _intent, $outlineStyle, $outlineColor, $outlineOffset, $outlineWidth, "data-spaceweb": dataSpaceweb, ...restProps }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
__standard: string;
|
|
6
6
|
};
|
package/esm/checkbox/checkbox.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __read } from "tslib";
|
|
1
|
+
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { getCheckmarkBackgroundColor, getCheckmarkBorderColor, getTrackBackgroundColor, getTrackBorderColor, StyledCheckmark, StyledInput, StyledLabel, StyledRoot, StyledToggle, StyledToggleTrack, } from './styled-components';
|
|
4
4
|
import { STYLE_TYPE } from './constants';
|
|
@@ -11,9 +11,10 @@ import { useContextualFormProps } from '../form-control/context';
|
|
|
11
11
|
import { useStyle } from '../style';
|
|
12
12
|
import Tick from '../icon/components/tick';
|
|
13
13
|
import Indeterminate from '../icon/components/subtract';
|
|
14
|
+
import { Box } from '../box';
|
|
14
15
|
var stopPropagation = function (e) { return e.stopPropagation(); };
|
|
15
16
|
var Checkbox = function (_a) {
|
|
16
|
-
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, _d = _a.containsInteractiveElement, containsInteractiveElement = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, _g = _a.isIndeterminate, isIndeterminate = _g === void 0 ? false : _g, _h = _a.error, error = _h === void 0 ? false : _h, _j = _a.checkmarkType, checkmarkType = _j === void 0 ? STYLE_TYPE.default : _j, _k = _a.onChange, onChange = _k === void 0 ? _noop : _k, _l = _a.onMouseEnter, onMouseEnter = _l === void 0 ? _noop : _l, _m = _a.onMouseLeave, onMouseLeave = _m === void 0 ? _noop : _m, _o = _a.onMouseDown, onMouseDown = _o === void 0 ? _noop : _o, _p = _a.onMouseUp, onMouseUp = _p === void 0 ? _noop : _p, _q = _a.onFocus, onFocus = _q === void 0 ? _noop : _q, _r = _a.onBlur, onBlur = _r === void 0 ? _noop : _r, required = _a.required, _s = _a.labelPlacement, labelPlacement = _s === void 0 ? 'right' : _s, value = _a.value, id = _a.id, name = _a.name, children = _a.children, title = _a.title, _ariaLabel = _a["aria-label"], ariaDescribedby = _a["aria-describedby"], ariaErrormessage = _a["aria-errormessage"], ariaLabel = _a.ariaLabel, inputRef = _a.inputRef, className = _a.className, style = _a.style, _t = _a.size, size = _t === void 0 ? 'md' : _t, _intent = _a.intent, $outlineStyle = _a.$outlineStyle, $outlineColor = _a.$outlineColor, $outlineOffset = _a.$outlineOffset, $outlineWidth = _a.$outlineWidth, dataSpaceweb = _a["data-spaceweb"];
|
|
17
|
+
var _b = _a.overrides, overrides = _b === void 0 ? {} : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, _d = _a.containsInteractiveElement, containsInteractiveElement = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, _g = _a.isIndeterminate, isIndeterminate = _g === void 0 ? false : _g, _h = _a.error, error = _h === void 0 ? false : _h, _j = _a.checkmarkType, checkmarkType = _j === void 0 ? STYLE_TYPE.default : _j, _k = _a.onChange, onChange = _k === void 0 ? _noop : _k, _l = _a.onMouseEnter, onMouseEnter = _l === void 0 ? _noop : _l, _m = _a.onMouseLeave, onMouseLeave = _m === void 0 ? _noop : _m, _o = _a.onMouseDown, onMouseDown = _o === void 0 ? _noop : _o, _p = _a.onMouseUp, onMouseUp = _p === void 0 ? _noop : _p, _q = _a.onFocus, onFocus = _q === void 0 ? _noop : _q, _r = _a.onBlur, onBlur = _r === void 0 ? _noop : _r, required = _a.required, _s = _a.labelPlacement, labelPlacement = _s === void 0 ? 'right' : _s, value = _a.value, id = _a.id, name = _a.name, children = _a.children, title = _a.title, _ariaLabel = _a["aria-label"], ariaDescribedby = _a["aria-describedby"], ariaErrormessage = _a["aria-errormessage"], ariaLabel = _a.ariaLabel, inputRef = _a.inputRef, className = _a.className, style = _a.style, _t = _a.size, size = _t === void 0 ? 'md' : _t, _intent = _a.intent, $outlineStyle = _a.$outlineStyle, $outlineColor = _a.$outlineColor, $outlineOffset = _a.$outlineOffset, $outlineWidth = _a.$outlineWidth, dataSpaceweb = _a["data-spaceweb"], restProps = __rest(_a, ["overrides", "checked", "containsInteractiveElement", "disabled", "autoFocus", "isIndeterminate", "error", "checkmarkType", "onChange", "onMouseEnter", "onMouseLeave", "onMouseDown", "onMouseUp", "onFocus", "onBlur", "required", "labelPlacement", "value", "id", "name", "children", "title", 'aria-label', 'aria-describedby', 'aria-errormessage', "ariaLabel", "inputRef", "className", "style", "size", "intent", "$outlineStyle", "$outlineColor", "$outlineOffset", "$outlineWidth", 'data-spaceweb']);
|
|
17
18
|
var intent = useContextualFormProps({
|
|
18
19
|
intent: _intent,
|
|
19
20
|
}).intent;
|
|
@@ -107,7 +108,7 @@ var Checkbox = function (_a) {
|
|
|
107
108
|
};
|
|
108
109
|
var labelComp = children && (_jsx(Label, __assign({}, sharedProps, labelProps, { children: containsInteractiveElement ? (
|
|
109
110
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- prevents the event from bubbling up to the label and moving focus to the radio button
|
|
110
|
-
_jsx(
|
|
111
|
+
_jsx(Box, __assign({ onClick: function (e) { return e.preventDefault(); } }, { children: children }))) : (children) })));
|
|
111
112
|
var getCheckmarkIcon = function () {
|
|
112
113
|
if (isIndeterminate) {
|
|
113
114
|
return _jsx(Indeterminate, { size: size === 'medium' || size === 'large' ? 10 : 8 });
|
|
@@ -131,10 +132,10 @@ var Checkbox = function (_a) {
|
|
|
131
132
|
},
|
|
132
133
|
style,
|
|
133
134
|
rootProps === null || rootProps === void 0 ? void 0 : rootProps.style,
|
|
134
|
-
], className: [className, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className] }, { children: [(labelPlacement === 'top' || labelPlacement === 'left') && labelComp, checkmarkType === STYLE_TYPE.toggle ? (_jsx(ToggleTrack, __assign({}, sharedProps, toggleTrackProps, { children: _jsx(Toggle, __assign({}, sharedProps, toggleProps)) }))) : (checkmarkComp), _jsx(Input, __assign({ value: value, id: id, name: name, checked: checked, required: required,
|
|
135
|
+
], className: [className, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className] }, { children: [(labelPlacement === 'top' || labelPlacement === 'left') && labelComp, checkmarkType === STYLE_TYPE.toggle ? (_jsx(ToggleTrack, __assign({}, sharedProps, toggleTrackProps, { children: _jsx(Toggle, __assign({}, sharedProps, toggleProps)) }))) : (checkmarkComp), _jsx(Input, __assign({ value: value, id: id, name: name, checked: checked, required: required, disabled: disabled, type: "checkbox", ref: mergedRef,
|
|
135
136
|
// Prevent a second click event from firing when label is clicked.
|
|
136
137
|
// See https://github.com/uber/baseweb/issues/3847
|
|
137
|
-
onClick: stopPropagation, role: checkmarkType === STYLE_TYPE.toggle ? 'switch' : undefined }, sharedProps, inputEvents, inputProps)), (labelPlacement === 'bottom' || labelPlacement === 'right') && labelComp] })));
|
|
138
|
+
onClick: stopPropagation, role: checkmarkType === STYLE_TYPE.toggle ? 'switch' : undefined }, restProps, { "aria-label": ariaLabel || _ariaLabel, "aria-describedby": ariaDescribedby, "aria-checked": !!checked, "aria-errormessage": ariaErrormessage, "aria-invalid": error || null, "aria-required": required || null }, sharedProps, inputEvents, inputProps)), (labelPlacement === 'bottom' || labelPlacement === 'right') && labelComp] })));
|
|
138
139
|
};
|
|
139
140
|
export default Checkbox;
|
|
140
141
|
Checkbox.displayName = 'Checkbox';
|
package/esm/checkbox/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { SharedProps as BaseSharedProps } from '../baseui/input';
|
|
3
|
-
import { OutlineProps } from '../helpers/commonStyles';
|
|
4
|
-
import { Override } from '../overrides';
|
|
5
|
-
import { Intent, SpacewebComponentProps } from '../types';
|
|
6
|
-
import { STYLE_TYPE } from './constants';
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { SharedProps as BaseSharedProps } from '../baseui/input';
|
|
3
|
+
import type { OutlineProps } from '../helpers/commonStyles';
|
|
4
|
+
import type { Override } from '../overrides';
|
|
5
|
+
import type { Intent, SpacewebComponentProps } from '../types';
|
|
6
|
+
import type { STYLE_TYPE } from './constants';
|
|
7
7
|
export type StyleType = keyof typeof STYLE_TYPE;
|
|
8
8
|
export type LabelPlacement = 'top' | 'right' | 'bottom' | 'left';
|
|
9
9
|
/** @deprecated */
|
|
@@ -39,8 +39,10 @@ export type CheckboxOverrides = {
|
|
|
39
39
|
type BaseCheckboxProps = {
|
|
40
40
|
'aria-describedby'?: string;
|
|
41
41
|
'aria-errormessage'?: string;
|
|
42
|
+
'aria-hidden'?: boolean | 'true' | 'false';
|
|
42
43
|
ariaLabel?: string;
|
|
43
44
|
'aria-label'?: string;
|
|
45
|
+
tabIndex?: number;
|
|
44
46
|
children?: React.ReactNode;
|
|
45
47
|
containsInteractiveElement?: boolean;
|
|
46
48
|
overrides?: CheckboxOverrides;
|
|
@@ -68,7 +68,7 @@ var FormControl = forwardRef(function (_a, ref) {
|
|
|
68
68
|
_a[a11yErrorMessageId] = intentMessageNode,
|
|
69
69
|
_a[a11yDisabledTooltipId] = shouldShowDisabledTooltip,
|
|
70
70
|
_a));
|
|
71
|
-
var childElement = React.cloneElement(child, __assign(__assign(__assign(__assign({ key: key, id: a11yFieldId, 'aria-invalid': invalidInput }, (invalidInput ? { 'aria-errormessage': error ? a11yErrorMessageId : a11yCaptionId } : {})), { 'aria-labelledby': a11yLabelId }), (ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {})), { 'aria-required': required ? 'true' : 'false', size: onlyChildProps.size || size, disabled: onlyChildProps.disabled || disabled, required: onlyChildProps.required || required }));
|
|
71
|
+
var childElement = React.cloneElement(child, __assign(__assign(__assign(__assign({ key: key, id: a11yFieldId, 'aria-invalid': invalidInput }, (invalidInput ? { 'aria-errormessage': error ? a11yErrorMessageId : a11yCaptionId } : {})), (label ? { 'aria-labelledby': a11yLabelId } : {})), (ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {})), { 'aria-required': required ? 'true' : 'false', size: onlyChildProps.size || size, disabled: onlyChildProps.disabled || disabled, required: onlyChildProps.required || required }));
|
|
72
72
|
return shouldShowDisabledTooltip ? (_jsx(DisabledTooltip, __assign({ content: disabledTooltip }, disabledTooltipProps, { children: _jsx(Box, __assign({ className: "inline-block w-full" }, { children: childElement })) }), "disabled-tooltip-".concat(key))) : (childElement);
|
|
73
73
|
}),
|
|
74
74
|
captionMessage ? (_jsx(Caption, __assign({ "data-spaceweb": "form-control-caption", id: a11yCaptionId }, sharedProps, captionProps, { children: renderWithIcon(intent, captionMessage) }))) : null,
|
|
@@ -19,7 +19,7 @@ declare const StatefulSubMenu: import("react").ForwardRefExoticComponent<Omit<Me
|
|
|
19
19
|
onItemSelect?: ((item: SubMenuItem, event?: MouseEvent) => void) | undefined;
|
|
20
20
|
overrides?: {
|
|
21
21
|
Menu?: Override<Omit<import("../list").ListProps, "overrides"> & {
|
|
22
|
-
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem
|
|
22
|
+
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem> | undefined;
|
|
23
23
|
disableNavigationOnMount?: boolean | undefined;
|
|
24
24
|
focusWhenNavigationEnabled?: boolean | undefined;
|
|
25
25
|
keyboardFocusRestoreTarget?: HTMLElement | null | undefined;
|
package/esm/menu/SubMenu.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare const SubMenu: import("react").ForwardRefExoticComponent<Omit<MenuProps,
|
|
|
20
20
|
onItemSelect: (item: SubMenuItem, event?: MouseEvent) => void;
|
|
21
21
|
overrides?: {
|
|
22
22
|
Menu?: Override<Omit<import("../list").ListProps, "overrides"> & {
|
|
23
|
-
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem
|
|
23
|
+
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem> | undefined;
|
|
24
24
|
disableNavigationOnMount?: boolean | undefined;
|
|
25
25
|
focusWhenNavigationEnabled?: boolean | undefined;
|
|
26
26
|
keyboardFocusRestoreTarget?: HTMLElement | null | undefined;
|
package/esm/menu/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { default as ActionsIconButton, type ActionsIconButtonProps } from './Act
|
|
|
4
4
|
export { default as NestedMenuProvider } from './nested-menu-context';
|
|
5
5
|
export { SubMenu, type SubMenuProps } from './SubMenu';
|
|
6
6
|
export { StatefulSubMenu, type StatefulSubMenuProps } from './StatefulSubMenu';
|
|
7
|
-
export type { MenuItemProps, ContextValue, MenuProps, MenuRef, SubMenuItem, MenuItemActions, MenuItemActionsParams, MenuActionItem, } from './types';
|
|
7
|
+
export type { MenuItemProps, ContextValue, MenuProps, MenuRef, SubMenuItem, MenuItemActions, MenuItemActionsParams, MenuItemActionsConfig, MenuActionItem, } from './types';
|
|
8
8
|
export { default as useStatefulSubMenu } from './useStatefulSubmenu';
|
package/esm/menu/menu-item.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { Box } from '../box';
|
|
@@ -17,12 +17,24 @@ import cx from '../classNames';
|
|
|
17
17
|
function resolveMenuActions(getActionsElement, item) {
|
|
18
18
|
if (!getActionsElement)
|
|
19
19
|
return null;
|
|
20
|
+
var menuActions;
|
|
20
21
|
if (typeof getActionsElement === 'function') {
|
|
21
22
|
if (item == null)
|
|
22
23
|
return null;
|
|
23
|
-
|
|
24
|
+
menuActions = getActionsElement({ item: item });
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
else {
|
|
27
|
+
menuActions = getActionsElement;
|
|
28
|
+
}
|
|
29
|
+
return menuActions.filter(function (action) {
|
|
30
|
+
// If array item is null | undefined
|
|
31
|
+
if (!action)
|
|
32
|
+
return false;
|
|
33
|
+
// If action object in array as no actionEl
|
|
34
|
+
if ('actionEl' in action && !action.actionEl)
|
|
35
|
+
return false;
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
26
38
|
}
|
|
27
39
|
var listItemOverrides = {
|
|
28
40
|
ListItem: {
|
|
@@ -61,10 +73,17 @@ var ACTION_CONTAINER_HANDLER_PROPS = {
|
|
|
61
73
|
},
|
|
62
74
|
};
|
|
63
75
|
function MenuActionContainer(_a) {
|
|
64
|
-
var sharedProps = _a.sharedProps,
|
|
65
|
-
return (
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
var sharedProps = _a.sharedProps, renderedActions = _a.renderedActions;
|
|
77
|
+
return (_jsx(Box, __assign({ className: ['flex items-center', sharedProps.$highlighted ? 'pointer-events-auto' : 'pointer-events-none'], "data-menu-action-container": "true" }, ACTION_CONTAINER_HANDLER_PROPS, { children: renderedActions.map(function (action, index) {
|
|
78
|
+
var _a;
|
|
79
|
+
var _b = 'actionEl' in action ? action : { actionEl: action, alwaysVisible: false }, actionEl = _b.actionEl, alwaysVisible = _b.alwaysVisible;
|
|
80
|
+
return (_jsx(Box, __assign({
|
|
81
|
+
// Only show actions that are always visible or whose parent item is highlighted
|
|
82
|
+
className: [
|
|
83
|
+
index === 0 ? 'ml-0' : 'ml-1',
|
|
84
|
+
alwaysVisible || sharedProps.$highlighted ? 'visible' : 'invisible w-0 ml-0',
|
|
85
|
+
] }, { children: React.cloneElement(actionEl, { tabIndex: -1 }) }), (_a = actionEl.key) !== null && _a !== void 0 ? _a : "menu-action-".concat(index)));
|
|
86
|
+
}) })));
|
|
68
87
|
}
|
|
69
88
|
function buildListItemAriaProps(itemRole, selected, ChildMenu) {
|
|
70
89
|
var props = {};
|
|
@@ -76,28 +95,10 @@ function buildListItemAriaProps(itemRole, selected, ChildMenu) {
|
|
|
76
95
|
}
|
|
77
96
|
return props;
|
|
78
97
|
}
|
|
79
|
-
function flattenActionElements(actions) {
|
|
80
|
-
return React.Children.toArray(actions).flatMap(function (node) {
|
|
81
|
-
if (React.isValidElement(node)) {
|
|
82
|
-
return node.type === React.Fragment ? flattenActionElements(node.props.children) : [node];
|
|
83
|
-
}
|
|
84
|
-
return [];
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
98
|
function useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, endEnhancer, ChildMenu) {
|
|
88
|
-
var renderedActions = useMemo(function () {
|
|
89
|
-
return shouldRenderActions
|
|
90
|
-
? flattenActionElements(resolvedItemActions).map(function (action, index) {
|
|
91
|
-
var _a;
|
|
92
|
-
return React.cloneElement(action, {
|
|
93
|
-
key: (_a = action.key) !== null && _a !== void 0 ? _a : "menu-action-".concat(index),
|
|
94
|
-
});
|
|
95
|
-
})
|
|
96
|
-
: null;
|
|
97
|
-
}, [resolvedItemActions, shouldRenderActions]);
|
|
98
99
|
return useMemo(function () {
|
|
99
100
|
if (shouldRenderActions) {
|
|
100
|
-
return function (sharedProps) { return (_jsx(MenuActionContainer, { sharedProps: sharedProps,
|
|
101
|
+
return function (sharedProps) { return (_jsxs(_Fragment, { children: [_jsx(MenuActionContainer, { sharedProps: sharedProps, renderedActions: resolvedItemActions !== null && resolvedItemActions !== void 0 ? resolvedItemActions : [] }), typeof endEnhancer === 'function' ? endEnhancer(sharedProps) : endEnhancer !== null && endEnhancer !== void 0 ? endEnhancer : null] })); };
|
|
101
102
|
}
|
|
102
103
|
if (endEnhancer)
|
|
103
104
|
return endEnhancer;
|
|
@@ -105,7 +106,7 @@ function useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, en
|
|
|
105
106
|
return _jsx(ChevronDown, { size: 14, className: "transform -rotate-90" });
|
|
106
107
|
}
|
|
107
108
|
return undefined;
|
|
108
|
-
}, [ChildMenu, endEnhancer,
|
|
109
|
+
}, [ChildMenu, endEnhancer, resolvedItemActions, shouldRenderActions]);
|
|
109
110
|
}
|
|
110
111
|
function useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem, setNestedMenuOpen) {
|
|
111
112
|
var onMouseOverRef = useLatest(onMouseOver);
|
|
@@ -127,12 +128,13 @@ function useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem,
|
|
|
127
128
|
return { handleMouseOver: handleMouseOver, handleMouseMove: handleMouseMove, resetMenu: resetMenu, closeNestedMenu: closeNestedMenu };
|
|
128
129
|
}
|
|
129
130
|
var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
131
|
+
var _b;
|
|
130
132
|
var selected = _a.selected, highlighted = _a.highlighted, overrides = _a.overrides, getChildMenu = _a.getChildMenu, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, onMouseOver = _a.onMouseOver, endEnhancer = _a.endEnhancer, hideInlineActions = _a.hideInlineActions, renderAll = _a.renderAll, explicitRole = _a.role, $item = _a.$item, restProps = __rest(_a, ["selected", "highlighted", "overrides", "getChildMenu", "onMouseEnter", "onMouseLeave", "onMouseOver", "endEnhancer", "hideInlineActions", "renderAll", "role", "$item"]);
|
|
131
|
-
var
|
|
133
|
+
var _c = __read(useState(false), 2), hovered = _c[0], setHovered = _c[1];
|
|
132
134
|
var ChildMenu = getChildMenu === null || getChildMenu === void 0 ? void 0 : getChildMenu();
|
|
133
135
|
var ownRef = useRef(null);
|
|
134
136
|
var itemRef = useCombinedRefs(ref, ownRef);
|
|
135
|
-
var
|
|
137
|
+
var _d = useMenuContext(), getActionsElement = _d.getActionsElement, highlightedItem = _d.highlightedItem, setHighlightedItem = _d.setHighlightedItem, setMenuContainerRef = _d.setMenuContainerRef, listItemFocusVisible = _d.listItemFocusVisible, nestedMenuOpen = _d.nestedMenuOpen, setNestedMenuOpen = _d.setNestedMenuOpen;
|
|
136
138
|
var itemRole = explicitRole !== null && explicitRole !== void 0 ? explicitRole : 'menuitem';
|
|
137
139
|
useEffect(function () {
|
|
138
140
|
var _a, _b;
|
|
@@ -140,12 +142,12 @@ var MenuItem = React.forwardRef(function MenuItem(_a, ref) {
|
|
|
140
142
|
}, [setMenuContainerRef]);
|
|
141
143
|
var isItemHighlighted = highlighted || (highlightedItem !== null && highlightedItem === ownRef.current);
|
|
142
144
|
var resolvedItemActions = useMemo(function () { return resolveMenuActions(getActionsElement, $item); }, [getActionsElement, $item]);
|
|
143
|
-
var shouldRenderActions =
|
|
145
|
+
var shouldRenderActions = ((_b = resolvedItemActions === null || resolvedItemActions === void 0 ? void 0 : resolvedItemActions.length) !== null && _b !== void 0 ? _b : 0) > 0 && !ChildMenu && !hideInlineActions;
|
|
144
146
|
var resolvedEndEnhancer = useResolvedMenuEndEnhancer(resolvedItemActions, shouldRenderActions, endEnhancer, ChildMenu);
|
|
145
147
|
var mergedOverrides = useMemo(function () { return mergeOverrides(listItemOverrides, overrides); }, [overrides]);
|
|
146
|
-
var
|
|
147
|
-
var
|
|
148
|
-
var
|
|
148
|
+
var _e = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.ListItem, ListItem), 2), ListItemOverride = _e[0], listItemProps = _e[1];
|
|
149
|
+
var _f = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.Popover, Popover), 2), PopoverOverride = _f[0], popoverProps = _f[1];
|
|
150
|
+
var _g = useMenuItemInteractionHandlers(onMouseOver, ownRef, setHighlightedItem, setNestedMenuOpen), handleMouseOver = _g.handleMouseOver, handleMouseMove = _g.handleMouseMove, resetMenu = _g.resetMenu, closeNestedMenu = _g.closeNestedMenu;
|
|
149
151
|
var id = useUniqueId();
|
|
150
152
|
var listItem = (_jsx(ListItemOverride, __assign({ id: id.toString(), ref: itemRef, role: itemRole, selected: selected, "data-haschildmenu": Boolean(ChildMenu), "data-hasactions": shouldRenderActions, highlighted: isItemHighlighted, "$outlined": isItemHighlighted && listItemFocusVisible, endEnhancer: resolvedEndEnhancer, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, "$item": $item }, buildListItemAriaProps(itemRole, selected, ChildMenu), restProps, { onMouseOver: handleMouseOver, onMouseMove: handleMouseMove }, listItemProps)));
|
|
151
153
|
var handleMouseEnter = useCombinedHandler(function () { return setHovered(true); }, onMouseEnter);
|
package/esm/menu/menu.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { MenuRef } from './types';
|
|
3
3
|
import type { ClassName, Styles } from '../types';
|
|
4
4
|
declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<import("../list").ListProps, "overrides"> & {
|
|
5
|
-
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem
|
|
5
|
+
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem> | undefined;
|
|
6
6
|
disableNavigationOnMount?: boolean | undefined;
|
|
7
7
|
focusWhenNavigationEnabled?: boolean | undefined;
|
|
8
8
|
keyboardFocusRestoreTarget?: HTMLElement | null | undefined;
|
package/esm/menu/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dispatch, MutableRefObject, ReactElement,
|
|
1
|
+
import type { Dispatch, MutableRefObject, ReactElement, SetStateAction } from 'react';
|
|
2
2
|
import type { ListItemProps, ListItemSharedProps, ListProps } from '../list';
|
|
3
3
|
import type { Override } from '../overrides';
|
|
4
4
|
import type { PopoverProps } from '../popover';
|
|
@@ -32,7 +32,15 @@ export type MenuItemActionsParams<TItem extends MenuActionItem = MenuActionItem>
|
|
|
32
32
|
* Inline row actions: a static node for every row, or `({ item }) => …` for per-row actions
|
|
33
33
|
* (permissions, conditional buttons, etc.). Function form requires `$item` on {@link MenuItem}.
|
|
34
34
|
*/
|
|
35
|
-
export type
|
|
35
|
+
export type MenuItemActionsConfig = (ReactElement | null | undefined | {
|
|
36
|
+
actionEl: ReactElement | null | undefined;
|
|
37
|
+
alwaysVisible?: boolean;
|
|
38
|
+
})[];
|
|
39
|
+
export type ResolvedMenuItemActionsConfig = (ReactElement | {
|
|
40
|
+
actionEl: ReactElement;
|
|
41
|
+
alwaysVisible?: boolean;
|
|
42
|
+
})[];
|
|
43
|
+
export type MenuItemActions<TItem extends MenuActionItem = MenuActionItem> = MenuItemActionsConfig | ((params: MenuItemActionsParams<TItem>) => MenuItemActionsConfig);
|
|
36
44
|
export type MenuProps = Omit<ListProps, 'overrides'> & {
|
|
37
45
|
/**
|
|
38
46
|
* Action buttons rendered for each MenuItem (skips submenu items). Pass `({ item }) => …` to vary actions per row.
|
|
@@ -114,7 +114,7 @@ export declare const CollapsibleSelectMenu: ({ overrides, value, items: groupedI
|
|
|
114
114
|
virtual?: boolean | undefined;
|
|
115
115
|
overscanCount?: number | undefined;
|
|
116
116
|
selectOnTab?: boolean | undefined;
|
|
117
|
-
getActionsElement?: import("../../menu").MenuItemActions;
|
|
117
|
+
getActionsElement?: import("../../menu").MenuItemActions | undefined;
|
|
118
118
|
inputElement?: HTMLInputElement | null | undefined;
|
|
119
119
|
} & {
|
|
120
120
|
$onPaginate?: ((event: UIEvent<HTMLElement>, itemGroup: string) => void) | undefined;
|
|
@@ -64,8 +64,10 @@ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponen
|
|
|
64
64
|
Checkbox?: Override<Omit<{
|
|
65
65
|
'aria-describedby'?: string | undefined;
|
|
66
66
|
'aria-errormessage'?: string | undefined;
|
|
67
|
+
'aria-hidden'?: boolean | "false" | "true" | undefined;
|
|
67
68
|
ariaLabel?: string | undefined;
|
|
68
69
|
'aria-label'?: string | undefined;
|
|
70
|
+
tabIndex?: number | undefined;
|
|
69
71
|
children?: React.ReactNode;
|
|
70
72
|
containsInteractiveElement?: boolean | undefined;
|
|
71
73
|
overrides?: import("../../checkbox").CheckboxOverrides | undefined;
|
package/esm/tag/tag.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare const Tag: import("react").ForwardRefExoticComponent<Omit<{
|
|
3
3
|
closeable?: boolean | undefined;
|
|
4
|
+
closeAriaLabel?: string | undefined;
|
|
4
5
|
isFocused?: boolean | undefined;
|
|
5
6
|
isHovered?: boolean | undefined;
|
|
6
7
|
children?: import("react").ReactNode;
|
package/esm/tag/tag.js
CHANGED
|
@@ -17,7 +17,7 @@ import { useLocale } from '../locale';
|
|
|
17
17
|
import { useTruncateWithTooltip } from '../truncateWithTooltip/hooks/useTruncateWithTooltip';
|
|
18
18
|
import { getActionIconButtonOverrides, getDefaultTagSize, getTagSizeTheme, getTextFromChildren } from './utils';
|
|
19
19
|
var Tag = forwardRef(function (props, ref) {
|
|
20
|
-
var children = props.children, _a = props.closeable, closeable = _a === void 0 ? true : _a, _size = props.size, _b = props.shape, shape = _b === void 0 ? 'default' : _b, _c = props.isFocused, isFocused = _c === void 0 ? false : _c, _d = props.isHovered, isHovered = _d === void 0 ? false : _d, onActionClick = props.onActionClick, onActionKeyDown = props.onActionKeyDown, _e = props.onClick, onClick = _e === void 0 ? null : _e, _f = props.onKeyDown, onKeyDown = _f === void 0 ? null : _f, overrides = props.overrides, title = props.title, _g = props.variant, variant = _g === void 0 ? 'light' : _g, _h = props.intent, intent = _h === void 0 ? 'default' : _h, _j = props.appearance, appearance = _j === void 0 ? 'gray' : _j, className = props.className, startEnhancer = props.startEnhancer, noTooltipOnTruncation = props.noTooltipOnTruncation, restProps = __rest(props, ["children", "closeable", "size", "shape", "isFocused", "isHovered", "onActionClick", "onActionKeyDown", "onClick", "onKeyDown", "overrides", "title", "variant", "intent", "appearance", "className", "startEnhancer", "noTooltipOnTruncation"]);
|
|
20
|
+
var children = props.children, _a = props.closeable, closeable = _a === void 0 ? true : _a, closeAriaLabel = props.closeAriaLabel, _size = props.size, _b = props.shape, shape = _b === void 0 ? 'default' : _b, _c = props.isFocused, isFocused = _c === void 0 ? false : _c, _d = props.isHovered, isHovered = _d === void 0 ? false : _d, onActionClick = props.onActionClick, onActionKeyDown = props.onActionKeyDown, _e = props.onClick, onClick = _e === void 0 ? null : _e, _f = props.onKeyDown, onKeyDown = _f === void 0 ? null : _f, overrides = props.overrides, title = props.title, _g = props.variant, variant = _g === void 0 ? 'light' : _g, _h = props.intent, intent = _h === void 0 ? 'default' : _h, _j = props.appearance, appearance = _j === void 0 ? 'gray' : _j, className = props.className, startEnhancer = props.startEnhancer, noTooltipOnTruncation = props.noTooltipOnTruncation, restProps = __rest(props, ["children", "closeable", "closeAriaLabel", "size", "shape", "isFocused", "isHovered", "onActionClick", "onActionKeyDown", "onClick", "onKeyDown", "overrides", "title", "variant", "intent", "appearance", "className", "startEnhancer", "noTooltipOnTruncation"]);
|
|
21
21
|
var _k = useFocusVisible(), $isFocusVisible = _k.$isFocusVisible, onBlur = _k.onBlur, onFocus = _k.onFocus;
|
|
22
22
|
var theme = useStyle().theme;
|
|
23
23
|
var locale = useLocale();
|
|
@@ -67,7 +67,7 @@ var Tag = forwardRef(function (props, ref) {
|
|
|
67
67
|
actionIconButtonOverrides,
|
|
68
68
|
], style: {
|
|
69
69
|
'--sw-color': theme.spr.iconTertiary,
|
|
70
|
-
}, "aria-label": locale.tag.closeAriaLabel, tabIndex: actionProps === null || actionProps === void 0 ? void 0 : actionProps.tabIndex }, { children: _jsx(ActionIcon, __assign({ size: clearableIconSize }, actionIconProps)) })) }))) : null] })));
|
|
70
|
+
}, "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : locale.tag.closeAriaLabel, tabIndex: actionProps === null || actionProps === void 0 ? void 0 : actionProps.tabIndex }, { children: _jsx(ActionIcon, __assign({ size: clearableIconSize }, actionIconProps)) })) }))) : null] })));
|
|
71
71
|
});
|
|
72
72
|
Tag.displayName = 'Tag';
|
|
73
73
|
Tag.__standard = 'Component';
|
package/esm/tag/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { AvatarProps } from '../avatar';
|
|
3
|
-
import { Override } from '../overrides';
|
|
4
|
-
import { ClassName, SpacewebComponentProps } from '../types';
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { AvatarProps } from '../avatar';
|
|
3
|
+
import type { Override } from '../overrides';
|
|
4
|
+
import type { ClassName, SpacewebComponentProps } from '../types';
|
|
5
5
|
export type Intent = 'success' | 'error' | 'warning' | 'info' | 'default' | 'ai';
|
|
6
6
|
export type Appearance = 'gray' | 'white' | 'outline';
|
|
7
7
|
export type Variant = 'solid' | 'light';
|
|
@@ -16,6 +16,7 @@ export type TagOverrides = {
|
|
|
16
16
|
};
|
|
17
17
|
export type TagProps = SpacewebComponentProps<{
|
|
18
18
|
closeable?: boolean;
|
|
19
|
+
closeAriaLabel?: string;
|
|
19
20
|
isFocused?: boolean;
|
|
20
21
|
isHovered?: boolean;
|
|
21
22
|
children?: React.ReactNode;
|
|
@@ -71,7 +71,7 @@ var FormControl = (0, react_2.forwardRef)(function (_a, ref) {
|
|
|
71
71
|
_a[a11yErrorMessageId] = intentMessageNode,
|
|
72
72
|
_a[a11yDisabledTooltipId] = shouldShowDisabledTooltip,
|
|
73
73
|
_a));
|
|
74
|
-
var childElement = React.cloneElement(child, tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ key: key, id: a11yFieldId, 'aria-invalid': invalidInput }, (invalidInput ? { 'aria-errormessage': error ? a11yErrorMessageId : a11yCaptionId } : {})), { 'aria-labelledby': a11yLabelId }), (ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {})), { 'aria-required': required ? 'true' : 'false', size: onlyChildProps.size || size, disabled: onlyChildProps.disabled || disabled, required: onlyChildProps.required || required }));
|
|
74
|
+
var childElement = React.cloneElement(child, tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ key: key, id: a11yFieldId, 'aria-invalid': invalidInput }, (invalidInput ? { 'aria-errormessage': error ? a11yErrorMessageId : a11yCaptionId } : {})), (label ? { 'aria-labelledby': a11yLabelId } : {})), (ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {})), { 'aria-required': required ? 'true' : 'false', size: onlyChildProps.size || size, disabled: onlyChildProps.disabled || disabled, required: onlyChildProps.required || required }));
|
|
75
75
|
return shouldShowDisabledTooltip ? ((0, jsx_runtime_1.jsx)(DisabledTooltip, tslib_1.__assign({ content: disabledTooltip }, disabledTooltipProps, { children: (0, jsx_runtime_1.jsx)(box_1.Box, tslib_1.__assign({ className: "inline-block w-full" }, { children: childElement })) }), "disabled-tooltip-".concat(key))) : (childElement);
|
|
76
76
|
}),
|
|
77
77
|
captionMessage ? ((0, jsx_runtime_1.jsx)(Caption, tslib_1.__assign({ "data-spaceweb": "form-control-caption", id: a11yCaptionId }, sharedProps, captionProps, { children: renderWithIcon(intent, captionMessage) }))) : null,
|
|
@@ -19,7 +19,7 @@ declare const StatefulSubMenu: import("react").ForwardRefExoticComponent<Omit<Me
|
|
|
19
19
|
onItemSelect?: ((item: SubMenuItem, event?: MouseEvent) => void) | undefined;
|
|
20
20
|
overrides?: {
|
|
21
21
|
Menu?: Override<Omit<import("../list").ListProps, "overrides"> & {
|
|
22
|
-
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem
|
|
22
|
+
getActionsElement?: import("./types").MenuItemActions<import("./types").MenuActionItem> | undefined;
|
|
23
23
|
disableNavigationOnMount?: boolean | undefined;
|
|
24
24
|
focusWhenNavigationEnabled?: boolean | undefined;
|
|
25
25
|
keyboardFocusRestoreTarget?: HTMLElement | null | undefined;
|