@laser-ui/components 0.1.5 → 0.2.0
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/CHANGELOG.md +11 -0
- package/card/Card.d.ts +2 -0
- package/card/Card.js +6 -12
- package/card/CardActions.d.ts +3 -0
- package/card/CardActions.js +15 -0
- package/card/index.d.ts +1 -1
- package/card/types.d.ts +3 -2
- package/context/props.d.ts +2 -1
- package/fab/types.d.ts +1 -1
- package/form/model/abstract-control.d.ts +1 -1
- package/form/model/abstract-control.js +18 -16
- package/internal/popup/Popup.js +9 -6
- package/package.json +5 -6
- package/slides/Slides.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
# [0.2.0](https://github.com/laser-ui/laser-ui/compare/v0.1.6...v0.2.0) (2023-10-31)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **components:** `list` is optional in `Fab` ([8ee4ae2](https://github.com/laser-ui/laser-ui/commit/8ee4ae2dd032e4ad8ecd0a1e955489c52a335231))
|
|
10
|
+
- **components:** remove Slides's radio value ([f8b07ea](https://github.com/laser-ui/laser-ui/commit/f8b07ea58131e125cd7bdaaa6221be82d32971b7))
|
|
11
|
+
|
|
12
|
+
## [0.1.6](https://github.com/laser-ui/laser-ui/compare/v0.1.5...v0.1.6) (2023-10-13)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @laser-ui/components
|
|
15
|
+
|
|
5
16
|
## [0.1.5](https://github.com/laser-ui/laser-ui/compare/v0.1.4...v0.1.5) (2023-10-09)
|
|
6
17
|
|
|
7
18
|
### Bug Fixes
|
package/card/Card.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CardProps } from './types';
|
|
3
3
|
import { CardAction } from './CardAction';
|
|
4
|
+
import { CardActions } from './CardActions';
|
|
4
5
|
import { CardContent } from './CardContent';
|
|
5
6
|
import { CardHeader } from './CardHeader';
|
|
6
7
|
export declare const Card: {
|
|
7
8
|
(props: CardProps): JSX.Element | null;
|
|
8
9
|
Header: typeof CardHeader;
|
|
9
10
|
Content: typeof CardContent;
|
|
11
|
+
Actions: typeof CardActions;
|
|
10
12
|
Action: typeof CardAction;
|
|
11
13
|
};
|
package/card/Card.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx
|
|
3
|
-
import { isString } from 'lodash';
|
|
4
|
-
import { Children } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
3
|
import { CardAction } from './CardAction';
|
|
4
|
+
import { CardActions } from './CardActions';
|
|
6
5
|
import { CardContent } from './CardContent';
|
|
7
6
|
import { CardHeader } from './CardHeader';
|
|
8
7
|
import { CLASSES } from './vars';
|
|
9
8
|
import { useComponentProps, useStyled } from '../hooks';
|
|
10
|
-
import { Separator } from '../separator';
|
|
11
9
|
import { mergeCS } from '../utils';
|
|
12
10
|
export const Card = (props) => {
|
|
13
|
-
const _a = useComponentProps('Card', props), { children, styleOverrides, styleProvider, shadow = false
|
|
11
|
+
const _a = useComponentProps('Card', props), { children, styleOverrides, styleProvider, shadow = false } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "shadow"]);
|
|
14
12
|
const styled = useStyled(CLASSES, { card: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.card }, styleOverrides);
|
|
15
|
-
|
|
16
|
-
if (headerProp) {
|
|
17
|
-
return isString(headerProp) ? _jsx(CardHeader, { children: headerProp }) : headerProp;
|
|
18
|
-
}
|
|
19
|
-
})();
|
|
20
|
-
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('card', {
|
|
13
|
+
return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('card', {
|
|
21
14
|
'card--shadow': shadow === true,
|
|
22
15
|
'card--shadow-hover': shadow === 'hover',
|
|
23
16
|
}), {
|
|
24
17
|
className: restProps.className,
|
|
25
18
|
style: restProps.style,
|
|
26
|
-
}), { children:
|
|
19
|
+
}), { children: children })));
|
|
27
20
|
};
|
|
28
21
|
Card.Header = CardHeader;
|
|
29
22
|
Card.Content = CardContent;
|
|
23
|
+
Card.Actions = CardActions;
|
|
30
24
|
Card.Action = CardAction;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Children } from 'react';
|
|
4
|
+
import { CLASSES } from './vars';
|
|
5
|
+
import { useComponentProps, useStyled } from '../hooks';
|
|
6
|
+
import { Separator } from '../separator';
|
|
7
|
+
import { mergeCS } from '../utils';
|
|
8
|
+
export function CardActions(props) {
|
|
9
|
+
const _a = useComponentProps('CardActions', props), { styleOverrides, styleProvider, actions } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "actions"]);
|
|
10
|
+
const styled = useStyled(CLASSES, { card: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.card }, styleOverrides);
|
|
11
|
+
return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('card__actions'), {
|
|
12
|
+
className: restProps.className,
|
|
13
|
+
style: restProps.style,
|
|
14
|
+
}), { children: Children.map(actions, (action, index) => (_jsxs(_Fragment, { children: [action, index !== actions.length - 1 && _jsx(Separator, { style: { margin: 8 }, vertical: true })] }))) })));
|
|
15
|
+
}
|
package/card/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { CardProps, CardHeaderProps, CardContentProps, CardActionProps } from './types';
|
|
1
|
+
export type { CardProps, CardHeaderProps, CardContentProps, CardActionsProps, CardActionProps } from './types';
|
|
2
2
|
export { Card } from './Card';
|
package/card/types.d.ts
CHANGED
|
@@ -4,14 +4,15 @@ import type { BaseProps } from '../types';
|
|
|
4
4
|
export {};
|
|
5
5
|
export interface CardProps extends BaseProps<'card', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
shadow?: boolean | 'hover';
|
|
7
|
-
header?: React.ReactElement | string;
|
|
8
|
-
actions?: React.ReactNode[];
|
|
9
7
|
}
|
|
10
8
|
export interface CardHeaderProps extends BaseProps<'card', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
|
|
11
9
|
action?: React.ReactNode;
|
|
12
10
|
}
|
|
13
11
|
export interface CardContentProps extends BaseProps<'card', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
|
|
14
12
|
}
|
|
13
|
+
export interface CardActionsProps extends BaseProps<'card', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
14
|
+
actions: React.ReactNode[];
|
|
15
|
+
}
|
|
15
16
|
export interface CardActionProps extends BaseProps<'card', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
}
|
package/context/props.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { AvatarProps } from '../avatar';
|
|
|
6
6
|
import type { BadgeProps, BadgeTextProps } from '../badge';
|
|
7
7
|
import type { BreadcrumbProps } from '../breadcrumb';
|
|
8
8
|
import type { ButtonProps } from '../button';
|
|
9
|
-
import type { CardActionProps, CardContentProps, CardHeaderProps, CardProps } from '../card';
|
|
9
|
+
import type { CardActionProps, CardActionsProps, CardContentProps, CardHeaderProps, CardProps } from '../card';
|
|
10
10
|
import type { CascaderProps } from '../cascader';
|
|
11
11
|
import type { CheckboxGroupProps, CheckboxProps } from '../checkbox';
|
|
12
12
|
import type { ComposeItemProps, ComposeProps } from '../compose';
|
|
@@ -61,6 +61,7 @@ export interface ComponentProps {
|
|
|
61
61
|
Card: CardProps;
|
|
62
62
|
CardHeader: CardHeaderProps;
|
|
63
63
|
CardContent: CardContentProps;
|
|
64
|
+
CardActions: CardActionsProps;
|
|
64
65
|
CardAction: CardActionProps;
|
|
65
66
|
Cascader: CascaderProps<any, any>;
|
|
66
67
|
Checkbox: CheckboxProps;
|
package/fab/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface FabProps extends BaseProps<'fab', typeof CLASSES>, Omit<React.H
|
|
|
7
7
|
children: React.ReactElement;
|
|
8
8
|
expand?: boolean;
|
|
9
9
|
defaultExpand?: boolean;
|
|
10
|
-
list
|
|
10
|
+
list?: {
|
|
11
11
|
placement: 'top' | 'right' | 'bottom' | 'left';
|
|
12
12
|
actions: React.ReactElement[];
|
|
13
13
|
}[];
|
|
@@ -5,7 +5,7 @@ export declare abstract class AbstractControl<V = any> {
|
|
|
5
5
|
private _pristine;
|
|
6
6
|
private _errors;
|
|
7
7
|
private _hasOwnPendingAsyncValidator;
|
|
8
|
-
private
|
|
8
|
+
private _abortAsyncValidation?;
|
|
9
9
|
private _composedValidatorFn;
|
|
10
10
|
private _composedAsyncValidatorFn;
|
|
11
11
|
private _rawValidators;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isArray } from 'lodash';
|
|
2
|
-
import { forkJoin, from } from 'rxjs';
|
|
3
2
|
import { DISABLED, INVALID, PENDING, VALID } from './vars';
|
|
4
3
|
function mergeErrors(arrayOfErrors) {
|
|
5
4
|
const res = {};
|
|
@@ -26,11 +25,8 @@ function composeAsyncValidators(validators) {
|
|
|
26
25
|
}
|
|
27
26
|
return function (control) {
|
|
28
27
|
return new Promise((resolve) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
next: (errors) => {
|
|
32
|
-
resolve(mergeErrors(errors));
|
|
33
|
-
},
|
|
28
|
+
Promise.all(presentValidators.map((fn) => fn(control))).then((errors) => {
|
|
29
|
+
resolve(mergeErrors(errors));
|
|
34
30
|
});
|
|
35
31
|
});
|
|
36
32
|
};
|
|
@@ -84,7 +80,7 @@ export class AbstractControl {
|
|
|
84
80
|
writable: true,
|
|
85
81
|
value: false
|
|
86
82
|
});
|
|
87
|
-
Object.defineProperty(this, "
|
|
83
|
+
Object.defineProperty(this, "_abortAsyncValidation", {
|
|
88
84
|
enumerable: true,
|
|
89
85
|
configurable: true,
|
|
90
86
|
writable: true,
|
|
@@ -312,8 +308,8 @@ export class AbstractControl {
|
|
|
312
308
|
return this.validator ? this.validator(this) : null;
|
|
313
309
|
}
|
|
314
310
|
_cancelExistingSubscription() {
|
|
315
|
-
if (this.
|
|
316
|
-
this.
|
|
311
|
+
if (this._abortAsyncValidation) {
|
|
312
|
+
this._abortAsyncValidation();
|
|
317
313
|
this._hasOwnPendingAsyncValidator = false;
|
|
318
314
|
}
|
|
319
315
|
}
|
|
@@ -321,14 +317,20 @@ export class AbstractControl {
|
|
|
321
317
|
if (this.asyncValidator) {
|
|
322
318
|
this._status = PENDING;
|
|
323
319
|
this._hasOwnPendingAsyncValidator = true;
|
|
324
|
-
|
|
320
|
+
let abort = false;
|
|
321
|
+
this._abortAsyncValidation = () => {
|
|
322
|
+
abort = true;
|
|
323
|
+
};
|
|
324
|
+
this.asyncValidator(this).then((errors) => {
|
|
325
325
|
var _a, _b;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
326
|
+
if (!abort) {
|
|
327
|
+
this._hasOwnPendingAsyncValidator = false;
|
|
328
|
+
// This will trigger the recalculation of the validation status, which depends on
|
|
329
|
+
// the state of the asynchronous validation (whether it is in progress or not). So, it is
|
|
330
|
+
// necessary that we have updated the `_hasOwnPendingAsyncValidator` boolean flag first.
|
|
331
|
+
this.setErrors(errors);
|
|
332
|
+
(_b = (_a = this.root)._emitChange) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
333
|
+
}
|
|
332
334
|
});
|
|
333
335
|
}
|
|
334
336
|
}
|
package/internal/popup/Popup.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useAsync, useEvent, useRefExtra, useResize } from '@laser-ui/hooks';
|
|
2
2
|
import { isUndefined } from 'lodash';
|
|
3
3
|
import { cloneElement, useEffect, useRef } from 'react';
|
|
4
|
-
import { fromEvent } from 'rxjs';
|
|
5
4
|
import { useLayout, useListenGlobalScrolling } from '../../hooks';
|
|
6
5
|
export function Popup(props) {
|
|
7
6
|
const { children, visible: visibleProp, trigger, disabled = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, updatePosition, onVisibleChange, } = props;
|
|
@@ -46,13 +45,17 @@ export function Popup(props) {
|
|
|
46
45
|
const listenGlobalScrolling = useListenGlobalScrolling(updatePosition.fn, disabled || !visibleProp);
|
|
47
46
|
useEffect(() => {
|
|
48
47
|
if (!disabled && visibleProp && !listenGlobalScrolling) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const els = [pageScrollRef, ...updatePosition.containerRefs].map((ref) => ref.current).filter((el) => el);
|
|
49
|
+
const listener = () => {
|
|
50
|
+
updatePosition.fn();
|
|
51
|
+
};
|
|
52
|
+
els.forEach((el) => {
|
|
53
|
+
el.addEventListener('scroll', listener, { passive: true });
|
|
53
54
|
});
|
|
54
55
|
return () => {
|
|
55
|
-
|
|
56
|
+
els.forEach((el) => {
|
|
57
|
+
el.removeEventListener('scroll', listener);
|
|
58
|
+
});
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -26,14 +26,13 @@
|
|
|
26
26
|
"module": "./index.js",
|
|
27
27
|
"types": "./index.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@laser-ui/hooks": "0.
|
|
30
|
-
"@laser-ui/utils": "0.
|
|
29
|
+
"@laser-ui/hooks": "0.2.0",
|
|
30
|
+
"@laser-ui/utils": "0.2.0",
|
|
31
31
|
"@material-design-icons/svg": "^0.14.12",
|
|
32
32
|
"jss": "^10.10.0",
|
|
33
33
|
"jss-preset-default": "^10.10.0",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
|
-
"rcl-store": "^2.1.0"
|
|
36
|
-
"rxjs": "^7.8.1"
|
|
35
|
+
"rcl-store": "^2.1.0"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
39
38
|
"dayjs": "^1.11.0",
|
|
@@ -46,5 +45,5 @@
|
|
|
46
45
|
"access": "public",
|
|
47
46
|
"directory": "../../dist/libs/components"
|
|
48
47
|
},
|
|
49
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "70ff2b4c73a45c05aa49c44047e1da3ccbcea030"
|
|
50
49
|
}
|
package/slides/Slides.js
CHANGED
|
@@ -270,7 +270,7 @@ export function Slides(props) {
|
|
|
270
270
|
'slides__pagination-radio--next-2': pagination.dynamic && index - activeIndex === 2,
|
|
271
271
|
}), {
|
|
272
272
|
style: { [vertical ? 'top' : 'left']: pagination.dynamic ? 40 - 8 - 16 * activeIndex : undefined },
|
|
273
|
-
}), { key: slide.id, type: "radio",
|
|
273
|
+
}), { key: slide.id, type: "radio", checked: checked, name: uniqueId, title: slide.tooltip, "aria-checked": checked, "aria-controls": viewId, onChange: () => {
|
|
274
274
|
changeActive(slide.id);
|
|
275
275
|
} })));
|
|
276
276
|
}) })))] })));
|