@laser-ui/components 1.6.1 → 2.0.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 +10 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +13 -25
- package/accordion/types.d.ts +1 -0
- package/affix/Affix.d.ts +2 -2
- package/affix/Affix.js +27 -32
- package/affix/types.d.ts +7 -2
- package/alert/Alert.d.ts +1 -1
- package/alert/Alert.js +12 -21
- package/anchor/Anchor.d.ts +2 -4
- package/anchor/Anchor.js +34 -26
- package/anchor/types.d.ts +1 -0
- package/avatar/Avatar.d.ts +1 -1
- package/avatar/Avatar.js +9 -3
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +22 -41
- package/badge/BadgeText.js +12 -26
- package/badge/internal/BadgeNumber.d.ts +2 -2
- package/badge/internal/BadgeNumber.js +34 -24
- package/base-input/BaseInput.d.ts +1 -2
- package/base-input/BaseInput.js +4 -4
- package/base-input/types.d.ts +1 -0
- package/breadcrumb/Breadcrumb.d.ts +1 -1
- package/button/Button.d.ts +1 -2
- package/button/Button.js +18 -22
- package/button/types.d.ts +1 -0
- package/card/Card.d.ts +1 -1
- package/card/CardAction.d.ts +1 -1
- package/card/CardAction.js +3 -4
- package/card/CardActions.d.ts +1 -1
- package/card/CardActions.js +7 -3
- package/card/CardContent.d.ts +1 -1
- package/card/CardHeader.d.ts +1 -1
- package/card/types.d.ts +5 -1
- package/cascader/Cascader.d.ts +2 -4
- package/cascader/Cascader.js +217 -214
- package/cascader/internal/CascaderPanel.d.ts +2 -2
- package/cascader/internal/CascaderPanel.js +21 -7
- package/cascader/internal/CascaderSearchPanel.d.ts +2 -2
- package/cascader/internal/CascaderSearchPanel.js +15 -6
- package/cascader/types.d.ts +3 -3
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +4 -5
- package/checkbox/CheckboxGroup.d.ts +1 -1
- package/checkbox/CheckboxGroup.js +8 -7
- package/checkbox/types.d.ts +14 -4
- package/{internal/circular-progress → circular-progress}/CircularProgress.d.ts +1 -1
- package/{internal/circular-progress → circular-progress}/CircularProgress.js +2 -2
- package/compose/Compose.d.ts +1 -1
- package/compose/ComposeItem.d.ts +1 -1
- package/config-provider/ConfigProvider.d.ts +1 -1
- package/config-provider/ConfigProvider.js +3 -3
- package/date-picker/DatePicker.d.ts +2 -2
- package/date-picker/DatePicker.js +116 -98
- package/date-picker/internal/DatePickerPanel.d.ts +2 -1
- package/date-picker/internal/DatePickerPanel.js +4 -4
- package/date-picker/types.d.ts +3 -3
- package/dialog-service.d.ts +9 -6
- package/dialog-service.js +50 -26
- package/drawer/Drawer.d.ts +1 -1
- package/drawer/Drawer.js +83 -92
- package/drawer/DrawerFooter.d.ts +1 -1
- package/drawer/DrawerFooter.js +12 -9
- package/drawer/DrawerHeader.d.ts +1 -1
- package/drawer/DrawerHeader.js +10 -7
- package/drawer/types.d.ts +9 -2
- package/drawer/vars.d.ts +5 -1
- package/drawer/vars.js +1 -1
- package/dropdown/Dropdown.d.ts +2 -4
- package/dropdown/Dropdown.js +83 -104
- package/dropdown/internal/DropdownGroup.d.ts +1 -1
- package/dropdown/internal/DropdownItem.d.ts +1 -1
- package/dropdown/internal/DropdownSub.d.ts +2 -1
- package/dropdown/internal/DropdownSub.js +26 -49
- package/dropdown/types.d.ts +15 -2
- package/empty/Empty.d.ts +1 -1
- package/fab/Fab.d.ts +1 -1
- package/fab/Fab.js +19 -14
- package/fab/FabBacktop.d.ts +1 -1
- package/fab/FabBacktop.js +24 -31
- package/fab/FabButton.d.ts +1 -1
- package/fab/FabButton.js +37 -10
- package/fab/types.d.ts +6 -2
- package/fab/vars.d.ts +14 -0
- package/fab/vars.js +4 -0
- package/form/Form.d.ts +1 -1
- package/form/Form.js +7 -2
- package/form/FormItem.d.ts +1 -1
- package/form/FormItem.js +35 -24
- package/form/internal/FormError.d.ts +3 -2
- package/form/internal/FormError.js +10 -19
- package/hooks/index.d.ts +0 -2
- package/hooks/index.js +0 -2
- package/hooks/useComponentProps.js +2 -2
- package/hooks/useFocusVisible.d.ts +9 -2
- package/hooks/useFocusVisible.js +5 -11
- package/hooks/useLayout.d.ts +2 -2
- package/hooks/useLayout.js +2 -2
- package/hooks/useNamespace.js +2 -2
- package/hooks/useNestedPopup.d.ts +1 -1
- package/hooks/useScopedProps.js +2 -2
- package/hooks/useStyled.js +2 -2
- package/hooks/useTranslation.js +2 -2
- package/icon/Icon.d.ts +1 -1
- package/icon/Icon.js +7 -4
- package/image/Image.d.ts +1 -1
- package/image/Image.js +6 -2
- package/image/ImageAction.d.ts +1 -1
- package/image/ImageAction.js +3 -4
- package/image/ImageLoader.d.ts +1 -1
- package/image/ImagePreview.d.ts +1 -1
- package/image/ImagePreview.js +94 -109
- package/image/types.d.ts +6 -2
- package/input/Input.d.ts +1 -1
- package/input/Input.js +12 -8
- package/input/InputNumber.js +49 -40
- package/input/types.d.ts +3 -5
- package/internal/lazy-loading/LazyLoading.d.ts +3 -0
- package/internal/lazy-loading/LazyLoading.js +9 -0
- package/internal/lazy-loading/index.d.ts +2 -0
- package/internal/lazy-loading/index.js +1 -0
- package/internal/lazy-loading/types.d.ts +7 -0
- package/internal/popup/Popup.d.ts +1 -1
- package/internal/popup/Popup.js +40 -68
- package/internal/popup/types.d.ts +13 -6
- package/internal/portal/Portal.d.ts +1 -1
- package/internal/portal/Portal.js +12 -6
- package/internal/portal/types.d.ts +3 -2
- package/mask/Mask.d.ts +3 -0
- package/mask/Mask.js +31 -0
- package/menu/Menu.d.ts +2 -4
- package/menu/Menu.js +37 -42
- package/menu/internal/MenuGroup.d.ts +1 -1
- package/menu/internal/MenuItem.d.ts +1 -1
- package/menu/internal/MenuItem.js +14 -10
- package/menu/internal/MenuSub.d.ts +2 -1
- package/menu/internal/MenuSub.js +43 -70
- package/menu/types.d.ts +1 -0
- package/modal/Modal.d.ts +1 -1
- package/modal/Modal.js +77 -80
- package/modal/ModalAlert.d.ts +1 -1
- package/modal/ModalFooter.d.ts +1 -1
- package/modal/ModalFooter.js +12 -9
- package/modal/ModalHeader.d.ts +1 -1
- package/modal/ModalHeader.js +10 -7
- package/modal/types.d.ts +9 -2
- package/modal/vars.d.ts +5 -0
- package/modal/vars.js +2 -0
- package/notification/Notification.d.ts +1 -1
- package/notification/Notification.js +44 -71
- package/notification/types.d.ts +1 -0
- package/package.json +2 -2
- package/pagination/Pagination.d.ts +1 -1
- package/pagination/Pagination.js +9 -6
- package/popover/Popover.d.ts +2 -2
- package/popover/Popover.js +82 -118
- package/popover/PopoverFooter.d.ts +1 -1
- package/popover/PopoverFooter.js +12 -9
- package/popover/PopoverHeader.d.ts +1 -1
- package/popover/PopoverHeader.js +10 -7
- package/popover/types.d.ts +18 -4
- package/popover/vars.d.ts +5 -0
- package/popover/vars.js +2 -0
- package/progress/Progress.d.ts +1 -1
- package/radio/Radio.d.ts +1 -1
- package/radio/Radio.js +18 -13
- package/radio/RadioGroup.d.ts +1 -1
- package/radio/RadioGroup.js +12 -7
- package/radio/types.d.ts +16 -4
- package/radio/vars.d.ts +6 -0
- package/radio/vars.js +2 -0
- package/rating/Rating.d.ts +1 -1
- package/rating/internal/RatingStar.d.ts +1 -1
- package/rating/internal/RatingStar.js +23 -21
- package/root/Root.d.ts +1 -1
- package/root/Root.js +1 -1
- package/select/Select.d.ts +2 -4
- package/select/Select.js +245 -243
- package/select/types.d.ts +3 -3
- package/separator/Separator.d.ts +1 -1
- package/skeleton/Skeleton.d.ts +1 -1
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +54 -34
- package/slider/types.d.ts +2 -3
- package/slides/Slides.d.ts +1 -1
- package/slides/Slides.js +8 -3
- package/spinner/Spinner.d.ts +1 -1
- package/spinner/Spinner.js +27 -29
- package/stepper/Stepper.d.ts +1 -1
- package/stepper/Stepper.js +9 -16
- package/switch/Switch.js +33 -24
- package/switch/types.d.ts +2 -3
- package/table/Table.d.ts +1 -1
- package/table/Table.js +14 -10
- package/table/TableEmpty.d.ts +1 -1
- package/table/TableEmpty.js +9 -3
- package/table/TableExpand.d.ts +1 -1
- package/table/TableFilter.d.ts +1 -1
- package/table/TableFilter.js +1 -1
- package/table/TableTd.d.ts +1 -1
- package/table/TableTh.d.ts +1 -1
- package/table/TableThAction.d.ts +1 -1
- package/table/TableThAction.js +3 -4
- package/table/internal/TableCell.d.ts +1 -1
- package/table/internal/TableCell.js +13 -5
- package/table/types.d.ts +9 -2
- package/tabs/Tabs.d.ts +2 -4
- package/tabs/Tabs.js +41 -25
- package/tabs/types.d.ts +1 -0
- package/tag/Tag.d.ts +1 -1
- package/textarea/Textarea.d.ts +1 -1
- package/textarea/Textarea.js +15 -8
- package/textarea/types.d.ts +1 -0
- package/time-picker/TimePicker.d.ts +2 -2
- package/time-picker/TimePicker.js +89 -75
- package/time-picker/internal/TimePickerPanel.d.ts +2 -1
- package/time-picker/internal/TimePickerPanel.js +22 -7
- package/time-picker/types.d.ts +3 -3
- package/timeline/Timeline.d.ts +1 -1
- package/toast/Toast.d.ts +1 -1
- package/toast/Toast.js +44 -72
- package/toast/types.d.ts +1 -0
- package/tooltip/Tooltip.d.ts +2 -2
- package/tooltip/Tooltip.js +50 -74
- package/tooltip/types.d.ts +10 -2
- package/transfer/Transfer.d.ts +1 -1
- package/transfer/internal/TransferPanel.d.ts +1 -1
- package/transfer/internal/TransferPanel.js +7 -2
- package/{internal/transition → transition}/CollapseTransition.d.ts +1 -1
- package/transition/CollapseTransition.js +65 -0
- package/transition/Transition.d.ts +3 -0
- package/transition/Transition.js +148 -0
- package/transition/types.d.ts +29 -0
- package/tree/Tree.d.ts +1 -1
- package/tree/Tree.js +19 -7
- package/tree/internal/TreePanel.d.ts +2 -2
- package/tree/internal/TreePanel.js +32 -26
- package/tree-select/TreeSelect.d.ts +2 -4
- package/tree-select/TreeSelect.js +216 -213
- package/tree-select/internal/TreeSelectSearchPanel.d.ts +2 -2
- package/tree-select/internal/TreeSelectSearchPanel.js +15 -6
- package/tree-select/types.d.ts +3 -3
- package/types.d.ts +1 -1
- package/upload/Upload.d.ts +1 -3
- package/upload/Upload.js +41 -50
- package/upload/UploadAction.d.ts +1 -1
- package/upload/UploadAction.js +19 -16
- package/upload/UploadButton.d.ts +1 -1
- package/upload/UploadButton.js +16 -12
- package/upload/UploadList.d.ts +1 -1
- package/upload/UploadList.js +52 -47
- package/upload/UploadPicture.d.ts +1 -1
- package/upload/UploadPicture.js +47 -53
- package/upload/UploadPictureList.d.ts +1 -1
- package/upload/UploadPictureList.js +52 -47
- package/upload/UploadPreviewAction.d.ts +1 -1
- package/upload/UploadPreviewAction.js +15 -14
- package/upload/hooks.d.ts +2 -0
- package/upload/types.d.ts +27 -6
- package/upload/vars.d.ts +11 -0
- package/upload/vars.js +3 -0
- package/virtual-scroll/VirtualScroll.d.ts +2 -4
- package/virtual-scroll/VirtualScroll.js +13 -21
- package/virtual-scroll/types.d.ts +2 -1
- package/wave/Wave.d.ts +3 -0
- package/{internal/wave → wave}/Wave.js +6 -6
- package/{internal/wave → wave}/types.d.ts +1 -0
- package/wave/types.js +1 -0
- package/LICENSE +0 -21
- package/hooks/useJSS.d.ts +0 -1
- package/hooks/useJSS.js +0 -15
- package/hooks/useNextTick.d.ts +0 -2
- package/internal/mask/Mask.d.ts +0 -3
- package/internal/mask/Mask.js +0 -36
- package/internal/transition/CollapseTransition.js +0 -101
- package/internal/transition/Transition.d.ts +0 -3
- package/internal/transition/Transition.js +0 -87
- package/internal/transition/types.d.ts +0 -33
- package/internal/wave/Wave.d.ts +0 -3
- /package/{internal/circular-progress → circular-progress}/index.d.ts +0 -0
- /package/{internal/circular-progress → circular-progress}/index.js +0 -0
- /package/{internal/circular-progress → circular-progress}/vars.d.ts +0 -0
- /package/{internal/circular-progress → circular-progress}/vars.js +0 -0
- /package/internal/{mask → lazy-loading}/types.js +0 -0
- /package/{internal/mask → mask}/index.d.ts +0 -0
- /package/{internal/mask → mask}/index.js +0 -0
- /package/{internal/mask → mask}/types.d.ts +0 -0
- /package/{internal/transition → mask}/types.js +0 -0
- /package/{internal/mask → mask}/vars.d.ts +0 -0
- /package/{internal/mask → mask}/vars.js +0 -0
- /package/{internal/transition → transition}/index.d.ts +0 -0
- /package/{internal/transition → transition}/index.js +0 -0
- /package/{internal/wave → transition}/types.js +0 -0
- /package/{hooks/useNextTick.js → upload/hooks.js} +0 -0
- /package/{internal/wave → wave}/index.d.ts +0 -0
- /package/{internal/wave → wave}/index.js +0 -0
- /package/{internal/wave → wave}/vars.d.ts +0 -0
- /package/{internal/wave → wave}/vars.js +0 -0
package/popover/PopoverHeader.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import CloseOutlined from '@material-design-icons/svg/outlined/close.svg?react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { has } from 'lodash';
|
|
5
|
+
import { Fragment, use } from 'react';
|
|
6
|
+
import { CLASSES, PopoverContext } from './vars';
|
|
6
7
|
import { Button } from '../button';
|
|
7
8
|
import { useComponentProps, useControlled, useStyled, useTranslation } from '../hooks';
|
|
8
9
|
import { Icon } from '../icon';
|
|
9
10
|
import { mergeCS } from '../utils';
|
|
10
11
|
export function PopoverHeader(props) {
|
|
11
|
-
const _a = useComponentProps('PopoverHeader', props), { styleOverrides, styleProvider, children, actions = [], closeProps: closePropsProp, onCloseClick
|
|
12
|
+
const _a = useComponentProps('PopoverHeader', props), { styleOverrides, styleProvider, children, actions = [], closeProps: closePropsProp, onCloseClick } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "children", "actions", "closeProps", "onCloseClick"]);
|
|
12
13
|
const styled = useStyled(CLASSES, { popover: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.popover }, styleOverrides);
|
|
13
14
|
const { t } = useTranslation();
|
|
15
|
+
const popoverContext = use(PopoverContext);
|
|
14
16
|
const [closeLoading, changeCloseLoading] = useControlled(false, closePropsProp === null || closePropsProp === void 0 ? void 0 : closePropsProp.loading);
|
|
15
17
|
const closeProps = Object.assign(Object.assign({}, closePropsProp), { loading: closeLoading, onClick: () => {
|
|
16
18
|
const shouldClose = onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
|
|
@@ -19,19 +21,20 @@ export function PopoverHeader(props) {
|
|
|
19
21
|
shouldClose.then((val) => {
|
|
20
22
|
changeCloseLoading(false);
|
|
21
23
|
if (val !== false) {
|
|
22
|
-
|
|
24
|
+
popoverContext === null || popoverContext === void 0 ? void 0 : popoverContext.onClose();
|
|
23
25
|
}
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
else if (shouldClose !== false) {
|
|
27
|
-
|
|
29
|
+
popoverContext === null || popoverContext === void 0 ? void 0 : popoverContext.onClose();
|
|
28
30
|
}
|
|
29
31
|
} });
|
|
30
32
|
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('popover__header'), {
|
|
31
33
|
className: restProps.className,
|
|
32
34
|
style: restProps.style,
|
|
33
|
-
}), { children: [_jsx("div", Object.assign({}, styled('popover__header-title'), { id:
|
|
35
|
+
}), { children: [_jsx("div", Object.assign({}, styled('popover__header-title'), { id: popoverContext === null || popoverContext === void 0 ? void 0 : popoverContext.id, children: children })), _jsx("div", Object.assign({}, styled('popover__header-actions'), { children: actions.map((node, index) => {
|
|
34
36
|
var _a, _b, _c;
|
|
35
|
-
|
|
37
|
+
const { id, action } = (has(node, ['id', 'action']) ? node : { id: index, action: node });
|
|
38
|
+
return (_jsx(Fragment, { children: action === 'close' ? (_jsx(Button, Object.assign({}, closeProps, { "aria-label": (_a = closeProps['aria-label']) !== null && _a !== void 0 ? _a : t('Close'), pattern: (_b = closeProps.pattern) !== null && _b !== void 0 ? _b : 'text', icon: (_c = closeProps.icon) !== null && _c !== void 0 ? _c : (_jsx(Icon, { children: _jsx(CloseOutlined, {}) })) }))) : (action) }, id));
|
|
36
39
|
}) }))] })));
|
|
37
40
|
}
|
package/popover/types.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { ButtonProps } from '../button';
|
|
4
|
-
import type { BaseProps,
|
|
4
|
+
import type { BaseProps, PopupPlacement } from '../types';
|
|
5
5
|
export {};
|
|
6
6
|
export interface PopoverRef {
|
|
7
7
|
updatePosition: () => void;
|
|
8
8
|
}
|
|
9
9
|
export interface PopoverProps extends BaseProps<'popover', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'content'> {
|
|
10
|
-
|
|
10
|
+
ref?: React.Ref<PopoverRef>;
|
|
11
|
+
children: (props: {
|
|
12
|
+
id: string;
|
|
13
|
+
onClick: React.MouseEventHandler<HTMLElement>;
|
|
14
|
+
onMouseEnter: React.MouseEventHandler<HTMLElement>;
|
|
15
|
+
onMouseLeave: React.MouseEventHandler<HTMLElement>;
|
|
16
|
+
onKeyDown: React.KeyboardEventHandler<HTMLElement>;
|
|
17
|
+
}) => React.ReactNode;
|
|
11
18
|
content: React.ReactNode;
|
|
12
19
|
header?: React.ReactElement | string;
|
|
13
20
|
footer?: React.ReactElement;
|
|
@@ -25,18 +32,25 @@ export interface PopoverProps extends BaseProps<'popover', typeof CLASSES>, Omit
|
|
|
25
32
|
modal?: boolean;
|
|
26
33
|
skipFirstTransition?: boolean;
|
|
27
34
|
destroyAfterClose?: boolean;
|
|
35
|
+
lazyLoading?: boolean;
|
|
28
36
|
zIndex?: number | string;
|
|
29
37
|
onVisibleChange?: (visible: boolean) => void;
|
|
30
38
|
afterVisibleChange?: (visible: boolean) => void;
|
|
31
39
|
}
|
|
32
40
|
export interface PopoverHeaderProps extends BaseProps<'popover', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
|
|
33
|
-
actions?: React.ReactNode
|
|
41
|
+
actions?: (React.ReactNode | {
|
|
42
|
+
id: React.Key;
|
|
43
|
+
action: React.ReactNode;
|
|
44
|
+
})[];
|
|
34
45
|
closeProps?: ButtonProps;
|
|
35
46
|
onCloseClick?: () => any | Promise<any>;
|
|
36
47
|
}
|
|
37
48
|
export interface PopoverFooterProps extends BaseProps<'popover', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
38
49
|
align?: 'left' | 'center' | 'right';
|
|
39
|
-
actions?: React.ReactNode
|
|
50
|
+
actions?: (React.ReactNode | {
|
|
51
|
+
id: React.Key;
|
|
52
|
+
action: React.ReactNode;
|
|
53
|
+
})[];
|
|
40
54
|
cancelProps?: ButtonProps;
|
|
41
55
|
okProps?: ButtonProps;
|
|
42
56
|
onCancelClick?: () => any | Promise<any>;
|
package/popover/vars.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const CLASSES: {
|
|
2
3
|
popover: string;
|
|
3
4
|
'popover--top': string;
|
|
@@ -28,3 +29,7 @@ export declare const TTANSITION_DURING: {
|
|
|
28
29
|
enter: number;
|
|
29
30
|
leave: number;
|
|
30
31
|
};
|
|
32
|
+
export declare const PopoverContext: import("react").Context<{
|
|
33
|
+
id: string;
|
|
34
|
+
onClose: () => void;
|
|
35
|
+
} | undefined>;
|
package/popover/vars.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
1
2
|
export const CLASSES = {
|
|
2
3
|
popover: '^popover',
|
|
3
4
|
'popover--top': '^popover--top',
|
|
@@ -25,3 +26,4 @@ export const CLASSES = {
|
|
|
25
26
|
'popover__footer--right': '^popover__footer--right',
|
|
26
27
|
};
|
|
27
28
|
export const TTANSITION_DURING = { enter: 86, leave: 100 };
|
|
29
|
+
export const PopoverContext = createContext(undefined);
|
package/progress/Progress.d.ts
CHANGED
package/radio/Radio.d.ts
CHANGED
package/radio/Radio.js
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { checkNodeExist } from '@laser-ui/utils';
|
|
4
|
-
import { useRef } from 'react';
|
|
4
|
+
import { use, useRef } from 'react';
|
|
5
5
|
import { RadioGroup } from './RadioGroup';
|
|
6
|
-
import { CLASSES } from './vars';
|
|
6
|
+
import { CLASSES, RadioGroupContext } from './vars';
|
|
7
7
|
import { useComponentProps, useControlled, useDesign, useNamespace, useScopedProps, useStyled } from '../hooks';
|
|
8
|
-
import { Wave } from '../internal/wave';
|
|
9
8
|
import { mergeCS } from '../utils';
|
|
9
|
+
import { Wave } from '../wave';
|
|
10
10
|
export const Radio = (props) => {
|
|
11
|
-
const _a = useComponentProps('Radio', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, disabled: disabledProp = false,
|
|
11
|
+
const _a = useComponentProps('Radio', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, disabled: disabledProp = false, inputProps, onModelChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "disabled", "inputProps", "onModelChange"]);
|
|
12
12
|
const namespace = useNamespace();
|
|
13
13
|
const styled = useStyled(CLASSES, { radio: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.radio }, styleOverrides);
|
|
14
14
|
const waveRef = useRef(null);
|
|
15
|
+
const groupContext = use(RadioGroupContext);
|
|
15
16
|
const [checked, changeChecked] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : false, model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
16
17
|
const { disabled } = useScopedProps({ disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
17
|
-
const designProps = useDesign({ compose:
|
|
18
|
-
const inputNode = (_jsx("input", Object.assign({}, styled('radio__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: inputRef, type: "radio", checked: checked, disabled: disabled, "aria-checked": checked, onChange: () => {
|
|
19
|
-
changeChecked(true);
|
|
20
|
-
} })));
|
|
18
|
+
const designProps = useDesign({ compose: (groupContext === null || groupContext === void 0 ? void 0 : groupContext.pattern) ? { active: checked, disabled } : undefined });
|
|
21
19
|
return (_jsxs("label", Object.assign({}, restProps, mergeCS(styled('radio', {
|
|
22
20
|
'radio.is-checked': checked,
|
|
23
21
|
'radio.is-disabled': disabled,
|
|
24
|
-
'radio--button':
|
|
25
|
-
[`radio--button-${
|
|
26
|
-
[`radio--button-${
|
|
22
|
+
'radio--button': groupContext === null || groupContext === void 0 ? void 0 : groupContext.pattern,
|
|
23
|
+
[`radio--button-${groupContext === null || groupContext === void 0 ? void 0 : groupContext.pattern}`]: groupContext === null || groupContext === void 0 ? void 0 : groupContext.pattern,
|
|
24
|
+
[`radio--button-${groupContext === null || groupContext === void 0 ? void 0 : groupContext.size}`]: groupContext === null || groupContext === void 0 ? void 0 : groupContext.size,
|
|
27
25
|
}), {
|
|
28
26
|
className: restProps.className,
|
|
29
27
|
style: restProps.style,
|
|
30
28
|
}), designProps, { onClick: (e) => {
|
|
31
29
|
var _a, _b;
|
|
32
30
|
(_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
33
|
-
if (
|
|
31
|
+
if (groupContext === null || groupContext === void 0 ? void 0 : groupContext.pattern) {
|
|
34
32
|
(_b = waveRef.current) === null || _b === void 0 ? void 0 : _b.call(waveRef);
|
|
35
33
|
}
|
|
36
|
-
}, children: [_jsx(Wave, { ref:
|
|
34
|
+
}, children: [_jsx(Wave, { ref: (instance) => {
|
|
35
|
+
waveRef.current = instance;
|
|
36
|
+
return () => {
|
|
37
|
+
waveRef.current = null;
|
|
38
|
+
};
|
|
39
|
+
}, color: `var(--${namespace}-color-primary)` }), _jsx("div", Object.assign({}, styled('radio__input-wrapper'), { children: _jsx("input", Object.assign({}, inputProps, styled('radio__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { type: "radio", checked: checked, disabled: disabled, "aria-checked": checked, onChange: () => {
|
|
40
|
+
changeChecked(true);
|
|
41
|
+
} })) })), checkNodeExist(children) && _jsx("div", Object.assign({}, styled('radio__label'), { children: children }))] })));
|
|
37
42
|
};
|
|
38
43
|
Radio.Group = RadioGroup;
|
package/radio/RadioGroup.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { RadioGroupItem, RadioGroupProps } from './types';
|
|
3
|
-
export declare function RadioGroup<V extends React.Key, T extends RadioGroupItem<V>>(props: RadioGroupProps<V, T>):
|
|
3
|
+
export declare function RadioGroup<V extends React.Key, T extends RadioGroupItem<V>>(props: RadioGroupProps<V, T>): React.ReactElement | null;
|
package/radio/RadioGroup.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { nth } from 'lodash';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { RadioGroupContext } from './vars';
|
|
5
5
|
import { useComponentProps, useControlled, useScopedProps } from '../hooks';
|
|
6
6
|
export function RadioGroup(props) {
|
|
7
|
-
var _a, _b
|
|
7
|
+
var _a, _b;
|
|
8
8
|
const { children, formControl, list, model, defaultModel, pattern, size: sizeProp, name: nameProp, disabled: disabledProp = false, onModelChange, } = useComponentProps('RadioGroup', props);
|
|
9
9
|
const uniqueId = useId();
|
|
10
10
|
const name = nameProp !== null && nameProp !== void 0 ? nameProp : uniqueId;
|
|
@@ -14,8 +14,13 @@ export function RadioGroup(props) {
|
|
|
14
14
|
}
|
|
15
15
|
}, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
16
16
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
return (_jsx(RadioGroupContext, { value: { pattern, size }, children: children({ role: 'radiogroup' }, (option) => ({
|
|
18
|
+
children: option.label,
|
|
19
|
+
model: option.value === value,
|
|
20
|
+
disabled: option.disabled || disabled,
|
|
21
|
+
inputProps: Object.assign({ name, value: option.value }, formControl === null || formControl === void 0 ? void 0 : formControl.inputAria),
|
|
22
|
+
onModelChange: () => {
|
|
23
|
+
changeValue(option.value);
|
|
24
|
+
},
|
|
25
|
+
}), list) }));
|
|
21
26
|
}
|
package/radio/types.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { FormControlProvider } from '../form/types';
|
|
4
|
-
import type { BaseProps,
|
|
4
|
+
import type { BaseProps, Size } from '../types';
|
|
5
5
|
export {};
|
|
6
6
|
export interface RadioProps extends BaseProps<'radio', typeof CLASSES>, React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
7
7
|
formControl?: FormControlProvider;
|
|
8
8
|
model?: boolean;
|
|
9
9
|
defaultModel?: boolean;
|
|
10
10
|
disabled?: boolean;
|
|
11
|
-
|
|
12
|
-
inputRender?: CloneHTMLElement;
|
|
11
|
+
inputProps?: React.ComponentPropsWithRef<'input'>;
|
|
13
12
|
onModelChange?: (checked: boolean) => void;
|
|
14
13
|
}
|
|
15
14
|
export interface RadioGroupItem<V extends React.Key> {
|
|
@@ -18,7 +17,20 @@ export interface RadioGroupItem<V extends React.Key> {
|
|
|
18
17
|
disabled?: boolean;
|
|
19
18
|
}
|
|
20
19
|
export interface RadioGroupProps<V extends React.Key, T extends RadioGroupItem<V>> {
|
|
21
|
-
children: (
|
|
20
|
+
children: (props: {
|
|
21
|
+
role: 'radiogroup';
|
|
22
|
+
}, optionProps: (option: T) => {
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
model: boolean;
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
inputProps?: {
|
|
27
|
+
name: string;
|
|
28
|
+
value: V;
|
|
29
|
+
'aria-invalid'?: boolean;
|
|
30
|
+
'aria-describedby'?: string;
|
|
31
|
+
};
|
|
32
|
+
onModelChange: () => void;
|
|
33
|
+
}, options: T[]) => React.ReactElement | null;
|
|
22
34
|
formControl?: FormControlProvider;
|
|
23
35
|
list: T[];
|
|
24
36
|
model?: V | null;
|
package/radio/vars.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Size } from '../types';
|
|
1
3
|
export declare const CLASSES: {
|
|
2
4
|
radio: string;
|
|
3
5
|
'radio.is-checked': string;
|
|
@@ -12,3 +14,7 @@ export declare const CLASSES: {
|
|
|
12
14
|
radio__input: string;
|
|
13
15
|
radio__label: string;
|
|
14
16
|
};
|
|
17
|
+
export declare const RadioGroupContext: import("react").Context<{
|
|
18
|
+
pattern?: "fill" | "outline" | undefined;
|
|
19
|
+
size: Size;
|
|
20
|
+
} | undefined>;
|
package/radio/vars.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
1
2
|
export const CLASSES = {
|
|
2
3
|
radio: '^radio',
|
|
3
4
|
'radio.is-checked': 'is-checked',
|
|
@@ -12,3 +13,4 @@ export const CLASSES = {
|
|
|
12
13
|
radio__input: '^radio__input',
|
|
13
14
|
radio__label: '^radio__label',
|
|
14
15
|
};
|
|
16
|
+
export const RadioGroupContext = createContext(undefined);
|
package/rating/Rating.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ interface RatingStarProps {
|
|
|
15
15
|
onCheck: (value: number) => void;
|
|
16
16
|
onHoverChange: (value: number) => void;
|
|
17
17
|
}
|
|
18
|
-
export declare function RatingStar(props: RatingStarProps):
|
|
18
|
+
export declare function RatingStar(props: RatingStarProps): React.ReactElement | null;
|
|
19
19
|
export {};
|
|
@@ -4,7 +4,6 @@ import { useId, useState } from 'react';
|
|
|
4
4
|
import { useNamespace } from '../../hooks';
|
|
5
5
|
import { Tooltip } from '../../tooltip';
|
|
6
6
|
export function RatingStar(props) {
|
|
7
|
-
var _a, _b;
|
|
8
7
|
const { styled, value, hover, checked: checkedProp, icon, tooltip, name, half, disabled, inputProps, onCheck, onHoverChange } = props;
|
|
9
8
|
const namespace = useNamespace();
|
|
10
9
|
const uniqueId = useId();
|
|
@@ -14,24 +13,27 @@ export function RatingStar(props) {
|
|
|
14
13
|
const halfValue = value - 0.5;
|
|
15
14
|
const halfChecked = halfValue === checkedProp;
|
|
16
15
|
const [tooltipValue, setTooltipValue] = useState(value);
|
|
17
|
-
const node = (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
16
|
+
const node = (tooltipProps) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
return (_jsxs("div", Object.assign({}, styled('rating__star'), tooltipProps, { children: [half && (_jsxs(_Fragment, { children: [_jsx("input", Object.assign({}, styled('rating__input', 'rating__input--half'), inputProps, { id: halfInputId, type: "radio", name: name, checked: halfChecked, disabled: disabled, "aria-checked": halfChecked, onChange: () => {
|
|
19
|
+
onCheck(halfValue);
|
|
20
|
+
}, onMouseEnter: () => {
|
|
21
|
+
if (!isUndefined(tooltip)) {
|
|
22
|
+
setTooltipValue(halfValue);
|
|
23
|
+
}
|
|
24
|
+
onHoverChange(halfValue);
|
|
25
|
+
} })), _jsx("label", Object.assign({}, styled('rating__icon', 'rating__icon--half', {
|
|
26
|
+
'rating__icon.is-checked': halfValue <= ((_a = hover !== null && hover !== void 0 ? hover : checkedProp) !== null && _a !== void 0 ? _a : 0),
|
|
27
|
+
}), { htmlFor: halfInputId, children: icon }))] })), _jsxs("label", Object.assign({}, styled('rating__icon', {
|
|
28
|
+
'rating__icon.is-checked': value <= ((_b = hover !== null && hover !== void 0 ? hover : checkedProp) !== null && _b !== void 0 ? _b : 0),
|
|
29
|
+
}), { children: [_jsx("input", Object.assign({}, styled('rating__input'), { id: inputId, type: "radio", name: name, checked: checked, disabled: disabled, "aria-checked": checked, onChange: () => {
|
|
30
|
+
onCheck(value);
|
|
31
|
+
}, onMouseEnter: () => {
|
|
32
|
+
if (!isUndefined(tooltip)) {
|
|
33
|
+
setTooltipValue(value);
|
|
34
|
+
}
|
|
35
|
+
onHoverChange(value);
|
|
36
|
+
} })), icon] }))] })));
|
|
37
|
+
};
|
|
38
|
+
return isUndefined(tooltip) ? node() : _jsx(Tooltip, { title: tooltip(tooltipValue), children: node });
|
|
37
39
|
}
|
package/root/Root.d.ts
CHANGED
package/root/Root.js
CHANGED
|
@@ -69,5 +69,5 @@ export function Root(props) {
|
|
|
69
69
|
default:
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
|
-
return (_jsxs(RootContext
|
|
72
|
+
return (_jsxs(RootContext, { value: context, children: [children, dialogs.map(({ node }) => node)] }));
|
|
73
73
|
}
|
package/select/Select.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { SelectItem, SelectProps
|
|
3
|
-
declare function
|
|
4
|
-
export declare const Select: <V extends React.Key, T extends SelectItem<V>>(props: SelectProps<V, T> & React.RefAttributes<SelectRef>) => ReturnType<typeof SelectFC>;
|
|
5
|
-
export {};
|
|
2
|
+
import type { SelectItem, SelectProps } from './types';
|
|
3
|
+
export declare function Select<V extends React.Key, T extends SelectItem<V>>(props: SelectProps<V, T>): React.ReactElement | null;
|