@lumx/react 4.9.0-next.0 → 4.9.0-next.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/index.d.ts +112 -22
- package/index.js +116 -51
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -4173,41 +4173,131 @@ declare const Uploader: Comp<UploaderProps, HTMLElement>;
|
|
|
4173
4173
|
/**
|
|
4174
4174
|
* User block sizes.
|
|
4175
4175
|
*/
|
|
4176
|
-
type UserBlockSize = Extract<Size
|
|
4176
|
+
type UserBlockSize = Extract<Size, 'xs' | 's' | 'm' | 'l'>;
|
|
4177
|
+
/**
|
|
4178
|
+
* Props for the UserBlock component.
|
|
4179
|
+
*
|
|
4180
|
+
* UserBlock displays user information with an avatar, name, and optional fields.
|
|
4181
|
+
* Supports both horizontal and vertical orientations with customizable actions.
|
|
4182
|
+
*/
|
|
4183
|
+
interface UserBlockProps$1 extends HasClassName, HasTheme {
|
|
4184
|
+
/**
|
|
4185
|
+
* Props to pass to the Avatar component.
|
|
4186
|
+
* Configure the user's avatar appearance and behavior.
|
|
4187
|
+
*/
|
|
4188
|
+
avatarProps?: GenericProps;
|
|
4189
|
+
/**
|
|
4190
|
+
* Additional fields to display below the user's name.
|
|
4191
|
+
* Typically used for role, department, or other user metadata.
|
|
4192
|
+
*/
|
|
4193
|
+
fields?: string[];
|
|
4194
|
+
/**
|
|
4195
|
+
* Props to pass to the Link component wrapping the avatar and/or name.
|
|
4196
|
+
* Used to make the user block clickable with navigation.
|
|
4197
|
+
*/
|
|
4198
|
+
linkProps?: GenericProps;
|
|
4199
|
+
/**
|
|
4200
|
+
* Custom component to use for the link element.
|
|
4201
|
+
* Use this to inject a framework-specific router Link component (e.g., react-router Link).
|
|
4202
|
+
* @default 'a'
|
|
4203
|
+
*/
|
|
4204
|
+
linkAs?: 'a' | any;
|
|
4205
|
+
/**
|
|
4206
|
+
* Content for multiple actions displayed in the action toolbar.
|
|
4207
|
+
* Only visible when orientation is vertical.
|
|
4208
|
+
*/
|
|
4209
|
+
multipleActions?: JSXElement;
|
|
4210
|
+
/**
|
|
4211
|
+
* The user's display name.
|
|
4212
|
+
* Can be a string or custom JSX element.
|
|
4213
|
+
*/
|
|
4214
|
+
name?: JSXElement;
|
|
4215
|
+
/**
|
|
4216
|
+
* Props to pass to the name wrapper element.
|
|
4217
|
+
* Used to customize the name block's appearance and behavior.
|
|
4218
|
+
*/
|
|
4219
|
+
nameProps?: GenericProps;
|
|
4220
|
+
/**
|
|
4221
|
+
* Layout orientation of the user block.
|
|
4222
|
+
* - horizontal: Avatar and info side by side (default)
|
|
4223
|
+
* - vertical: Avatar and info stacked, forces size to 'l'
|
|
4224
|
+
* @default Orientation.horizontal
|
|
4225
|
+
*/
|
|
4226
|
+
orientation?: Orientation;
|
|
4227
|
+
/**
|
|
4228
|
+
* Content for a single action displayed in the action toolbar.
|
|
4229
|
+
* Only visible when orientation is vertical.
|
|
4230
|
+
*/
|
|
4231
|
+
simpleAction?: JSXElement;
|
|
4232
|
+
/**
|
|
4233
|
+
* Size variant of the component.
|
|
4234
|
+
* Note: When orientation is vertical, size is automatically forced to 'l'.
|
|
4235
|
+
* @default Size.m
|
|
4236
|
+
*/
|
|
4237
|
+
size?: UserBlockSize;
|
|
4238
|
+
/**
|
|
4239
|
+
* Click event handler.
|
|
4240
|
+
* Called when the user clicks on the clickable area (name/avatar).
|
|
4241
|
+
*/
|
|
4242
|
+
handleClick?(): void;
|
|
4243
|
+
/**
|
|
4244
|
+
* Mouse enter event handler.
|
|
4245
|
+
* Called when the mouse enters the component.
|
|
4246
|
+
*/
|
|
4247
|
+
handleMouseEnter?(): void;
|
|
4248
|
+
/**
|
|
4249
|
+
* Mouse leave event handler.
|
|
4250
|
+
* Called when the mouse leaves the component.
|
|
4251
|
+
*/
|
|
4252
|
+
handleMouseLeave?(): void;
|
|
4253
|
+
/**
|
|
4254
|
+
* Additional custom fields to display below the standard fields.
|
|
4255
|
+
* Only visible when size is not 'xs' or 's'.
|
|
4256
|
+
*/
|
|
4257
|
+
additionalFields?: JSXElement;
|
|
4258
|
+
/**
|
|
4259
|
+
* Content to display after the entire component.
|
|
4260
|
+
* Position depends on orientation:
|
|
4261
|
+
* - horizontal: displayed to the right
|
|
4262
|
+
* - vertical: displayed at the bottom
|
|
4263
|
+
*/
|
|
4264
|
+
after?: JSXElement;
|
|
4265
|
+
/**
|
|
4266
|
+
* Custom content to replace the default name block.
|
|
4267
|
+
* When provided, replaces the default name rendering.
|
|
4268
|
+
*/
|
|
4269
|
+
children?: JSXElement;
|
|
4270
|
+
/**
|
|
4271
|
+
* Ref to attach to the root element.
|
|
4272
|
+
*/
|
|
4273
|
+
ref?: CommonRef;
|
|
4274
|
+
/**
|
|
4275
|
+
* Text component for rendering text content.
|
|
4276
|
+
* Injected by the framework wrapper (React/Vue).
|
|
4277
|
+
*/
|
|
4278
|
+
Text: (props: any) => any;
|
|
4279
|
+
/**
|
|
4280
|
+
* Avatar component for rendering the user avatar.
|
|
4281
|
+
* Injected by the framework wrapper (React/Vue).
|
|
4282
|
+
*/
|
|
4283
|
+
Avatar: (props: any) => any;
|
|
4284
|
+
}
|
|
4285
|
+
type UserBlockPropsToOverride = 'Avatar' | 'Text' | 'nameProps' | 'linkProps' | 'avatarProps';
|
|
4286
|
+
|
|
4177
4287
|
/**
|
|
4178
4288
|
* Defines the props of the component.
|
|
4179
4289
|
*/
|
|
4180
|
-
interface UserBlockProps extends GenericProps$1,
|
|
4290
|
+
interface UserBlockProps extends GenericProps$1, ReactToJSX<UserBlockProps$1, UserBlockPropsToOverride> {
|
|
4181
4291
|
/** Props to pass to the avatar. */
|
|
4182
4292
|
avatarProps?: Omit<AvatarProps, 'alt'>;
|
|
4183
|
-
/** Additional fields used to describe the user. */
|
|
4184
|
-
fields?: string[];
|
|
4185
4293
|
/** Props to pass to the link wrapping the avatar thumbnail. */
|
|
4186
4294
|
linkProps?: React__default.DetailedHTMLProps<React__default.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
4187
|
-
/** Custom react component for the link (can be used to inject react router Link). */
|
|
4188
|
-
linkAs?: 'a' | any;
|
|
4189
|
-
/** Multiple action toolbar content. */
|
|
4190
|
-
multipleActions?: ReactNode;
|
|
4191
|
-
/** User name. */
|
|
4192
|
-
name?: React__default.ReactNode;
|
|
4193
|
-
/** Props to pass to the name block. */
|
|
4194
|
-
nameProps?: GenericProps$1;
|
|
4195
|
-
/** Orientation. */
|
|
4196
|
-
orientation?: Orientation$1;
|
|
4197
|
-
/** Simple action toolbar content. */
|
|
4198
|
-
simpleAction?: ReactNode;
|
|
4199
|
-
/** Size variant. */
|
|
4200
|
-
size?: UserBlockSize;
|
|
4201
4295
|
/** On click callback. */
|
|
4202
4296
|
onClick?(): void;
|
|
4203
4297
|
/** On mouse enter callback. */
|
|
4204
4298
|
onMouseEnter?(): void;
|
|
4205
4299
|
/** On mouse leave callback. */
|
|
4206
4300
|
onMouseLeave?(): void;
|
|
4207
|
-
/** Display additional fields below the original name and fields */
|
|
4208
|
-
additionalFields?: React__default.ReactNode;
|
|
4209
|
-
/** Display an additional element after the entire component. (to the right if orientation is horizontal, at the bottom if orientation is vertical) */
|
|
4210
|
-
after?: React__default.ReactNode;
|
|
4211
4301
|
}
|
|
4212
4302
|
/**
|
|
4213
4303
|
* UserBlock component.
|
package/index.js
CHANGED
|
@@ -16319,14 +16319,23 @@ const CLASSNAME = 'lumx-user-block';
|
|
|
16319
16319
|
const {
|
|
16320
16320
|
block,
|
|
16321
16321
|
element
|
|
16322
|
-
} =
|
|
16322
|
+
} = bem(CLASSNAME);
|
|
16323
16323
|
|
|
16324
16324
|
/**
|
|
16325
16325
|
* Component default props.
|
|
16326
16326
|
*/
|
|
16327
16327
|
const DEFAULT_PROPS = {
|
|
16328
|
-
orientation: Orientation
|
|
16329
|
-
size: Size
|
|
16328
|
+
orientation: Orientation.horizontal,
|
|
16329
|
+
size: Size.m
|
|
16330
|
+
};
|
|
16331
|
+
const isUserBlockClickeable = ({
|
|
16332
|
+
linkAs,
|
|
16333
|
+
linkProps,
|
|
16334
|
+
handleClick
|
|
16335
|
+
}) => {
|
|
16336
|
+
const isLink = Boolean(linkProps?.href || linkAs);
|
|
16337
|
+
const isClickable = !!handleClick || isLink;
|
|
16338
|
+
return isClickable;
|
|
16330
16339
|
};
|
|
16331
16340
|
|
|
16332
16341
|
/**
|
|
@@ -16336,69 +16345,44 @@ const DEFAULT_PROPS = {
|
|
|
16336
16345
|
* @param ref Component ref.
|
|
16337
16346
|
* @return React element.
|
|
16338
16347
|
*/
|
|
16339
|
-
const UserBlock =
|
|
16340
|
-
const defaultTheme = useTheme() || Theme$1.light;
|
|
16348
|
+
const UserBlock$1 = props => {
|
|
16341
16349
|
const {
|
|
16342
16350
|
avatarProps,
|
|
16343
16351
|
className,
|
|
16344
16352
|
fields,
|
|
16345
16353
|
linkProps,
|
|
16346
16354
|
linkAs,
|
|
16355
|
+
ref,
|
|
16347
16356
|
multipleActions,
|
|
16348
16357
|
name,
|
|
16349
16358
|
nameProps,
|
|
16350
|
-
|
|
16351
|
-
|
|
16352
|
-
|
|
16359
|
+
handleClick,
|
|
16360
|
+
handleMouseEnter,
|
|
16361
|
+
handleMouseLeave,
|
|
16353
16362
|
orientation = DEFAULT_PROPS.orientation,
|
|
16354
16363
|
simpleAction,
|
|
16355
16364
|
size = DEFAULT_PROPS.size,
|
|
16356
|
-
theme
|
|
16365
|
+
theme,
|
|
16357
16366
|
children,
|
|
16358
16367
|
additionalFields,
|
|
16359
16368
|
after,
|
|
16369
|
+
Text,
|
|
16370
|
+
Avatar,
|
|
16360
16371
|
...forwardedProps
|
|
16361
16372
|
} = props;
|
|
16362
16373
|
let componentSize = size;
|
|
16363
16374
|
|
|
16364
16375
|
// Special case - When using vertical orientation force the size to be Sizes.l.
|
|
16365
|
-
if (orientation === Orientation
|
|
16366
|
-
componentSize = Size
|
|
16376
|
+
if (orientation === Orientation.vertical) {
|
|
16377
|
+
componentSize = Size.l;
|
|
16367
16378
|
}
|
|
16368
|
-
const shouldDisplayActions = orientation === Orientation
|
|
16369
|
-
const
|
|
16370
|
-
|
|
16371
|
-
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
|
|
16375
|
-
let NameComponent = 'span';
|
|
16376
|
-
const nProps = {
|
|
16377
|
-
...nameProps,
|
|
16378
|
-
className: classNames.join(element('name'), linkProps?.className, nameProps?.className)
|
|
16379
|
-
};
|
|
16380
|
-
if (isClickable) {
|
|
16381
|
-
NameComponent = Link;
|
|
16382
|
-
Object.assign(nProps, {
|
|
16383
|
-
...linkProps,
|
|
16384
|
-
onClick,
|
|
16385
|
-
linkAs,
|
|
16386
|
-
color: ColorPalette$1.dark
|
|
16387
|
-
});
|
|
16388
|
-
}
|
|
16389
|
-
// Disable avatar focus since the name block is the same link / same button.
|
|
16390
|
-
if (avatarProps) {
|
|
16391
|
-
set(avatarProps, ['thumbnailProps', 'tabIndex'], -1);
|
|
16392
|
-
}
|
|
16393
|
-
return /*#__PURE__*/jsx(NameComponent, {
|
|
16394
|
-
...nProps,
|
|
16395
|
-
children: /*#__PURE__*/jsx(Text, {
|
|
16396
|
-
as: "span",
|
|
16397
|
-
children: name
|
|
16398
|
-
})
|
|
16399
|
-
});
|
|
16400
|
-
}, [avatarProps, isClickable, linkAs, linkProps, name, nameProps, onClick]);
|
|
16401
|
-
const shouldDisplayFields = componentSize !== Size$1.s && componentSize !== Size$1.xs;
|
|
16379
|
+
const shouldDisplayActions = orientation === Orientation.vertical;
|
|
16380
|
+
const isClickable = isUserBlockClickeable({
|
|
16381
|
+
handleClick,
|
|
16382
|
+
linkAs,
|
|
16383
|
+
linkProps
|
|
16384
|
+
});
|
|
16385
|
+
const shouldDisplayFields = componentSize !== Size.s && componentSize !== Size.xs;
|
|
16402
16386
|
const fieldsBlock = fields && shouldDisplayFields && /*#__PURE__*/jsx("div", {
|
|
16403
16387
|
className: element('fields'),
|
|
16404
16388
|
children: fields.map((field, idx) => /*#__PURE__*/jsx(Text, {
|
|
@@ -16410,26 +16394,26 @@ const UserBlock = forwardRef((props, ref) => {
|
|
|
16410
16394
|
return /*#__PURE__*/jsxs("div", {
|
|
16411
16395
|
ref: ref,
|
|
16412
16396
|
...forwardedProps,
|
|
16413
|
-
className:
|
|
16397
|
+
className: classnames(className, block({
|
|
16414
16398
|
[`orientation-${orientation}`]: Boolean(orientation),
|
|
16415
16399
|
[`size-${componentSize}`]: Boolean(componentSize),
|
|
16416
16400
|
[`theme-${theme}`]: Boolean(theme),
|
|
16417
16401
|
'is-clickable': isClickable
|
|
16418
16402
|
})),
|
|
16419
|
-
onMouseLeave:
|
|
16420
|
-
onMouseEnter:
|
|
16403
|
+
onMouseLeave: handleMouseLeave,
|
|
16404
|
+
onMouseEnter: handleMouseEnter,
|
|
16421
16405
|
children: [avatarProps && /*#__PURE__*/jsx(Avatar, {
|
|
16422
16406
|
linkAs: linkAs,
|
|
16423
16407
|
linkProps: linkProps,
|
|
16424
16408
|
alt: "",
|
|
16425
16409
|
...avatarProps,
|
|
16426
|
-
className:
|
|
16410
|
+
className: classnames(element('avatar'), avatarProps.className),
|
|
16427
16411
|
size: componentSize,
|
|
16428
|
-
onClick:
|
|
16412
|
+
onClick: handleClick,
|
|
16429
16413
|
theme: theme
|
|
16430
16414
|
}), (fields || name || children || additionalFields) && /*#__PURE__*/jsxs("div", {
|
|
16431
16415
|
className: element('wrapper'),
|
|
16432
|
-
children: [children
|
|
16416
|
+
children: [children, fieldsBlock, shouldDisplayFields ? additionalFields : null]
|
|
16433
16417
|
}), shouldDisplayActions && simpleAction && /*#__PURE__*/jsx("div", {
|
|
16434
16418
|
className: element('action'),
|
|
16435
16419
|
children: simpleAction
|
|
@@ -16441,6 +16425,87 @@ const UserBlock = forwardRef((props, ref) => {
|
|
|
16441
16425
|
children: after
|
|
16442
16426
|
}) : null]
|
|
16443
16427
|
});
|
|
16428
|
+
};
|
|
16429
|
+
|
|
16430
|
+
/**
|
|
16431
|
+
* UserBlock component.
|
|
16432
|
+
*
|
|
16433
|
+
* @param props Component props.
|
|
16434
|
+
* @param ref Component ref.
|
|
16435
|
+
* @return React element.
|
|
16436
|
+
*/
|
|
16437
|
+
const UserBlock = forwardRef((props, ref) => {
|
|
16438
|
+
const defaultTheme = useTheme() || Theme$1.light;
|
|
16439
|
+
const {
|
|
16440
|
+
onClick,
|
|
16441
|
+
onMouseEnter,
|
|
16442
|
+
onMouseLeave,
|
|
16443
|
+
theme = defaultTheme,
|
|
16444
|
+
nameProps,
|
|
16445
|
+
avatarProps,
|
|
16446
|
+
name,
|
|
16447
|
+
linkProps,
|
|
16448
|
+
linkAs,
|
|
16449
|
+
children,
|
|
16450
|
+
...forwardedProps
|
|
16451
|
+
} = props;
|
|
16452
|
+
const isClickable = isUserBlockClickeable({
|
|
16453
|
+
linkAs,
|
|
16454
|
+
linkProps,
|
|
16455
|
+
handleClick: onClick
|
|
16456
|
+
});
|
|
16457
|
+
|
|
16458
|
+
/**
|
|
16459
|
+
* This logic needs to occur on the wrapper level, since core templates cannot manage
|
|
16460
|
+
* the render of dynamically determined components. So `NameComponent`, if moved to core,
|
|
16461
|
+
* it will return an `undefined`
|
|
16462
|
+
*/
|
|
16463
|
+
const nameBlock = React__default.useMemo(() => {
|
|
16464
|
+
if (isEmpty(name)) {
|
|
16465
|
+
return null;
|
|
16466
|
+
}
|
|
16467
|
+
let NameComponent = 'span';
|
|
16468
|
+
const nProps = {
|
|
16469
|
+
...nameProps,
|
|
16470
|
+
className: classNames.join(element('name'), linkProps?.className, nameProps?.className)
|
|
16471
|
+
};
|
|
16472
|
+
if (isClickable) {
|
|
16473
|
+
NameComponent = Link;
|
|
16474
|
+
Object.assign(nProps, {
|
|
16475
|
+
...linkProps,
|
|
16476
|
+
onClick,
|
|
16477
|
+
linkAs,
|
|
16478
|
+
color: ColorPalette$1.dark
|
|
16479
|
+
});
|
|
16480
|
+
}
|
|
16481
|
+
// Disable avatar focus since the name block is the same link / same button.
|
|
16482
|
+
if (avatarProps) {
|
|
16483
|
+
set(avatarProps, ['thumbnailProps', 'tabIndex'], -1);
|
|
16484
|
+
}
|
|
16485
|
+
return /*#__PURE__*/jsx(NameComponent, {
|
|
16486
|
+
...nProps,
|
|
16487
|
+
children: /*#__PURE__*/jsx(Text, {
|
|
16488
|
+
as: "span",
|
|
16489
|
+
children: name
|
|
16490
|
+
})
|
|
16491
|
+
});
|
|
16492
|
+
}, [avatarProps, isClickable, linkAs, linkProps, name, nameProps, onClick]);
|
|
16493
|
+
return UserBlock$1({
|
|
16494
|
+
Avatar,
|
|
16495
|
+
ref,
|
|
16496
|
+
Text,
|
|
16497
|
+
handleClick: onClick,
|
|
16498
|
+
handleMouseEnter: onMouseEnter,
|
|
16499
|
+
handleMouseLeave: onMouseLeave,
|
|
16500
|
+
theme,
|
|
16501
|
+
nameProps,
|
|
16502
|
+
avatarProps,
|
|
16503
|
+
name,
|
|
16504
|
+
linkProps,
|
|
16505
|
+
linkAs,
|
|
16506
|
+
...forwardedProps,
|
|
16507
|
+
children: children || nameBlock
|
|
16508
|
+
});
|
|
16444
16509
|
});
|
|
16445
16510
|
UserBlock.displayName = COMPONENT_NAME;
|
|
16446
16511
|
UserBlock.className = CLASSNAME;
|