@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/skeleton/Skeleton.d.ts
CHANGED
package/slider/Slider.d.ts
CHANGED
package/slider/Slider.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createElement as _createElement } from "react";
|
|
4
|
-
import { useEvent, useRefExtra } from '@laser-ui/hooks';
|
|
4
|
+
import { useEvent, useIsomorphicLayoutEffect, useRefExtra } from '@laser-ui/hooks';
|
|
5
5
|
import { isArray, isNull, isNumber, toNumber } from 'lodash';
|
|
6
|
-
import {
|
|
6
|
+
import { useRef, useState } from 'react';
|
|
7
7
|
import { CLASSES } from './vars';
|
|
8
8
|
import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled } from '../hooks';
|
|
9
9
|
import { Tooltip } from '../tooltip';
|
|
10
10
|
import { mergeCS } from '../utils';
|
|
11
11
|
export function Slider(props) {
|
|
12
|
-
const _a = useComponentProps('Slider', props), { styleOverrides, styleProvider, formControl, model, defaultModel, max = 100, min = 0, step = 1, range = false, rangeMinDistance, rangeThumbDraggable = false, tooltip, customTooltip, marks, vertical = false, reverse = false, disabled: disabledProp = false,
|
|
12
|
+
const _a = useComponentProps('Slider', props), { styleOverrides, styleProvider, formControl, model, defaultModel, max = 100, min = 0, step = 1, range = false, rangeMinDistance, rangeThumbDraggable = false, tooltip, customTooltip, marks, vertical = false, reverse = false, disabled: disabledProp = false, inputProps, onModelChange } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "max", "min", "step", "range", "rangeMinDistance", "rangeThumbDraggable", "tooltip", "customTooltip", "marks", "vertical", "reverse", "disabled", "inputProps", "onModelChange"]);
|
|
13
13
|
const styled = useStyled(CLASSES, { slider: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.slider }, styleOverrides);
|
|
14
14
|
const sliderRef = useRef(null);
|
|
15
15
|
const dotLeftRef = useRef(null);
|
|
@@ -163,7 +163,7 @@ export function Slider(props) {
|
|
|
163
163
|
handle(true);
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
|
|
166
|
+
useIsomorphicLayoutEffect(() => {
|
|
167
167
|
var _a, _b, _c, _d;
|
|
168
168
|
if (thumbDraggingPoint) {
|
|
169
169
|
(_a = tooltipLeftRef.current) === null || _a === void 0 ? void 0 : _a.updatePosition();
|
|
@@ -238,41 +238,56 @@ export function Slider(props) {
|
|
|
238
238
|
return nodes;
|
|
239
239
|
})();
|
|
240
240
|
const getDotNode = (isLeft) => {
|
|
241
|
+
const index = isLeft ? 0 : 1;
|
|
241
242
|
const value = isLeft ? valueLeft : valueRight;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const isAdd = offset > 0;
|
|
250
|
-
draft[index] = val;
|
|
251
|
-
if (isNumber(rangeMinDistance) && draft[1] - draft[0] < rangeMinDistance) {
|
|
252
|
-
const _index = isLeft ? 1 : 0;
|
|
253
|
-
draft[_index] = getValue(draft[_index] + offset, isAdd ? 'ceil' : 'floor');
|
|
254
|
-
if (draft[1] - draft[0] < rangeMinDistance) {
|
|
255
|
-
draft[index] = getValue(draft[_index] + (isAdd ? -rangeMinDistance : rangeMinDistance), isAdd ? 'floor' : 'ceil');
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
changeValue(val);
|
|
262
|
-
}
|
|
263
|
-
}, onFocus: () => {
|
|
264
|
-
setDotFocused(isLeft ? 'left' : 'right');
|
|
265
|
-
}, onBlur: () => {
|
|
266
|
-
setDotFocused(null);
|
|
267
|
-
} })));
|
|
268
|
-
return (_jsx(Tooltip, { ref: isLeft ? tooltipLeftRef : tooltipRightRef, visible: isLeft ? visibleLeft : visibleRight, title: customTooltip ? customTooltip(value) : value, placement: vertical ? 'right' : 'top', onVisibleChange: (visible) => {
|
|
243
|
+
return (_jsx(Tooltip, { ref: (instance) => {
|
|
244
|
+
const tooltipRef = isLeft ? tooltipLeftRef : tooltipRightRef;
|
|
245
|
+
tooltipRef.current = instance;
|
|
246
|
+
return () => {
|
|
247
|
+
tooltipRef.current = null;
|
|
248
|
+
};
|
|
249
|
+
}, visible: isLeft ? visibleLeft : visibleRight, title: customTooltip ? customTooltip(value) : value, placement: vertical ? 'right' : 'top', onVisibleChange: (visible) => {
|
|
269
250
|
setDotVisible(visible ? (isLeft ? 'left' : 'right') : null);
|
|
270
|
-
}, children: _jsx("div", Object.assign({}, mergeCS(styled('slider__input-wrapper'), {
|
|
251
|
+
}, children: (tooltipProps) => (_jsx("div", Object.assign({}, mergeCS(styled('slider__input-wrapper'), {
|
|
271
252
|
style: {
|
|
272
253
|
left: vertical ? undefined : `calc(${value} / ${max - min} * 100% - 7px)`,
|
|
273
254
|
bottom: vertical ? `calc(${value} / ${max - min} * 100% - 7px)` : undefined,
|
|
274
255
|
},
|
|
275
|
-
}), { ref:
|
|
256
|
+
}), { ref: (instance) => {
|
|
257
|
+
const dotRef = isLeft ? dotLeftRef : dotRightRef;
|
|
258
|
+
dotRef.current = instance;
|
|
259
|
+
return () => {
|
|
260
|
+
dotRef.current = null;
|
|
261
|
+
};
|
|
262
|
+
} }, tooltipProps, { children: _jsx("input", Object.assign({}, inputProps === null || inputProps === void 0 ? void 0 : inputProps[index], styled('slider__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { type: "range", value: value, max: max, min: min, step: step !== null && step !== void 0 ? step : undefined, disabled: disabled, "aria-orientation": vertical ? 'vertical' : 'horizontal', onChange: (e) => {
|
|
263
|
+
const val = toNumber(e.currentTarget.value);
|
|
264
|
+
if (range) {
|
|
265
|
+
const index = isLeft ? 0 : 1;
|
|
266
|
+
changeValue((draft) => {
|
|
267
|
+
const offset = val - draft[index];
|
|
268
|
+
const isAdd = offset > 0;
|
|
269
|
+
draft[index] = val;
|
|
270
|
+
if (isNumber(rangeMinDistance) && draft[1] - draft[0] < rangeMinDistance) {
|
|
271
|
+
const _index = isLeft ? 1 : 0;
|
|
272
|
+
draft[_index] = getValue(draft[_index] + offset, isAdd ? 'ceil' : 'floor');
|
|
273
|
+
if (draft[1] - draft[0] < rangeMinDistance) {
|
|
274
|
+
draft[index] = getValue(draft[_index] + (isAdd ? -rangeMinDistance : rangeMinDistance), isAdd ? 'floor' : 'ceil');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
changeValue(val);
|
|
281
|
+
}
|
|
282
|
+
}, onFocus: (e) => {
|
|
283
|
+
var _a, _b;
|
|
284
|
+
(_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
285
|
+
setDotFocused(isLeft ? 'left' : 'right');
|
|
286
|
+
}, onBlur: (e) => {
|
|
287
|
+
var _a, _b;
|
|
288
|
+
(_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
289
|
+
setDotFocused(null);
|
|
290
|
+
} })) }))) }));
|
|
276
291
|
};
|
|
277
292
|
const preventBlur = (e) => {
|
|
278
293
|
if (e.button === 0) {
|
|
@@ -285,7 +300,12 @@ export function Slider(props) {
|
|
|
285
300
|
}), {
|
|
286
301
|
className: restProps.className,
|
|
287
302
|
style: restProps.style,
|
|
288
|
-
}), designProps, { ref:
|
|
303
|
+
}), designProps, { ref: (instance) => {
|
|
304
|
+
sliderRef.current = instance;
|
|
305
|
+
return () => {
|
|
306
|
+
sliderRef.current = null;
|
|
307
|
+
};
|
|
308
|
+
}, onMouseDown: (e) => {
|
|
289
309
|
var _a;
|
|
290
310
|
(_a = restProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
291
311
|
preventBlur(e);
|
package/slider/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 } from '../types';
|
|
5
5
|
export {};
|
|
6
6
|
export interface SliderProps extends BaseProps<'slider', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
7
7
|
formControl?: FormControlProvider;
|
|
@@ -22,7 +22,6 @@ export interface SliderProps extends BaseProps<'slider', typeof CLASSES>, Omit<R
|
|
|
22
22
|
vertical?: boolean;
|
|
23
23
|
reverse?: boolean;
|
|
24
24
|
disabled?: boolean;
|
|
25
|
-
|
|
26
|
-
inputRender?: [CloneHTMLElement?, CloneHTMLElement?];
|
|
25
|
+
inputProps?: [React.ComponentPropsWithRef<'input'>?, React.ComponentPropsWithRef<'input'>?];
|
|
27
26
|
onModelChange?: (value: any) => void;
|
|
28
27
|
}
|
package/slides/Slides.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { SlidesItem, SlidesProps } from './types';
|
|
3
|
-
export declare function Slides<ID extends React.Key, T extends SlidesItem<ID>>(props: SlidesProps<ID, T>):
|
|
3
|
+
export declare function Slides<ID extends React.Key, T extends SlidesItem<ID>>(props: SlidesProps<ID, T>): React.ReactElement | null;
|
package/slides/Slides.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createElement as _createElement } from "react";
|
|
4
|
-
import { useAsync, useEvent, useRefExtra } from '@laser-ui/hooks';
|
|
4
|
+
import { useAsync, useEvent, useIsomorphicLayoutEffect, useRefExtra } from '@laser-ui/hooks';
|
|
5
5
|
import KeyboardArrowLeftOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_left.svg?react';
|
|
6
6
|
import KeyboardArrowRightOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_right.svg?react';
|
|
7
7
|
import { isBoolean, isNumber, isUndefined, nth } from 'lodash';
|
|
@@ -151,7 +151,7 @@ export function Slides(props) {
|
|
|
151
151
|
setDragDistance(0);
|
|
152
152
|
setDragOpacity(undefined);
|
|
153
153
|
};
|
|
154
|
-
|
|
154
|
+
useIsomorphicLayoutEffect(() => {
|
|
155
155
|
if (slidesRef.current) {
|
|
156
156
|
let size = 0;
|
|
157
157
|
const slideEls = slidesRef.current.querySelectorAll(`.${namespace}-slides__slide`);
|
|
@@ -212,7 +212,12 @@ export function Slides(props) {
|
|
|
212
212
|
}), {
|
|
213
213
|
className: restProps.className,
|
|
214
214
|
style: restProps.style,
|
|
215
|
-
}), { ref:
|
|
215
|
+
}), { ref: (instance) => {
|
|
216
|
+
slidesRef.current = instance;
|
|
217
|
+
return () => {
|
|
218
|
+
slidesRef.current = null;
|
|
219
|
+
};
|
|
220
|
+
}, onMouseEnter: (e) => {
|
|
216
221
|
var _a;
|
|
217
222
|
(_a = restProps.onMouseEnter) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
218
223
|
setMouseEnter(true);
|
package/spinner/Spinner.d.ts
CHANGED
package/spinner/Spinner.js
CHANGED
|
@@ -5,30 +5,28 @@ import { checkNodeExist } from '@laser-ui/utils';
|
|
|
5
5
|
import { isNumber, isUndefined } from 'lodash';
|
|
6
6
|
import { useEffect, useRef } from 'react';
|
|
7
7
|
import { CLASSES } from './vars';
|
|
8
|
-
import {
|
|
8
|
+
import { CircularProgress } from '../circular-progress';
|
|
9
|
+
import { useComponentProps, useNamespace, useStyled } from '../hooks';
|
|
9
10
|
import { Icon } from '../icon';
|
|
10
|
-
import {
|
|
11
|
-
import { Transition } from '../internal/transition';
|
|
11
|
+
import { Transition } from '../transition';
|
|
12
12
|
import { mergeCS } from '../utils';
|
|
13
13
|
import { TTANSITION_DURING_BASE } from '../vars';
|
|
14
14
|
export function Spinner(props) {
|
|
15
15
|
const _a = useComponentProps('Spinner', props), { children, styleOverrides, styleProvider, visible: visibleProp, text, size = 28, delay, alone = false, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "visible", "text", "size", "delay", "alone", "afterVisibleChange"]);
|
|
16
|
+
const namespace = useNamespace();
|
|
16
17
|
const styled = useStyled(CLASSES, { spinner: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.spinner }, styleOverrides);
|
|
17
18
|
const async = useAsync();
|
|
18
19
|
const forceUpdate = useForceUpdate();
|
|
19
20
|
const spinnerRef = useRef(null);
|
|
20
|
-
const
|
|
21
|
-
const dataRef = useRef({
|
|
22
|
-
delayVisible: false,
|
|
23
|
-
});
|
|
21
|
+
const delayVisible = useRef(false);
|
|
24
22
|
if (visibleProp === false) {
|
|
25
|
-
|
|
23
|
+
delayVisible.current = false;
|
|
26
24
|
}
|
|
27
|
-
const visible = isUndefined(delay) ? visibleProp :
|
|
25
|
+
const visible = isUndefined(delay) ? visibleProp : delayVisible.current;
|
|
28
26
|
useEffect(() => {
|
|
29
27
|
if (isNumber(delay) && visibleProp) {
|
|
30
28
|
const clearTid = async.setTimeout(() => {
|
|
31
|
-
|
|
29
|
+
delayVisible.current = true;
|
|
32
30
|
forceUpdate();
|
|
33
31
|
}, delay);
|
|
34
32
|
return () => {
|
|
@@ -36,31 +34,31 @@ export function Spinner(props) {
|
|
|
36
34
|
};
|
|
37
35
|
}
|
|
38
36
|
}, [async, delay, forceUpdate, visibleProp]);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
transition: ['opacity'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms linear`).join(', '),
|
|
43
|
-
},
|
|
44
|
-
leaving: {
|
|
45
|
-
opacity: 0,
|
|
46
|
-
transition: ['opacity'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms linear`).join(', '),
|
|
47
|
-
},
|
|
48
|
-
leaved: { display: 'none' },
|
|
49
|
-
};
|
|
50
|
-
return (_jsx(Transition, { enter: visible, during: TTANSITION_DURING_BASE, afterRender: () => {
|
|
51
|
-
if (!alone && spinnerRef.current && containerRef.current) {
|
|
52
|
-
containerRef.current.style.height = `${spinnerRef.current.offsetHeight}px`;
|
|
37
|
+
return (_jsx(Transition, { enter: visible, name: `${namespace}-fade`, duration: TTANSITION_DURING_BASE, onSkipEnter: () => {
|
|
38
|
+
if (spinnerRef.current) {
|
|
39
|
+
spinnerRef.current.style.setProperty('--spinner-container-height', `${spinnerRef.current.offsetHeight}px`);
|
|
53
40
|
}
|
|
54
|
-
},
|
|
41
|
+
}, onBeforeEnter: () => {
|
|
42
|
+
if (spinnerRef.current) {
|
|
43
|
+
spinnerRef.current.style.setProperty('--spinner-container-height', `${spinnerRef.current.offsetHeight}px`);
|
|
44
|
+
}
|
|
45
|
+
}, onAfterEnter: () => {
|
|
55
46
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
56
|
-
},
|
|
47
|
+
}, onAfterLeave: () => {
|
|
57
48
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
58
|
-
}, children: (
|
|
49
|
+
}, children: (transitionRef, leaved) => (_jsx("div", Object.assign({}, restProps, mergeCS(styled('spinner', {
|
|
59
50
|
'spinner--alone': alone,
|
|
60
51
|
}), {
|
|
61
52
|
className: restProps.className,
|
|
62
|
-
style: Object.assign(Object.assign({}, restProps.style),
|
|
63
|
-
}), { ref:
|
|
53
|
+
style: Object.assign(Object.assign({}, restProps.style), (leaved ? { display: 'none' } : undefined)),
|
|
54
|
+
}), { ref: (instance) => {
|
|
55
|
+
spinnerRef.current = instance;
|
|
56
|
+
transitionRef(instance);
|
|
57
|
+
return () => {
|
|
58
|
+
spinnerRef.current = null;
|
|
59
|
+
transitionRef(null);
|
|
60
|
+
};
|
|
61
|
+
}, children: _jsxs("div", Object.assign({}, styled('spinner__container'), { children: [children !== false && (_jsx("div", Object.assign({}, mergeCS(styled('spinner__icon'), {
|
|
64
62
|
style: { fontSize: size },
|
|
65
63
|
}), { children: checkNodeExist(children) ? (children) : (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) }))), checkNodeExist(text) && _jsx("div", Object.assign({}, styled('spinner__text'), { children: text }))] })) }))) }));
|
|
66
64
|
}
|
package/stepper/Stepper.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { StepperItem, StepperProps } from './types';
|
|
3
|
-
export declare function Stepper<T extends StepperItem>(props: StepperProps<T>):
|
|
3
|
+
export declare function Stepper<T extends StepperItem>(props: StepperProps<T>): React.ReactElement | null;
|
package/stepper/Stepper.js
CHANGED
|
@@ -8,8 +8,8 @@ import { isNumber, isUndefined } from 'lodash';
|
|
|
8
8
|
import { CLASSES } from './vars';
|
|
9
9
|
import { useComponentProps, useStyled } from '../hooks';
|
|
10
10
|
import { Icon } from '../icon';
|
|
11
|
-
import { CollapseTransition } from '../internal/transition';
|
|
12
11
|
import { Progress } from '../progress';
|
|
12
|
+
import { CollapseTransition } from '../transition';
|
|
13
13
|
import { mergeCS } from '../utils';
|
|
14
14
|
import { TTANSITION_DURING_BASE } from '../vars';
|
|
15
15
|
export function Stepper(props) {
|
|
@@ -68,20 +68,13 @@ export function Stepper(props) {
|
|
|
68
68
|
}), { style: { width: dotSize, height: dotSize } }), { children: [itemDot === false ? null : checkNodeExist(itemDot) ? (itemDot) : itemState === 'error' ? (_jsx(Icon, { children: _jsx(CloseOutlined, {}) })) : isCompleted ? (_jsx(Icon, { children: _jsx(CheckOutlined, {}) })) : (itemStep), isProgress && (_jsx("div", Object.assign({}, styled('stepper__step-progress'), { children: _jsx(Progress, { percent: percent, pattern: "circle", state: "process", label: false, size: dotSize + 8, lineWidth: 4 }) })))] })), !labelBottom && titleNode, !vertical && separatoreNode] })),
|
|
69
69
|
labelBottom && titleNode,
|
|
70
70
|
vertical && separatoreNode,
|
|
71
|
-
checkNodeExist(itemDescription) && (_jsx(CollapseTransition, {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
leaving: {
|
|
80
|
-
transition: ['height', 'padding', 'margin'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-in`).join(', '),
|
|
81
|
-
},
|
|
82
|
-
leaved: { display: 'none' },
|
|
83
|
-
}, children: (descriptionRef, collapseStyle) => (_jsx("div", Object.assign({}, mergeCS(styled('stepper__step-description'), {
|
|
84
|
-
style: Object.assign({ marginLeft: labelBottom ? undefined : `calc(${dotSize}px + 8px)` }, collapseStyle),
|
|
85
|
-
}), { ref: descriptionRef, children: itemDescription }))) }))));
|
|
71
|
+
checkNodeExist(itemDescription) && (_jsx(CollapseTransition, { height: 0, enter: !vertical || isActive, duration: TTANSITION_DURING_BASE, children: (transitionRef, leaved) => (_jsx("div", { ref: (instance) => {
|
|
72
|
+
transitionRef(instance);
|
|
73
|
+
return () => {
|
|
74
|
+
transitionRef(null);
|
|
75
|
+
};
|
|
76
|
+
}, style: { display: leaved ? 'none' : undefined }, children: _jsx("div", Object.assign({}, mergeCS(styled('stepper__step-description'), {
|
|
77
|
+
style: { marginLeft: labelBottom ? undefined : `calc(${dotSize}px + 8px)` },
|
|
78
|
+
}), { children: itemDescription })) })) }))));
|
|
86
79
|
}) })));
|
|
87
80
|
}
|
package/switch/Switch.js
CHANGED
|
@@ -2,34 +2,18 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { checkNodeExist } from '@laser-ui/utils';
|
|
4
4
|
import { CLASSES, TTANSITION_DURING } from './vars';
|
|
5
|
-
import {
|
|
5
|
+
import { CircularProgress } from '../circular-progress';
|
|
6
|
+
import { useComponentProps, useControlled, useDesign, useNamespace, useScopedProps, useStyled } from '../hooks';
|
|
6
7
|
import { Icon } from '../icon';
|
|
7
|
-
import {
|
|
8
|
-
import { Transition } from '../internal/transition';
|
|
8
|
+
import { Transition } from '../transition';
|
|
9
9
|
import { mergeCS } from '../utils';
|
|
10
10
|
export function Switch(props) {
|
|
11
|
-
const _a = useComponentProps('Switch', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, stateContent, labelPlacement = 'right', size: sizeProp, loading = false, disabled: disabledProp = false,
|
|
11
|
+
const _a = useComponentProps('Switch', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, stateContent, labelPlacement = 'right', size: sizeProp, loading = false, disabled: disabledProp = false, inputProps, onModelChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "stateContent", "labelPlacement", "size", "loading", "disabled", "inputProps", "onModelChange"]);
|
|
12
|
+
const namespace = useNamespace();
|
|
12
13
|
const styled = useStyled(CLASSES, { switch: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.switch }, styleOverrides);
|
|
13
14
|
const [checked, changeChecked] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : false, model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
14
15
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
15
16
|
const designProps = useDesign({ compose: { active: checked, disabled } });
|
|
16
|
-
const transitionStyles = {
|
|
17
|
-
enter: { left: 2 },
|
|
18
|
-
entering: {
|
|
19
|
-
left: 'calc(100% - 20px)',
|
|
20
|
-
transition: ['width', 'padding', 'margin', 'left'].map((attr) => `${attr} ${TTANSITION_DURING}ms linear`).join(', '),
|
|
21
|
-
},
|
|
22
|
-
entered: { right: 2 },
|
|
23
|
-
leave: { right: 2 },
|
|
24
|
-
leaving: {
|
|
25
|
-
right: 'calc(100% - 20px)',
|
|
26
|
-
transition: ['width', 'padding', 'margin', 'right'].map((attr) => `${attr} ${TTANSITION_DURING}ms linear`).join(', '),
|
|
27
|
-
},
|
|
28
|
-
leaved: { left: 2 },
|
|
29
|
-
};
|
|
30
|
-
const inputNode = (_jsx("input", Object.assign({}, styled('switch__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: inputRef, type: "checkbox", disabled: disabled, role: "switch", "aria-checked": checked, onChange: () => {
|
|
31
|
-
changeChecked((draft) => !draft);
|
|
32
|
-
} })));
|
|
33
17
|
return (_jsxs("label", Object.assign({}, restProps, mergeCS(styled('switch', `switch--${size}`, {
|
|
34
18
|
'switch--label-left': labelPlacement === 'left',
|
|
35
19
|
'switch.is-checked': checked,
|
|
@@ -42,7 +26,32 @@ export function Switch(props) {
|
|
|
42
26
|
style: { opacity: checked ? 1 : 0 },
|
|
43
27
|
}), { children: stateContent[0] }))), checkNodeExist(stateContent[1]) && (_jsx("div", Object.assign({}, mergeCS(styled('switch__state-content'), {
|
|
44
28
|
style: { opacity: checked ? 0 : 1 },
|
|
45
|
-
}), { children: stateContent[1] })))] })),
|
|
46
|
-
|
|
47
|
-
}),
|
|
29
|
+
}), { children: stateContent[1] })))] })), _jsx("input", Object.assign({}, inputProps, styled('switch__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { type: "checkbox", disabled: disabled, role: "switch", "aria-checked": checked, onChange: () => {
|
|
30
|
+
changeChecked((draft) => !draft);
|
|
31
|
+
} })), _jsx(Transition, { enter: checked, name: `${namespace}-switch`, duration: TTANSITION_DURING, onSkipEnter: (el) => {
|
|
32
|
+
if (el) {
|
|
33
|
+
el.style.left = '';
|
|
34
|
+
el.style.right = '2px';
|
|
35
|
+
}
|
|
36
|
+
}, onAfterEnter: (el) => {
|
|
37
|
+
if (el) {
|
|
38
|
+
el.style.left = '';
|
|
39
|
+
el.style.right = '2px';
|
|
40
|
+
}
|
|
41
|
+
}, onSkipLeave: (el) => {
|
|
42
|
+
if (el) {
|
|
43
|
+
el.style.left = '2px';
|
|
44
|
+
el.style.right = '';
|
|
45
|
+
}
|
|
46
|
+
}, onAfterLeave: (el) => {
|
|
47
|
+
if (el) {
|
|
48
|
+
el.style.left = '2px';
|
|
49
|
+
el.style.right = '';
|
|
50
|
+
}
|
|
51
|
+
}, children: (transitionRef) => (_jsx("div", Object.assign({}, styled('switch__state-dot'), { ref: (instance) => {
|
|
52
|
+
transitionRef(instance);
|
|
53
|
+
return () => {
|
|
54
|
+
transitionRef(null);
|
|
55
|
+
};
|
|
56
|
+
}, children: loading && (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) }))) })] })), checkNodeExist(children) && _jsx("div", Object.assign({}, styled('switch__label'), { children: children }))] })));
|
|
48
57
|
}
|
package/switch/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 SwitchProps extends BaseProps<'switch', typeof CLASSES>, React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
7
7
|
formControl?: FormControlProvider;
|
|
@@ -12,7 +12,6 @@ export interface SwitchProps extends BaseProps<'switch', typeof CLASSES>, React.
|
|
|
12
12
|
size?: Size;
|
|
13
13
|
loading?: boolean;
|
|
14
14
|
disabled?: boolean;
|
|
15
|
-
|
|
16
|
-
inputRender?: CloneHTMLElement;
|
|
15
|
+
inputProps?: React.ComponentPropsWithRef<'input'>;
|
|
17
16
|
onModelChange?: (checked: boolean) => void;
|
|
18
17
|
}
|
package/table/Table.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { TableTd } from './TableTd';
|
|
|
7
7
|
import { TableTh } from './TableTh';
|
|
8
8
|
import { TableThAction } from './TableThAction';
|
|
9
9
|
export declare const Table: {
|
|
10
|
-
(props: TableProps):
|
|
10
|
+
(props: TableProps): React.ReactElement | null;
|
|
11
11
|
Th: typeof TableTh;
|
|
12
12
|
ThAction: typeof TableThAction;
|
|
13
13
|
Td: typeof TableTd;
|
package/table/Table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useAsync,
|
|
3
|
+
import { useAsync, useIsomorphicLayoutEffect, useResize } from '@laser-ui/hooks';
|
|
4
4
|
import { isSimpleArrayEqual } from '@laser-ui/utils';
|
|
5
5
|
import { useMemo, useRef, useState } from 'react';
|
|
6
6
|
import { TableEmpty } from './TableEmpty';
|
|
@@ -17,7 +17,8 @@ export const Table = (props) => {
|
|
|
17
17
|
const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
|
|
18
18
|
const async = useAsync();
|
|
19
19
|
const divRef = useRef(null);
|
|
20
|
-
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
21
|
+
const clearTid = useRef(() => { });
|
|
21
22
|
const [fixed, setFixed] = useState([]);
|
|
22
23
|
const handleFixed = () => {
|
|
23
24
|
if (divRef.current) {
|
|
@@ -41,14 +42,12 @@ export const Table = (props) => {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
+
useIsomorphicLayoutEffect(() => {
|
|
45
46
|
handleFixed();
|
|
46
|
-
});
|
|
47
|
+
}, []);
|
|
47
48
|
useResize(divRef, () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
dataRef.current.clearTid = async.setTimeout(() => {
|
|
51
|
-
dataRef.current.clearTid = undefined;
|
|
49
|
+
clearTid.current();
|
|
50
|
+
clearTid.current = async.setTimeout(() => {
|
|
52
51
|
handleFixed();
|
|
53
52
|
}, 100);
|
|
54
53
|
});
|
|
@@ -58,11 +57,16 @@ export const Table = (props) => {
|
|
|
58
57
|
}), {
|
|
59
58
|
className: restProps.className,
|
|
60
59
|
style: restProps.style,
|
|
61
|
-
}), { ref:
|
|
60
|
+
}), { ref: (instance) => {
|
|
61
|
+
divRef.current = instance;
|
|
62
|
+
return () => {
|
|
63
|
+
divRef.current = null;
|
|
64
|
+
};
|
|
65
|
+
}, onScroll: (e) => {
|
|
62
66
|
var _a;
|
|
63
67
|
(_a = restProps.onScroll) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
64
68
|
handleFixed();
|
|
65
|
-
}, children: _jsx(TableContext
|
|
69
|
+
}, children: _jsx(TableContext, { value: context, children: children }) })));
|
|
66
70
|
};
|
|
67
71
|
Table.Th = TableTh;
|
|
68
72
|
Table.ThAction = TableThAction;
|
package/table/TableEmpty.d.ts
CHANGED
package/table/TableEmpty.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useIsomorphicLayoutEffect } from '@laser-ui/hooks';
|
|
3
4
|
import { checkNodeExist } from '@laser-ui/utils';
|
|
4
5
|
import { isUndefined } from 'lodash';
|
|
5
|
-
import {
|
|
6
|
+
import { useRef } from 'react';
|
|
6
7
|
import { CLASSES } from './vars';
|
|
7
8
|
import { Empty } from '../empty';
|
|
8
9
|
import { useComponentProps, useStyled } from '../hooks';
|
|
@@ -11,7 +12,7 @@ export function TableEmpty(props) {
|
|
|
11
12
|
const _a = useComponentProps('TableEmpty', props), { children, styleOverrides, styleProvider, colSpan } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "colSpan"]);
|
|
12
13
|
const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
|
|
13
14
|
const tdRef = useRef(null);
|
|
14
|
-
|
|
15
|
+
useIsomorphicLayoutEffect(() => {
|
|
15
16
|
var _a, _b;
|
|
16
17
|
if (isUndefined(colSpan) && tdRef.current) {
|
|
17
18
|
let tableEl = tdRef.current.parentElement;
|
|
@@ -33,5 +34,10 @@ export function TableEmpty(props) {
|
|
|
33
34
|
return (_jsx("tr", Object.assign({}, restProps, mergeCS(styled('table__empty'), {
|
|
34
35
|
className: restProps.className,
|
|
35
36
|
style: restProps.style,
|
|
36
|
-
}), { children: _jsx("td", { ref:
|
|
37
|
+
}), { children: _jsx("td", { ref: (instance) => {
|
|
38
|
+
tdRef.current = instance;
|
|
39
|
+
return () => {
|
|
40
|
+
tdRef.current = null;
|
|
41
|
+
};
|
|
42
|
+
}, colSpan: colSpan, children: _jsx("div", Object.assign({}, styled('table__empty-content'), { children: checkNodeExist(children) ? children : _jsx(Empty, { image: Empty.SIMPLE_IMG }) })) }) })));
|
|
37
43
|
}
|
package/table/TableExpand.d.ts
CHANGED
package/table/TableFilter.d.ts
CHANGED
package/table/TableFilter.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Icon } from '../icon';
|
|
|
9
9
|
import { Input } from '../input';
|
|
10
10
|
import { Popover } from '../popover';
|
|
11
11
|
export function TableFilter(props) {
|
|
12
|
-
const _a = useComponentProps('TableFilter', props), { children, styleOverrides, styleProvider, content, footer, visible, placement = 'bottom-right', placementFixed = false, escClosable = true, gap, inWindow = false, searchable = false, searchValue, modal = false, destroyAfterClose =
|
|
12
|
+
const _a = useComponentProps('TableFilter', props), { children, styleOverrides, styleProvider, content, footer, visible, placement = 'bottom-right', placementFixed = false, escClosable = true, gap, inWindow = false, searchable = false, searchValue, modal = false, destroyAfterClose = false, zIndex, onVisibleChange, onSearch, onReset, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "content", "footer", "visible", "placement", "placementFixed", "escClosable", "gap", "inWindow", "searchable", "searchValue", "modal", "destroyAfterClose", "zIndex", "onVisibleChange", "onSearch", "onReset", "afterVisibleChange"]);
|
|
13
13
|
const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
|
|
14
14
|
const { t } = useTranslation();
|
|
15
15
|
return (_jsx(Popover, Object.assign({}, restProps, { children: children, content: _jsxs("div", Object.assign({}, styled('table__filter'), { children: [searchable && (_jsx(Input, { style: { display: 'flex' }, model: searchValue, prefix: _jsx(Icon, { children: _jsx(SearchOutlined, {}) }), placeholder: t('Search'), clearable: true, onModelChange: (value) => {
|
package/table/TableTd.d.ts
CHANGED
package/table/TableTh.d.ts
CHANGED
package/table/TableThAction.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TableThActionProps } from './types';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function TableThAction(props: TableThActionProps): React.ReactElement | null;
|
package/table/TableThAction.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
3
|
import { CLASSES } from './vars';
|
|
5
4
|
import { useComponentProps, useStyled } from '../hooks';
|
|
6
5
|
import { mergeCS } from '../utils';
|
|
7
|
-
export
|
|
6
|
+
export function TableThAction(props) {
|
|
8
7
|
var _a, _b;
|
|
9
|
-
const _c = useComponentProps('TableThAction', props), { styleOverrides, styleProvider, children, active = false, disabled = false } = _c, restProps = __rest(_c, ["styleOverrides", "styleProvider", "children", "active", "disabled"]);
|
|
8
|
+
const _c = useComponentProps('TableThAction', props), { ref, styleOverrides, styleProvider, children, active = false, disabled = false } = _c, restProps = __rest(_c, ["ref", "styleOverrides", "styleProvider", "children", "active", "disabled"]);
|
|
10
9
|
const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
|
|
11
10
|
return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('table__th-action', {
|
|
12
11
|
'table__th-action.is-active': active,
|
|
@@ -15,4 +14,4 @@ export const TableThAction = forwardRef((props, ref) => {
|
|
|
15
14
|
className: restProps.className,
|
|
16
15
|
style: restProps.style,
|
|
17
16
|
}), { ref: ref, role: (_a = restProps['role']) !== null && _a !== void 0 ? _a : 'button', tabIndex: (_b = restProps['tabIndex']) !== null && _b !== void 0 ? _b : (disabled ? -1 : 0), children: children })));
|
|
18
|
-
}
|
|
17
|
+
}
|