@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/image/ImagePreview.d.ts
CHANGED
package/image/ImagePreview.js
CHANGED
|
@@ -15,10 +15,10 @@ import { Button } from '../button';
|
|
|
15
15
|
import { useComponentProps, useControlled, useLockScroll, useMaxIndex, useNamespace, useStyled } from '../hooks';
|
|
16
16
|
import { Icon } from '../icon';
|
|
17
17
|
import { Input } from '../input';
|
|
18
|
-
import { Mask } from '../internal/mask';
|
|
19
18
|
import { Portal } from '../internal/portal';
|
|
20
|
-
import {
|
|
19
|
+
import { Mask } from '../mask';
|
|
21
20
|
import { ROOT_DATA } from '../root/vars';
|
|
21
|
+
import { Transition } from '../transition';
|
|
22
22
|
import { mergeCS } from '../utils';
|
|
23
23
|
import { TTANSITION_DURING_BASE } from '../vars';
|
|
24
24
|
export function ImagePreview(props) {
|
|
@@ -166,122 +166,107 @@ export function ImagePreview(props) {
|
|
|
166
166
|
document.body.appendChild(el);
|
|
167
167
|
}
|
|
168
168
|
return el;
|
|
169
|
-
}, children: _jsx(Transition, { enter: visible,
|
|
169
|
+
}, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup`, duration: TTANSITION_DURING_BASE, onAfterEnter: () => {
|
|
170
170
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
171
171
|
dataRef.current.prevActiveEl = document.activeElement;
|
|
172
172
|
if (previewRef.current) {
|
|
173
173
|
previewRef.current.focus({ preventScroll: true });
|
|
174
174
|
}
|
|
175
|
-
},
|
|
175
|
+
}, onAfterLeave: () => {
|
|
176
176
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
177
177
|
if (dataRef.current.prevActiveEl) {
|
|
178
178
|
dataRef.current.prevActiveEl.focus({ preventScroll: true });
|
|
179
179
|
}
|
|
180
|
-
}, children: (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}, true);
|
|
232
|
-
} }) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-zoom-in'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(ZoomInOutlined, {}) }), onClick: () => {
|
|
233
|
-
setTransform((transform) => {
|
|
234
|
-
transform.scale = transform.scale * 1.3;
|
|
235
|
-
}, true);
|
|
236
|
-
} }) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-close'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(CloseOutlined, {}) }), onClick: () => {
|
|
237
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
238
|
-
} }) }))] })), list.map((img, index) => (_jsx("div", Object.assign({}, mergeCS(styled('image-preview__img-wrapper'), {
|
|
239
|
-
style: {
|
|
240
|
-
display: index === active ? undefined : 'none',
|
|
241
|
-
},
|
|
242
|
-
}), { children: _jsx("img", Object.assign({}, img, styled('image-preview__img'), { tabIndex: -1, "data-index": index, onMouseDown: (e) => {
|
|
243
|
-
if (e.button === 0) {
|
|
244
|
-
e.preventDefault();
|
|
245
|
-
e.currentTarget.focus({ preventScroll: true });
|
|
246
|
-
dataRef.current.eventData = {};
|
|
247
|
-
setIsDragging(true);
|
|
248
|
-
}
|
|
249
|
-
}, onMouseUp: (e) => {
|
|
250
|
-
if (e.button === 0) {
|
|
251
|
-
e.preventDefault();
|
|
252
|
-
}
|
|
253
|
-
}, onTouchStart: (e) => {
|
|
254
|
-
var _a, _b;
|
|
180
|
+
}, children: (transitionRef, leaved) => leaved ? null : (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('image-preview'), {
|
|
181
|
+
className: restProps.className,
|
|
182
|
+
style: Object.assign(Object.assign(Object.assign({}, restProps.style), { '--popup-scale': 0.3, '--popup-duration': TTANSITION_DURING_BASE + 'ms' }), { zIndex }),
|
|
183
|
+
}), { ref: (instance) => {
|
|
184
|
+
previewRef.current = instance;
|
|
185
|
+
transitionRef(instance);
|
|
186
|
+
return () => {
|
|
187
|
+
previewRef.current = null;
|
|
188
|
+
transitionRef(null);
|
|
189
|
+
};
|
|
190
|
+
}, tabIndex: -1, onKeyDown: (e) => {
|
|
191
|
+
var _a;
|
|
192
|
+
(_a = restProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
193
|
+
if (visible && escClosable && e.code === 'Escape') {
|
|
194
|
+
e.stopPropagation();
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
197
|
+
}
|
|
198
|
+
}, children: [_jsx("button", Object.assign({}, styled('image-preview__navigation-button', 'image-preview__navigation-button--prev'), { onClick: () => {
|
|
199
|
+
changeActive((prevActive) => {
|
|
200
|
+
return prevActive === 0 ? list.length - 1 : prevActive - 1;
|
|
201
|
+
});
|
|
202
|
+
}, children: _jsx(Icon, { children: _jsx(KeyboardArrowLeftOutlined, {}) }) })), _jsx("button", Object.assign({}, styled('image-preview__navigation-button', 'image-preview__navigation-button--next'), { onClick: () => {
|
|
203
|
+
changeActive((prevActive) => {
|
|
204
|
+
return prevActive === list.length - 1 ? 0 : prevActive + 1;
|
|
205
|
+
});
|
|
206
|
+
}, children: _jsx(Icon, { children: _jsx(KeyboardArrowRightOutlined, {}) }) })), _jsxs("ul", Object.assign({}, styled('image-preview__toolbar'), { children: [_jsxs("li", Object.assign({}, styled('image-preview__toolbar-page'), { children: [_jsx(Input.Number, Object.assign({}, styled('image-preview__toolbar-page-input'), { model: active + 1, min: 1, max: list.length, integer: true, onModelChange: (val) => {
|
|
207
|
+
if (!isNull(val)) {
|
|
208
|
+
changeActive(val - 1);
|
|
209
|
+
}
|
|
210
|
+
} })), _jsx("span", { children: "/" }), _jsx("span", { children: list.length })] })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-rotate'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(Rotate90DegreesCwOutlined, {}) }), onClick: () => {
|
|
211
|
+
setTransform((transform) => {
|
|
212
|
+
transform.rotate = transform.rotate + 90;
|
|
213
|
+
});
|
|
214
|
+
} }) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-zoom-out'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(ZoomOutOutlined, {}) }), onClick: () => {
|
|
215
|
+
setTransform((transform) => {
|
|
216
|
+
transform.scale = Math.max(transform.scale / 1.3, 1);
|
|
217
|
+
}, true);
|
|
218
|
+
} }) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-zoom-in'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(ZoomInOutlined, {}) }), onClick: () => {
|
|
219
|
+
setTransform((transform) => {
|
|
220
|
+
transform.scale = transform.scale * 1.3;
|
|
221
|
+
}, true);
|
|
222
|
+
} }) })), _jsx("li", Object.assign({}, styled('image-preview__toolbar-close'), { children: _jsx(Button, { pattern: "text", icon: _jsx(Icon, { children: _jsx(CloseOutlined, {}) }), onClick: () => {
|
|
223
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
224
|
+
} }) }))] })), list.map((img, index) => (_jsx("div", Object.assign({}, mergeCS(styled('image-preview__img-wrapper'), {
|
|
225
|
+
style: {
|
|
226
|
+
display: index === active ? undefined : 'none',
|
|
227
|
+
},
|
|
228
|
+
}), { children: _jsx("img", Object.assign({}, img, styled('image-preview__img'), { tabIndex: -1, "data-index": index, onMouseDown: (e) => {
|
|
229
|
+
if (e.button === 0) {
|
|
230
|
+
e.preventDefault();
|
|
255
231
|
e.currentTarget.focus({ preventScroll: true });
|
|
256
232
|
dataRef.current.eventData = {};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
233
|
+
setIsDragging(true);
|
|
234
|
+
}
|
|
235
|
+
}, onMouseUp: (e) => {
|
|
236
|
+
if (e.button === 0) {
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
}
|
|
239
|
+
}, onTouchStart: (e) => {
|
|
240
|
+
var _a, _b;
|
|
241
|
+
e.currentTarget.focus({ preventScroll: true });
|
|
242
|
+
dataRef.current.eventData = {};
|
|
243
|
+
if (e.touches.length === 1) {
|
|
244
|
+
setIsDragging(true);
|
|
245
|
+
}
|
|
246
|
+
else if (e.touches.length === 2) {
|
|
247
|
+
dataRef.current.initialScale = (_b = (_a = dataRef.current.transform.get(active)) === null || _a === void 0 ? void 0 : _a.scale) !== null && _b !== void 0 ? _b : 1;
|
|
248
|
+
dataRef.current.mouse = {
|
|
249
|
+
x: Math.min(e.touches[0].clientX, e.touches[1].clientX) + Math.abs(e.touches[0].clientX - e.touches[1].clientX),
|
|
250
|
+
y: Math.min(e.touches[0].clientY, e.touches[1].clientY) + Math.abs(e.touches[0].clientY - e.touches[1].clientY),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}, onTouchEnd: (e) => {
|
|
254
|
+
if (e.touches.length === 1) {
|
|
255
|
+
dataRef.current.eventData.initialTouches = dataRef.current.eventData.currentTouches = undefined;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
setIsDragging(false);
|
|
259
|
+
}
|
|
260
|
+
}, onWheel: (e) => {
|
|
261
|
+
setTransform((transform) => {
|
|
262
|
+
transform.scale =
|
|
263
|
+
e.deltaY < 0 ? transform.scale + transform.scale * 0.1 : Math.max(transform.scale - transform.scale * 0.1, 1);
|
|
264
|
+
});
|
|
265
|
+
} })) }), index))), _jsx("ul", Object.assign({}, styled('image-preview__thumbnail-list'), { children: list.map((imgProps, index) => index >= startIndex &&
|
|
266
|
+
index <= endIndex && (_createElement("li", Object.assign({}, styled('image-preview__thumbnail', {
|
|
267
|
+
'image-preview__thumbnail.is-active': active === index,
|
|
268
|
+
}), { key: index, onClick: () => {
|
|
269
|
+
changeActive(index);
|
|
270
|
+
} }),
|
|
271
|
+
_jsx("img", Object.assign({}, imgProps, styled('image-preview__thumbnail-img')))))) })), _jsx(Mask, { visible: true })] }))) }) }));
|
|
287
272
|
}
|
package/image/types.d.ts
CHANGED
|
@@ -6,14 +6,18 @@ export interface ImageProps extends BaseProps<'image', typeof CLASSES>, Omit<Rea
|
|
|
6
6
|
imgProps: React.ImgHTMLAttributes<HTMLImageElement>;
|
|
7
7
|
loading?: React.ReactNode;
|
|
8
8
|
error?: React.ReactNode;
|
|
9
|
-
actions?: React.
|
|
9
|
+
actions?: (React.ReactNode | {
|
|
10
|
+
id: React.Key;
|
|
11
|
+
action: React.ReactNode;
|
|
12
|
+
})[];
|
|
10
13
|
}
|
|
11
14
|
export interface ImageLoaderProps<K extends keyof HTMLImageElement = 'naturalWidth' | 'naturalHeight'> {
|
|
12
15
|
src: string;
|
|
13
16
|
keys?: K[];
|
|
14
|
-
children: (img: Pick<HTMLImageElement, K>) =>
|
|
17
|
+
children: (img: Pick<HTMLImageElement, K>) => React.ReactElement | null;
|
|
15
18
|
}
|
|
16
19
|
export interface ImageActionProps extends BaseProps<'image', typeof CLASSES>, React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
20
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
17
21
|
}
|
|
18
22
|
export interface ImagePreviewProps extends BaseProps<'image-preview', typeof PREVIEW_CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
19
23
|
list: React.ImgHTMLAttributes<HTMLImageElement>[];
|
package/input/Input.d.ts
CHANGED
package/input/Input.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { checkNodeExist } from '@laser-ui/utils';
|
|
3
|
+
import { checkNodeExist, setRef } from '@laser-ui/utils';
|
|
5
4
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
6
5
|
import VisibilityOutlined from '@material-design-icons/svg/outlined/visibility.svg?react';
|
|
7
6
|
import VisibilityOffOutlined from '@material-design-icons/svg/outlined/visibility_off.svg?react';
|
|
@@ -13,11 +12,10 @@ import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled,
|
|
|
13
12
|
import { Icon } from '../icon';
|
|
14
13
|
import { mergeCS } from '../utils';
|
|
15
14
|
export const Input = (props) => {
|
|
16
|
-
const _a = useComponentProps('Input', props), { styleOverrides, styleProvider, formControl, model, defaultModel, type, prefix, suffix, password: passwordProp, defaultPassword, clearable, placeholder, size: sizeProp, disabled: disabledProp = false,
|
|
15
|
+
const _a = useComponentProps('Input', props), { styleOverrides, styleProvider, formControl, model, defaultModel, type, prefix, suffix, password: passwordProp, defaultPassword, clearable, placeholder, size: sizeProp, disabled: disabledProp = false, inputProps, onModelChange, onClear, onPasswordChange } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "type", "prefix", "suffix", "password", "defaultPassword", "clearable", "placeholder", "size", "disabled", "inputProps", "onModelChange", "onClear", "onPasswordChange"]);
|
|
17
16
|
const styled = useStyled(CLASSES, { input: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.input }, styleOverrides);
|
|
18
17
|
const { t } = useTranslation();
|
|
19
18
|
const inputRef = useRef(null);
|
|
20
|
-
const combineInputRef = useForkRef(inputRef, inputRefProp);
|
|
21
19
|
const [value, changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : '', model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
22
20
|
const [password, changePassword] = useControlled(defaultPassword !== null && defaultPassword !== void 0 ? defaultPassword : true, passwordProp, onPasswordChange);
|
|
23
21
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
@@ -27,9 +25,6 @@ export const Input = (props) => {
|
|
|
27
25
|
}
|
|
28
26
|
};
|
|
29
27
|
const designProps = useDesign({ compose: { disabled }, form: formControl });
|
|
30
|
-
const inputNode = (_jsx(BaseInput, Object.assign({}, styled('input__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: combineInputRef, value: value, type: type === 'password' ? (password ? 'password' : 'text') : type, placeholder: placeholder, disabled: disabled, onValueChange: (val) => {
|
|
31
|
-
changeValue(val);
|
|
32
|
-
} })));
|
|
33
28
|
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('input', `input--${size}`, {
|
|
34
29
|
'input.is-disabled': disabled,
|
|
35
30
|
}), {
|
|
@@ -47,7 +42,16 @@ export const Input = (props) => {
|
|
|
47
42
|
var _a, _b;
|
|
48
43
|
(_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
49
44
|
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
|
|
50
|
-
}, children: [checkNodeExist(prefix) && _jsx("div", Object.assign({}, styled('input__prefix'), { children: prefix })),
|
|
45
|
+
}, children: [checkNodeExist(prefix) && _jsx("div", Object.assign({}, styled('input__prefix'), { children: prefix })), _jsx(BaseInput, Object.assign({}, inputProps, styled('input__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: (instance) => {
|
|
46
|
+
inputRef.current = instance;
|
|
47
|
+
const ret = setRef(inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref, instance);
|
|
48
|
+
return () => {
|
|
49
|
+
inputRef.current = null;
|
|
50
|
+
ret();
|
|
51
|
+
};
|
|
52
|
+
}, value: value, type: type === 'password' ? (password ? 'password' : 'text') : type, placeholder: placeholder, disabled: disabled, onValueChange: (val) => {
|
|
53
|
+
changeValue(val);
|
|
54
|
+
} })), clearable && !disabled && (_jsx("div", Object.assign({}, mergeCS(styled('input__clear'), { style: { opacity: value.length > 0 ? 1 : 0 } }), { role: "button", "aria-label": t('Clear'), onClick: () => {
|
|
51
55
|
changeValue('');
|
|
52
56
|
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
53
57
|
}, children: _jsx(Icon, { children: _jsx(CancelFilled, {}) }) }))), type === 'password' && !disabled && (_jsx("div", Object.assign({}, styled('input__password'), { role: "button", "aria-label": t('Input', password ? 'Password is not visible' : 'Password is visible'), onClick: () => {
|
package/input/InputNumber.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useAsync, useEvent, useForceUpdate,
|
|
4
|
-
import { checkNodeExist } from '@laser-ui/utils';
|
|
3
|
+
import { useAsync, useEvent, useForceUpdate, useRefExtra } from '@laser-ui/hooks';
|
|
4
|
+
import { checkNodeExist, setRef } from '@laser-ui/utils';
|
|
5
5
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
6
6
|
import KeyboardArrowDownOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_down.svg?react';
|
|
7
7
|
import KeyboardArrowUpOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_up.svg?react';
|
|
@@ -13,7 +13,7 @@ import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled,
|
|
|
13
13
|
import { Icon } from '../icon';
|
|
14
14
|
import { mergeCS } from '../utils';
|
|
15
15
|
export function InputNumber(props) {
|
|
16
|
-
const _a = useComponentProps('InputNumber', props), { styleOverrides, styleProvider, formControl, model, defaultModel, max, min, step = 1, integer = false, prefix, suffix, clearable, placeholder, size: sizeProp, numberButton = true, disabled: disabledProp = false,
|
|
16
|
+
const _a = useComponentProps('InputNumber', props), { styleOverrides, styleProvider, formControl, model, defaultModel, max, min, step = 1, integer = false, prefix, suffix, clearable, placeholder, size: sizeProp, numberButton = true, disabled: disabledProp = false, inputProps, onModelChange, onClear } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "max", "min", "step", "integer", "prefix", "suffix", "clearable", "placeholder", "size", "numberButton", "disabled", "inputProps", "onModelChange", "onClear"]);
|
|
17
17
|
const styled = useStyled(CLASSES, { input: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.input }, styleOverrides);
|
|
18
18
|
const async = useAsync();
|
|
19
19
|
const { t } = useTranslation();
|
|
@@ -21,9 +21,8 @@ export function InputNumber(props) {
|
|
|
21
21
|
const dataRef = useRef({
|
|
22
22
|
inputFocused: false,
|
|
23
23
|
});
|
|
24
|
-
const inputRef = useRef(null);
|
|
25
|
-
const combineInputRef = useForkRef(inputRef, inputRefProp);
|
|
26
24
|
const windowRef = useRefExtra(() => window);
|
|
25
|
+
const inputRef = useRef(null);
|
|
27
26
|
const [value, _changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : null, model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
28
27
|
const inputValue = dataRef.current.inputFocused && !isUndefined(dataRef.current.inputValue)
|
|
29
28
|
? dataRef.current.inputValue
|
|
@@ -69,40 +68,6 @@ export function InputNumber(props) {
|
|
|
69
68
|
}
|
|
70
69
|
};
|
|
71
70
|
const designProps = useDesign({ compose: { disabled }, form: formControl });
|
|
72
|
-
const inputNode = (_jsx(BaseInput, Object.assign({}, styled('input__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: combineInputRef, value: inputValue, max: max, min: min, step: step, type: "number", placeholder: placeholder, disabled: disabled, onValueChange: (val) => {
|
|
73
|
-
forceUpdate();
|
|
74
|
-
dataRef.current.inputValue = val;
|
|
75
|
-
if (val.length === 0) {
|
|
76
|
-
changeValue(null);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
const num = Number(val);
|
|
80
|
-
if ((isUndefined(max) || num <= max) && (isUndefined(min) || num >= min) && (!integer || Number.isInteger(num))) {
|
|
81
|
-
changeValue(num);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}, onFocus: () => {
|
|
85
|
-
dataRef.current.inputFocused = true;
|
|
86
|
-
dataRef.current.inputValue = undefined;
|
|
87
|
-
}, onBlur: () => {
|
|
88
|
-
dataRef.current.inputFocused = false;
|
|
89
|
-
if (inputValue.length === 0) {
|
|
90
|
-
changeValue(null);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
let num = Number(inputValue);
|
|
94
|
-
if (!isUndefined(max) && num > max) {
|
|
95
|
-
num = max;
|
|
96
|
-
}
|
|
97
|
-
if (!isUndefined(min) && num < min) {
|
|
98
|
-
num = min;
|
|
99
|
-
}
|
|
100
|
-
if (integer && !Number.isInteger(num)) {
|
|
101
|
-
num = Math.round(num);
|
|
102
|
-
}
|
|
103
|
-
changeValue(num);
|
|
104
|
-
}
|
|
105
|
-
} })));
|
|
106
71
|
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('input', `input--${size}`, {
|
|
107
72
|
'input.is-disabled': disabled,
|
|
108
73
|
}), {
|
|
@@ -120,7 +85,51 @@ export function InputNumber(props) {
|
|
|
120
85
|
var _a, _b;
|
|
121
86
|
(_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
122
87
|
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
|
|
123
|
-
}, children: [checkNodeExist(prefix) && _jsx("div", Object.assign({}, styled('input__prefix'), { children: prefix })),
|
|
88
|
+
}, children: [checkNodeExist(prefix) && _jsx("div", Object.assign({}, styled('input__prefix'), { children: prefix })), _jsx(BaseInput, Object.assign({}, inputProps, styled('input__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: (instance) => {
|
|
89
|
+
inputRef.current = instance;
|
|
90
|
+
const ret = setRef(inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref, instance);
|
|
91
|
+
return () => {
|
|
92
|
+
inputRef.current = null;
|
|
93
|
+
ret();
|
|
94
|
+
};
|
|
95
|
+
}, value: inputValue, max: max, min: min, step: step, type: "number", placeholder: placeholder, disabled: disabled, onValueChange: (val) => {
|
|
96
|
+
forceUpdate();
|
|
97
|
+
dataRef.current.inputValue = val;
|
|
98
|
+
if (val.length === 0) {
|
|
99
|
+
changeValue(null);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const num = Number(val);
|
|
103
|
+
if ((isUndefined(max) || num <= max) && (isUndefined(min) || num >= min) && (!integer || Number.isInteger(num))) {
|
|
104
|
+
changeValue(num);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}, onFocus: (e) => {
|
|
108
|
+
var _a;
|
|
109
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
110
|
+
dataRef.current.inputFocused = true;
|
|
111
|
+
dataRef.current.inputValue = undefined;
|
|
112
|
+
}, onBlur: (e) => {
|
|
113
|
+
var _a;
|
|
114
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
115
|
+
dataRef.current.inputFocused = false;
|
|
116
|
+
if (inputValue.length === 0) {
|
|
117
|
+
changeValue(null);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
let num = Number(inputValue);
|
|
121
|
+
if (!isUndefined(max) && num > max) {
|
|
122
|
+
num = max;
|
|
123
|
+
}
|
|
124
|
+
if (!isUndefined(min) && num < min) {
|
|
125
|
+
num = min;
|
|
126
|
+
}
|
|
127
|
+
if (integer && !Number.isInteger(num)) {
|
|
128
|
+
num = Math.round(num);
|
|
129
|
+
}
|
|
130
|
+
changeValue(num);
|
|
131
|
+
}
|
|
132
|
+
} })), clearable && !disabled && (_jsx("div", Object.assign({}, mergeCS(styled('input__clear'), { style: { opacity: inputValue.length > 0 ? 1 : 0 } }), { role: "button", "aria-label": t('Clear'), onClick: () => {
|
|
124
133
|
changeValue(null);
|
|
125
134
|
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
126
135
|
}, children: _jsx(Icon, { children: _jsx(CancelFilled, {}) }) }))), numberButton && !disabled && (_jsxs("div", Object.assign({}, styled('input__number-container'), { children: [_jsx("div", Object.assign({}, styled('input__number'), { role: "button", "aria-label": t('Input', 'Increase number'), onMouseDown: (e) => {
|
package/input/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 InputProps extends BaseProps<'input', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'prefix'> {
|
|
7
7
|
formControl?: FormControlProvider;
|
|
@@ -16,8 +16,7 @@ export interface InputProps extends BaseProps<'input', typeof CLASSES>, Omit<Rea
|
|
|
16
16
|
placeholder?: string;
|
|
17
17
|
size?: Size;
|
|
18
18
|
disabled?: boolean;
|
|
19
|
-
|
|
20
|
-
inputRender?: CloneHTMLElement;
|
|
19
|
+
inputProps?: React.ComponentPropsWithRef<'input'>;
|
|
21
20
|
onModelChange?: (value: string) => void;
|
|
22
21
|
onClear?: () => void;
|
|
23
22
|
onPasswordChange?: (value: boolean) => void;
|
|
@@ -37,8 +36,7 @@ export interface InputNumberProps extends BaseProps<'input', typeof CLASSES>, Om
|
|
|
37
36
|
size?: Size;
|
|
38
37
|
numberButton?: boolean;
|
|
39
38
|
disabled?: boolean;
|
|
40
|
-
|
|
41
|
-
inputRender?: CloneHTMLElement;
|
|
39
|
+
inputProps?: React.ComponentPropsWithRef<'input'>;
|
|
42
40
|
onModelChange?: (value: number | null) => void;
|
|
43
41
|
onClear?: () => void;
|
|
44
42
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
export function LazyLoading(props) {
|
|
3
|
+
const { children, hidden, disabled = false } = props;
|
|
4
|
+
const loaded = useRef(disabled ? true : !hidden);
|
|
5
|
+
if (!hidden) {
|
|
6
|
+
loaded.current = true;
|
|
7
|
+
}
|
|
8
|
+
return loaded.current ? children : null;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LazyLoading } from './LazyLoading';
|