@canlooks/can-ui 0.0.63 → 0.0.65

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.
@@ -38,6 +38,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, cont
38
38
  const unmounted = (0, utils_1.useUnmounted)();
39
39
  const openHolding = (0, react_1.useRef)(0);
40
40
  const hold = (open) => {
41
+ console.log('hold', open);
41
42
  return open ? ++openHolding.current
42
43
  : openHolding.current > 0 ? --openHolding.current
43
44
  : openHolding.current;
@@ -7,7 +7,7 @@ const dropArea_style_1 = require("./dropArea.style");
7
7
  const utils_1 = require("../../utils");
8
8
  const __1 = require("../..");
9
9
  const faInbox_1 = require("@fortawesome/free-solid-svg-icons/faInbox");
10
- exports.DropArea = (0, react_1.memo)(({ description = '将文件拖拽到这里', onDrop, ...props }) => {
10
+ exports.DropArea = (0, react_1.memo)(({ description = '点击选择文件,或将文件拖拽到这里', onDrop, ...props }) => {
11
11
  const [draggingOver, setDraggingOver] = (0, react_1.useState)(false);
12
12
  (0, react_1.useEffect)(() => {
13
13
  const fn = (e) => e.preventDefault();
@@ -7,7 +7,7 @@ exports.classes = (0, utils_1.defineInnerClasses)('upload-drop-area', [
7
7
  'icon',
8
8
  'description'
9
9
  ]);
10
- exports.style = (0, utils_1.defineCss)(({ spacing, gray, divider, borderRadius, text, colors }) => (0, react_1.css) `
10
+ exports.style = (0, utils_1.defineCss)(({ spacing, gray, divider, borderRadius, text, colors, easing }) => (0, react_1.css) `
11
11
  height: 100px;
12
12
  display: flex;
13
13
  gap: ${spacing[1]}px;
@@ -15,10 +15,21 @@ exports.style = (0, utils_1.defineCss)(({ spacing, gray, divider, borderRadius,
15
15
  align-items: center;
16
16
  justify-content: center;
17
17
  border: 1px dashed ${divider};
18
- background-color: ${gray(.1)};
19
18
  border-radius: ${borderRadius}px;
20
19
  color: ${text.disabled};
20
+ cursor: pointer;
21
+ background-color: ${gray(.1)};
22
+ transition: background-color .25s ${easing.easeOut};
21
23
 
24
+ &:hover {
25
+ background-color: ${gray(.15)};
26
+ }
27
+
28
+ &:active {
29
+ background-color: ${gray(.08)};
30
+ transition: background-color 0s;
31
+ }
32
+
22
33
  .${exports.classes.icon}, .${exports.classes.description} {
23
34
  pointer-events: none;
24
35
  }
@@ -96,8 +96,10 @@ exports.Upload = (0, react_1.memo)(({ inputProps, type = 'file', accept = type =
96
96
  newValue && setInnerValue(newValue);
97
97
  };
98
98
  return ((0, jsx_runtime_1.jsxs)("div", { ...props, ref: wrapperRef, css: upload_style_1.style, className: (0, utils_1.clsx)(upload_style_1.classes.root, props.className), "data-file-type": type, "data-variant": variant, "data-sortable": sortable, children: [(0, jsx_runtime_1.jsx)("input", { type: "file", accept: accept, multiple: max !== 1, ...inputProps, ref: (0, utils_1.cloneRef)(innerInputRef, inputProps?.ref), className: (0, utils_1.clsx)(upload_style_1.classes.input, inputProps?.className), onChange: inputChangeHandler, "data-hidden": "true" }), (0, jsx_runtime_1.jsx)(core_1.DndContext, { sensors: (0, utils_1.useDndSensors)(), onDragEnd: dragEndHandler, children: (0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: innerValue.current, disabled: !sortable, children: type === 'file'
99
- ? (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showButton &&
100
- (0, jsx_runtime_1.jsx)(button_1.Button, { variant: "outlined", prefix: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: faUpload_1.faUpload }), ...buttonProps, onClick: buttonClick, children: buttonText }), (0, jsx_runtime_1.jsx)(react_transition_group_1.TransitionGroup, { className: upload_style_1.classes.files, children: innerValue.current.map(file => (0, jsx_runtime_1.jsx)(sortableItem_1.SortableItem, { component: transitionBase_1.Collapse, className: upload_style_1.classes.sortable, id: file.id, children: (0, jsx_runtime_1.jsx)(fileItem_1.FileItem, { ref: r => {
99
+ ? (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [droppable
100
+ ? (0, jsx_runtime_1.jsx)(dropArea_1.DropArea, { onClick: () => innerInputRef.current.click(), onDrop: changeFn })
101
+ : showButton &&
102
+ (0, jsx_runtime_1.jsx)(button_1.Button, { variant: "outlined", prefix: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: faUpload_1.faUpload }), ...buttonProps, onClick: buttonClick, children: buttonText }), (0, jsx_runtime_1.jsx)(react_transition_group_1.TransitionGroup, { className: upload_style_1.classes.files, children: innerValue.current.map(file => (0, jsx_runtime_1.jsx)(sortableItem_1.SortableItem, { component: transitionBase_1.Collapse, className: upload_style_1.classes.sortable, id: file.id, children: (0, jsx_runtime_1.jsx)(fileItem_1.FileItem, { ref: r => {
101
103
  r
102
104
  ? itemRefs.current.set(file.id, r)
103
105
  : itemRefs.current.delete(file.id);
@@ -35,6 +35,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
35
35
  const unmounted = useUnmounted();
36
36
  const openHolding = useRef(0);
37
37
  const hold = (open) => {
38
+ console.log('hold', open);
38
39
  return open ? ++openHolding.current
39
40
  : openHolding.current > 0 ? --openHolding.current
40
41
  : openHolding.current;
@@ -4,7 +4,7 @@ import { classes, style } from './dropArea.style';
4
4
  import { clsx } from '../../utils';
5
5
  import { Icon } from '../..';
6
6
  import { faInbox } from '@fortawesome/free-solid-svg-icons/faInbox';
7
- export const DropArea = memo(({ description = '将文件拖拽到这里', onDrop, ...props }) => {
7
+ export const DropArea = memo(({ description = '点击选择文件,或将文件拖拽到这里', onDrop, ...props }) => {
8
8
  const [draggingOver, setDraggingOver] = useState(false);
9
9
  useEffect(() => {
10
10
  const fn = (e) => e.preventDefault();
@@ -4,7 +4,7 @@ export const classes = defineInnerClasses('upload-drop-area', [
4
4
  'icon',
5
5
  'description'
6
6
  ]);
7
- export const style = defineCss(({ spacing, gray, divider, borderRadius, text, colors }) => css `
7
+ export const style = defineCss(({ spacing, gray, divider, borderRadius, text, colors, easing }) => css `
8
8
  height: 100px;
9
9
  display: flex;
10
10
  gap: ${spacing[1]}px;
@@ -12,10 +12,21 @@ export const style = defineCss(({ spacing, gray, divider, borderRadius, text, co
12
12
  align-items: center;
13
13
  justify-content: center;
14
14
  border: 1px dashed ${divider};
15
- background-color: ${gray(.1)};
16
15
  border-radius: ${borderRadius}px;
17
16
  color: ${text.disabled};
17
+ cursor: pointer;
18
+ background-color: ${gray(.1)};
19
+ transition: background-color .25s ${easing.easeOut};
18
20
 
21
+ &:hover {
22
+ background-color: ${gray(.15)};
23
+ }
24
+
25
+ &:active {
26
+ background-color: ${gray(.08)};
27
+ transition: background-color 0s;
28
+ }
29
+
19
30
  .${classes.icon}, .${classes.description} {
20
31
  pointer-events: none;
21
32
  }
@@ -93,8 +93,10 @@ export const Upload = memo(({ inputProps, type = 'file', accept = type === 'imag
93
93
  newValue && setInnerValue(newValue);
94
94
  };
95
95
  return (_jsxs("div", { ...props, ref: wrapperRef, css: style, className: clsx(classes.root, props.className), "data-file-type": type, "data-variant": variant, "data-sortable": sortable, children: [_jsx("input", { type: "file", accept: accept, multiple: max !== 1, ...inputProps, ref: cloneRef(innerInputRef, inputProps?.ref), className: clsx(classes.input, inputProps?.className), onChange: inputChangeHandler, "data-hidden": "true" }), _jsx(DndContext, { sensors: useDndSensors(), onDragEnd: dragEndHandler, children: _jsx(SortableContext, { items: innerValue.current, disabled: !sortable, children: type === 'file'
96
- ? _jsxs(_Fragment, { children: [showButton &&
97
- _jsx(Button, { variant: "outlined", prefix: _jsx(Icon, { icon: faUpload }), ...buttonProps, onClick: buttonClick, children: buttonText }), _jsx(TransitionGroup, { className: classes.files, children: innerValue.current.map(file => _jsx(SortableItem, { component: Collapse, className: classes.sortable, id: file.id, children: _jsx(FileItem, { ref: r => {
96
+ ? _jsxs(_Fragment, { children: [droppable
97
+ ? _jsx(DropArea, { onClick: () => innerInputRef.current.click(), onDrop: changeFn })
98
+ : showButton &&
99
+ _jsx(Button, { variant: "outlined", prefix: _jsx(Icon, { icon: faUpload }), ...buttonProps, onClick: buttonClick, children: buttonText }), _jsx(TransitionGroup, { className: classes.files, children: innerValue.current.map(file => _jsx(SortableItem, { component: Collapse, className: classes.sortable, id: file.id, children: _jsx(FileItem, { ref: r => {
98
100
  r
99
101
  ? itemRefs.current.set(file.id, r)
100
102
  : itemRefs.current.delete(file.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",