@lumx/react 3.18.2-alpha.2 → 3.18.2-alpha.4
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 +3 -1
- package/index.js +37 -16
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/button/ButtonRoot.tsx +1 -0
- package/src/components/thumbnail/Thumbnail.test.tsx +40 -3
- package/src/components/thumbnail/Thumbnail.tsx +6 -4
- package/src/components/uploader/Uploader.stories.tsx +12 -3
- package/src/components/uploader/Uploader.test.tsx +31 -10
- package/src/components/uploader/Uploader.tsx +29 -7
- package/src/utils/disabled/DisabledStateProvider.stories.tsx +7 -1
package/index.d.ts
CHANGED
|
@@ -3328,11 +3328,13 @@ interface FileInputProps extends Omit<React.ComponentProps<'input'>, 'onChange'>
|
|
|
3328
3328
|
/**
|
|
3329
3329
|
* Defines the props of the component.
|
|
3330
3330
|
*/
|
|
3331
|
-
interface UploaderProps extends GenericProps, HasTheme {
|
|
3331
|
+
interface UploaderProps extends GenericProps, HasTheme, HasAriaDisabled {
|
|
3332
3332
|
/** Image aspect ratio. */
|
|
3333
3333
|
aspectRatio?: AspectRatio;
|
|
3334
3334
|
/** Icon (SVG path). */
|
|
3335
3335
|
icon?: string;
|
|
3336
|
+
/** Disabled state */
|
|
3337
|
+
isDisabled?: boolean;
|
|
3336
3338
|
/** Label text. */
|
|
3337
3339
|
label?: string;
|
|
3338
3340
|
/** Size variant. */
|
package/index.js
CHANGED
|
@@ -1389,6 +1389,7 @@ const ButtonRoot = forwardRef((props, ref) => {
|
|
|
1389
1389
|
}), children);
|
|
1390
1390
|
}
|
|
1391
1391
|
return /*#__PURE__*/React__default.createElement("button", _extends({}, forwardedProps, disabledStateProps, {
|
|
1392
|
+
"aria-disabled": isAnyDisabled,
|
|
1392
1393
|
"aria-label": ariaLabel,
|
|
1393
1394
|
ref: ref,
|
|
1394
1395
|
className: buttonClassName,
|
|
@@ -13651,6 +13652,10 @@ const DEFAULT_PROPS$4 = {
|
|
|
13651
13652
|
*/
|
|
13652
13653
|
const Thumbnail = forwardRef((props, ref) => {
|
|
13653
13654
|
var _loadingPlaceholderIm;
|
|
13655
|
+
const {
|
|
13656
|
+
isAnyDisabled,
|
|
13657
|
+
otherProps
|
|
13658
|
+
} = useDisableStateProps(props);
|
|
13654
13659
|
const defaultTheme = useTheme() || Theme.light;
|
|
13655
13660
|
const {
|
|
13656
13661
|
align,
|
|
@@ -13676,8 +13681,8 @@ const Thumbnail = forwardRef((props, ref) => {
|
|
|
13676
13681
|
variant,
|
|
13677
13682
|
linkProps,
|
|
13678
13683
|
linkAs
|
|
13679
|
-
} =
|
|
13680
|
-
forwardedProps = _objectWithoutProperties(
|
|
13684
|
+
} = otherProps,
|
|
13685
|
+
forwardedProps = _objectWithoutProperties(otherProps, _excluded$4);
|
|
13681
13686
|
const [imgElement, setImgElement] = useState();
|
|
13682
13687
|
|
|
13683
13688
|
// Image loading state.
|
|
@@ -13700,13 +13705,13 @@ const Thumbnail = forwardRef((props, ref) => {
|
|
|
13700
13705
|
}
|
|
13701
13706
|
const isLink = Boolean((linkProps === null || linkProps === void 0 ? void 0 : linkProps.href) || linkAs);
|
|
13702
13707
|
const isButton = !!forwardedProps.onClick;
|
|
13703
|
-
const isClickable = isButton || isLink;
|
|
13708
|
+
const isClickable = !isAnyDisabled && (isButton || isLink);
|
|
13704
13709
|
let Wrapper = 'div';
|
|
13705
13710
|
const wrapperProps = _objectSpread2({}, forwardedProps);
|
|
13706
|
-
if (isLink) {
|
|
13711
|
+
if (!isAnyDisabled && isLink) {
|
|
13707
13712
|
Wrapper = linkAs || 'a';
|
|
13708
13713
|
Object.assign(wrapperProps, linkProps);
|
|
13709
|
-
} else if (isButton) {
|
|
13714
|
+
} else if (!isAnyDisabled && isButton) {
|
|
13710
13715
|
Wrapper = 'button';
|
|
13711
13716
|
wrapperProps.type = forwardedProps.type || 'button';
|
|
13712
13717
|
wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;
|
|
@@ -14172,7 +14177,7 @@ Tooltip.displayName = COMPONENT_NAME$2;
|
|
|
14172
14177
|
Tooltip.className = CLASSNAME$2;
|
|
14173
14178
|
Tooltip.defaultProps = DEFAULT_PROPS$2;
|
|
14174
14179
|
|
|
14175
|
-
const _excluded$1 = ["aspectRatio", "className", "label", "icon", "size", "theme", "variant", "fileInputProps"];
|
|
14180
|
+
const _excluded$1 = ["aspectRatio", "className", "label", "icon", "size", "theme", "variant", "fileInputProps", "onClick"];
|
|
14176
14181
|
|
|
14177
14182
|
/**
|
|
14178
14183
|
* Uploader variants.
|
|
@@ -14222,6 +14227,11 @@ const DEFAULT_PROPS$1 = {
|
|
|
14222
14227
|
* @return React element.
|
|
14223
14228
|
*/
|
|
14224
14229
|
const Uploader = forwardRef((props, ref) => {
|
|
14230
|
+
const {
|
|
14231
|
+
disabledStateProps,
|
|
14232
|
+
otherProps,
|
|
14233
|
+
isAnyDisabled
|
|
14234
|
+
} = useDisableStateProps(props);
|
|
14225
14235
|
const defaultTheme = useTheme() || Theme.light;
|
|
14226
14236
|
const {
|
|
14227
14237
|
aspectRatio = DEFAULT_PROPS$1.aspectRatio,
|
|
@@ -14231,11 +14241,19 @@ const Uploader = forwardRef((props, ref) => {
|
|
|
14231
14241
|
size = DEFAULT_PROPS$1.size,
|
|
14232
14242
|
theme = defaultTheme,
|
|
14233
14243
|
variant = DEFAULT_PROPS$1.variant,
|
|
14234
|
-
fileInputProps
|
|
14235
|
-
|
|
14236
|
-
|
|
14244
|
+
fileInputProps,
|
|
14245
|
+
onClick
|
|
14246
|
+
} = otherProps,
|
|
14247
|
+
forwardedProps = _objectWithoutProperties(otherProps, _excluded$1);
|
|
14237
14248
|
// Adjust to square aspect ratio when using circle variants.
|
|
14238
14249
|
const adjustedAspectRatio = variant === UploaderVariant.circle ? AspectRatio.square : aspectRatio;
|
|
14250
|
+
const handleClick = React__default.useCallback(evt => {
|
|
14251
|
+
if (isAnyDisabled) {
|
|
14252
|
+
evt.preventDefault();
|
|
14253
|
+
} else {
|
|
14254
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(evt);
|
|
14255
|
+
}
|
|
14256
|
+
}, [isAnyDisabled, onClick]);
|
|
14239
14257
|
const generatedInputId = useId();
|
|
14240
14258
|
const inputId = (fileInputProps === null || fileInputProps === void 0 ? void 0 : fileInputProps.id) || generatedInputId;
|
|
14241
14259
|
const [isDragHovering, unsetDragHovering, setDragHovering] = useBooleanState(false);
|
|
@@ -14246,28 +14264,30 @@ const Uploader = forwardRef((props, ref) => {
|
|
|
14246
14264
|
}
|
|
14247
14265
|
} : {
|
|
14248
14266
|
Component: 'button',
|
|
14249
|
-
props: {
|
|
14267
|
+
props: _objectSpread2({
|
|
14250
14268
|
type: 'button'
|
|
14251
|
-
}
|
|
14269
|
+
}, disabledStateProps)
|
|
14252
14270
|
};
|
|
14253
14271
|
const onChange = React__default.useMemo(() => {
|
|
14254
|
-
if (!(fileInputProps !== null && fileInputProps !== void 0 && fileInputProps.onChange)) return undefined;
|
|
14272
|
+
if (isAnyDisabled || !(fileInputProps !== null && fileInputProps !== void 0 && fileInputProps.onChange)) return undefined;
|
|
14255
14273
|
return evt => {
|
|
14256
14274
|
const fileList = evt.target.files;
|
|
14257
14275
|
const files = fileList ? Array.from(fileList) : [];
|
|
14258
14276
|
fileInputProps.onChange(files, evt);
|
|
14259
14277
|
};
|
|
14260
|
-
}, [fileInputProps]);
|
|
14278
|
+
}, [isAnyDisabled, fileInputProps]);
|
|
14261
14279
|
return /*#__PURE__*/React__default.createElement(wrapper.Component, _extends({
|
|
14262
14280
|
ref: ref
|
|
14263
14281
|
}, wrapper.props, forwardedProps, {
|
|
14282
|
+
onClick: handleClick,
|
|
14264
14283
|
className: classNames(className, handleBasicClasses({
|
|
14265
14284
|
aspectRatio: adjustedAspectRatio,
|
|
14266
14285
|
prefix: CLASSNAME$1,
|
|
14267
14286
|
size,
|
|
14268
14287
|
theme,
|
|
14269
14288
|
variant,
|
|
14270
|
-
isDragHovering
|
|
14289
|
+
isDragHovering,
|
|
14290
|
+
isDisabled: isAnyDisabled
|
|
14271
14291
|
}))
|
|
14272
14292
|
}), /*#__PURE__*/React__default.createElement("span", {
|
|
14273
14293
|
className: `${CLASSNAME$1}__background`
|
|
@@ -14282,8 +14302,9 @@ const Uploader = forwardRef((props, ref) => {
|
|
|
14282
14302
|
}, label)), fileInputProps && /*#__PURE__*/React__default.createElement("input", _extends({
|
|
14283
14303
|
type: "file",
|
|
14284
14304
|
id: inputId,
|
|
14285
|
-
className: `${CLASSNAME$1}__input`
|
|
14286
|
-
}, fileInputProps, {
|
|
14305
|
+
className: `${CLASSNAME$1}__input ${VISUALLY_HIDDEN}`
|
|
14306
|
+
}, disabledStateProps, fileInputProps, {
|
|
14307
|
+
readOnly: isAnyDisabled,
|
|
14287
14308
|
onChange: onChange,
|
|
14288
14309
|
onDragEnter: setDragHovering,
|
|
14289
14310
|
onDragLeave: unsetDragHovering,
|