@ioca/react 1.5.11 → 1.5.12

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.
Files changed (33) hide show
  1. package/lib/cjs/components/editor/editor.js +5 -0
  2. package/lib/cjs/components/editor/editor.js.map +1 -1
  3. package/lib/cjs/components/editor/memtion.js +45 -3
  4. package/lib/cjs/components/editor/memtion.js.map +1 -1
  5. package/lib/cjs/components/list/list.js +3 -3
  6. package/lib/cjs/components/list/list.js.map +1 -1
  7. package/lib/cjs/components/picker/colors/index.js +7 -3
  8. package/lib/cjs/components/picker/colors/index.js.map +1 -1
  9. package/lib/cjs/components/tabs/navs.js.map +1 -1
  10. package/lib/cjs/components/tabs/tabs.js.map +1 -1
  11. package/lib/cjs/components/upload/upload.js +8 -2
  12. package/lib/cjs/components/upload/upload.js.map +1 -1
  13. package/lib/css/index.css +1 -1
  14. package/lib/css/index.css.map +1 -1
  15. package/lib/es/components/editor/editor.js +5 -0
  16. package/lib/es/components/editor/editor.js.map +1 -1
  17. package/lib/es/components/editor/memtion.js +46 -4
  18. package/lib/es/components/editor/memtion.js.map +1 -1
  19. package/lib/es/components/list/list.js +4 -4
  20. package/lib/es/components/list/list.js.map +1 -1
  21. package/lib/es/components/picker/colors/index.js +6 -3
  22. package/lib/es/components/picker/colors/index.js.map +1 -1
  23. package/lib/es/components/tabs/navs.js.map +1 -1
  24. package/lib/es/components/tabs/tabs.js.map +1 -1
  25. package/lib/es/components/upload/upload.js +8 -2
  26. package/lib/es/components/upload/upload.js.map +1 -1
  27. package/lib/index.js +64 -11
  28. package/lib/types/components/list/item.d.ts +6 -0
  29. package/lib/types/components/list/list.d.ts +3 -5
  30. package/lib/types/components/picker/type.d.ts +4 -1
  31. package/lib/types/components/tabs/type.d.ts +1 -1
  32. package/lib/types/components/upload/type.d.ts +1 -0
  33. package/package.json +97 -97
package/lib/index.js CHANGED
@@ -1752,9 +1752,9 @@ const Item$4 = (props) => {
1752
1752
  }), style: { alignItems: align, ...style }, ...restProps, children: [label !== undefined && (jsx("span", { className: 'i-list-item-label', children: label })), children] }));
1753
1753
  };
1754
1754
 
1755
- const List$1 = (props) => {
1755
+ const List$1 = forwardRef((props, ref) => {
1756
1756
  const { label, type, border, className, children, ...restProps } = props;
1757
- return (jsx("ul", { className: classNames("i-list", className), ...restProps, children: Children.map(children, (node, i) => {
1757
+ return (jsx("ul", { ref: ref, className: classNames("i-list", className), ...restProps, children: Children.map(children, (node, i) => {
1758
1758
  const renderLabel = typeof label === "function" ? label(i) : label;
1759
1759
  const { type, props: nodeProps } = node;
1760
1760
  if (type === Item$4) {
@@ -1767,7 +1767,7 @@ const List$1 = (props) => {
1767
1767
  }
1768
1768
  return node;
1769
1769
  }) }));
1770
- };
1770
+ });
1771
1771
  List$1.Item = Item$4;
1772
1772
 
1773
1773
  const Content$2 = forwardRef((props, ref) => {
@@ -2605,15 +2605,56 @@ const removeAdjacentMemtionTag = (editor, key) => {
2605
2605
  editor.focus();
2606
2606
  return true;
2607
2607
  };
2608
+ const makeRectSource = (rect) => {
2609
+ const { left, top, width, height } = rect;
2610
+ return {
2611
+ offsetParent: null,
2612
+ offsetLeft: left,
2613
+ offsetTop: top,
2614
+ getBoundingClientRect: () => ({
2615
+ left,
2616
+ top,
2617
+ right: left + width,
2618
+ bottom: top + height,
2619
+ width,
2620
+ height,
2621
+ x: left,
2622
+ y: top,
2623
+ toJSON: () => ({}),
2624
+ }),
2625
+ };
2626
+ };
2608
2627
  const Memtion = (props) => {
2609
2628
  const { visible, rect, options, activeIndex, onActiveChange, onSelect } = props;
2629
+ const containerRef = useRef(null);
2630
+ const [pos, setPos] = useState({ left: 0, top: 0 });
2631
+ const [ready, setReady] = useState(false);
2632
+ useLayoutEffect(() => {
2633
+ if (!visible || !rect || !options?.length) {
2634
+ setReady(false);
2635
+ return;
2636
+ }
2637
+ const el = containerRef.current;
2638
+ if (!el)
2639
+ return;
2640
+ const [left, top] = getPosition(makeRectSource(rect), el, {
2641
+ position: "bottom",
2642
+ gap: 4,
2643
+ offset: 0,
2644
+ align: "start",
2645
+ refWindow: true,
2646
+ });
2647
+ setPos({ left, top });
2648
+ setReady(true);
2649
+ }, [visible, rect, options]);
2610
2650
  if (!visible || !rect || !options?.length) {
2611
2651
  return null;
2612
2652
  }
2613
- const content = (jsx(List$1, { className: "i-editor-memtion", type: "option", style: {
2653
+ const content = (jsx(List$1, { ref: containerRef, className: "i-editor-memtion", type: "option", style: {
2614
2654
  position: "fixed",
2615
- top: rect.bottom,
2616
- left: rect.left,
2655
+ left: pos.left,
2656
+ top: pos.top,
2657
+ opacity: ready ? 1 : 0,
2617
2658
  }, children: options.map((option, i) => (jsx(List$1.Item, { type: "option", active: i === activeIndex, onMouseDown: (e) => e.preventDefault(), onMouseEnter: () => onActiveChange?.(i), onClick: () => onSelect?.(option), children: option.label }, `${option.value}-${i}`))) }));
2618
2659
  if (typeof document === "undefined") {
2619
2660
  return content;
@@ -2732,6 +2773,8 @@ const Editor = (props) => {
2732
2773
  };
2733
2774
  const handleKeyDown = (e) => {
2734
2775
  onKeyDown?.(e);
2776
+ if (e.defaultPrevented)
2777
+ return;
2735
2778
  if (!isPlaintextMode &&
2736
2779
  (e.key === "Backspace" || e.key === "Delete") &&
2737
2780
  removeAdjacentMemtionTag(editorRef.current, e.key)) {
@@ -2772,6 +2815,9 @@ const Editor = (props) => {
2772
2815
  exec(isRichMode ? "insertHTML" : "insertText", false, isRichMode ? "	" : "\t");
2773
2816
  break;
2774
2817
  case "Enter":
2818
+ if (e.shiftKey) {
2819
+ break;
2820
+ }
2775
2821
  if (!onEnter)
2776
2822
  break;
2777
2823
  e.preventDefault();
@@ -4615,7 +4661,7 @@ const Handle = (props) => {
4615
4661
  };
4616
4662
 
4617
4663
  function ColorPicker(props) {
4618
- const { value, type = "HEX", disabledAlpha, children, usePanel, handle = "both", placeholder = "Colors", popupProps, onChange, label, required, ...restProps } = props;
4664
+ const { value, type = "HEX", disabledAlpha, children, usePanel, handle = "both", placeholder = "Colors", popupProps, onChange, label, required, className, style, ...restProps } = props;
4619
4665
  const [colorType, setColorType] = useState(type);
4620
4666
  const [colorValue, setColorValue] = useState(value);
4621
4667
  const [syncValue, setSyncValue] = useState(value);
@@ -4659,9 +4705,11 @@ function ColorPicker(props) {
4659
4705
  if (usePanel) {
4660
4706
  return (jsx(InputContainer, { label: label, required: required, children: jsx(ColorsPanel, { ...restProps, value: value, onChange: onChange }) }));
4661
4707
  }
4662
- return (jsx(InputContainer, { label: label, required: required, children: jsx(Popup, { trigger: "click", touchable: true, position: "bottom", ...popupProps, visible: visible, content: jsx(ColorsPanel, { ...restProps, value: syncValue, disabledAlpha: disabledAlpha, panelRender: (panel) => {
4708
+ return (jsx(InputContainer, { label: label, required: required, className: classNames("i-colorpicker", className), style: style, children: jsx(Popup, { trigger: "click", touchable: true, position: "bottom", ...popupProps, visible: visible, content: jsx(ColorsPanel, { ...restProps, value: syncValue, disabledAlpha: disabledAlpha, panelRender: (panel) => {
4663
4709
  return (jsxs(Fragment, { children: [panel, jsx(Footer, { value: colorValue, type: colorType, onTypeChange: handleTypeChange, onChange: handleValueChange, onOk: handleOk })] }));
4664
- }, onChange: handleChange, onChangeComplete: handleComplete }), onVisibleChange: handleVisibleChange, children: children ?? (jsx(Handle, { color: value, handle: handle, placeholder: placeholder })) }) }));
4710
+ }, onChange: handleChange, onChangeComplete: handleComplete }), onVisibleChange: handleVisibleChange, children: typeof children === "function"
4711
+ ? children({ type: colorType, value: colorValue })
4712
+ : (children ?? (jsx(Handle, { color: value, handle: handle, placeholder: placeholder }))) }) }));
4665
4713
  }
4666
4714
 
4667
4715
  const Dates = (props) => {
@@ -6094,7 +6142,7 @@ const normalizeFiles = (files) => (files ?? []).map((item) => {
6094
6142
  };
6095
6143
  });
6096
6144
  const Upload = (props) => {
6097
- const { label, labelInline, value, files, placeholder, status = "normal", message, className, style, children, droppable, dropbox, defaultButtonProps, mode = "default", cardSize = "3.2em", disabled, sortable, limit = props.multiple ? Infinity : 1, multiple, renderItem, shouldUpload = () => true, uploader, onChange, onFilesChange, onUpload, onRemove, ...restProps } = props;
6145
+ const { label, labelInline, value, files, placeholder, status = "normal", message, className, style, children, droppable, dropbox, getDropboxContainer, defaultButtonProps, mode = "default", cardSize = "3.2em", disabled, sortable, limit = props.multiple ? Infinity : 1, multiple, renderItem, shouldUpload = () => true, uploader, onChange, onFilesChange, onUpload, onRemove, ...restProps } = props;
6098
6146
  const [internalFileList, setInternalFileList] = useState([]);
6099
6147
  const isControlled = useMemo(() => value !== undefined || files !== undefined, [value, files]);
6100
6148
  const fileList = isControlled
@@ -6204,7 +6252,12 @@ const Upload = (props) => {
6204
6252
  return node;
6205
6253
  return jsx(SortableItem, { children: node }, key);
6206
6254
  }) }), uploadMessage && (jsx("span", { className: "i-upload-message", children: uploadMessage })), fileList.length < limit &&
6207
- (droppable ? (jsx(Dropbox, { multiple: multiple, accept: restProps.accept, disabled: disabled, onChange: handleChange, onDropFiles: handleDropFiles, children: dropbox })) : (jsxs("label", { children: [jsx("input", { ...restProps, disabled: disabled, ref: inputRef, type: "file", className: "i-input-file-hidden", multiple: multiple, onChange: handleChange }), trigger] })))] }) }));
6255
+ (droppable ? ((() => {
6256
+ const node = (jsx(Dropbox, { multiple: multiple, accept: restProps.accept, disabled: disabled, onChange: handleChange, onDropFiles: handleDropFiles, children: dropbox }));
6257
+ return getDropboxContainer
6258
+ ? createPortal(node, getDropboxContainer())
6259
+ : node;
6260
+ })()) : (jsxs("label", { children: [jsx("input", { ...restProps, disabled: disabled, ref: inputRef, type: "file", className: "i-input-file-hidden", multiple: multiple, onChange: handleChange }), trigger] })))] }) }));
6208
6261
  };
6209
6262
 
6210
6263
  const stores = new Map();
@@ -0,0 +1,6 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { IListItem } from './type.js';
3
+
4
+ declare const Item: (props: IListItem) => react_jsx_runtime.JSX.Element;
5
+
6
+ export { Item as default };
@@ -1,9 +1,7 @@
1
- import { IList, IListItem } from './type.js';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import Item from './item.js';
3
2
 
4
- declare const List: {
5
- (props: IList): react_jsx_runtime.JSX.Element;
6
- Item: (props: IListItem) => react_jsx_runtime.JSX.Element;
3
+ declare const List: typeof List & {
4
+ Item: typeof Item;
7
5
  };
8
6
 
9
7
  export { List as default };
@@ -32,7 +32,10 @@ interface IColorPicker extends Omit<ColorPickerProps, "value" | "onChange"> {
32
32
  label?: ReactNode;
33
33
  required?: boolean;
34
34
  type?: "HEX" | "RGB" | "HSB";
35
- children?: ReactNode;
35
+ children?: ReactNode | ((params: {
36
+ type: string;
37
+ value: any;
38
+ }) => ReactNode);
36
39
  popupProps?: IPopup;
37
40
  usePanel?: boolean;
38
41
  handle?: "text" | "square" | "both";
@@ -34,7 +34,7 @@ interface RefTabs {
34
34
  open: (key: string) => void;
35
35
  close: (key: string) => void;
36
36
  add: (tab: ITabItem, position?: number) => void;
37
- navs: RefObject<HTMLDivElement>;
37
+ navs: RefObject<HTMLDivElement | null>;
38
38
  }
39
39
  interface CompositionTabs extends ForwardRefExoticComponent<ITabs> {
40
40
  Item: typeof Item;
@@ -12,6 +12,7 @@ interface IUpload extends Omit<BaseInput, "ref">, Omit<InputHTMLAttributes<HTMLI
12
12
  mode?: "default" | "card";
13
13
  droppable?: boolean;
14
14
  dropbox?: (dragging?: boolean) => ReactNode;
15
+ getDropboxContainer?: () => HTMLElement;
15
16
  cardSize?: string;
16
17
  defaultButtonProps?: IButton;
17
18
  shouldUpload?: (file: IFile) => boolean;
package/package.json CHANGED
@@ -1,99 +1,99 @@
1
1
  {
2
- "name": "@ioca/react",
3
- "version": "1.5.11",
4
- "type": "module",
5
- "scripts": {
6
- "dev": "vite",
7
- "build": "tsc && vite build",
8
- "preview": "vite preview",
9
- "make": "node templates/index.js",
10
- "lib": "rimraf lib && npx rollup -c"
11
- },
12
- "dependencies": {
13
- "@rc-component/color-picker": "^2.0.1",
14
- "@ricons/material": "^0.12.0",
15
- "classnames": "^2.5.1",
16
- "dayjs": "^1.11.13",
17
- "highlight-words-core": "^1.2.3",
18
- "pubsub-js": "^1.9.5",
19
- "radash": "^12.1.0",
20
- "react": ">=16.8.0",
21
- "react-dom": ">=16.8.0",
22
- "react-easy-sort": "^1.6.0",
23
- "react-router": "^7.1.1",
24
- "react-window": "^2.2.7",
25
- "xss": "^1.0.15"
26
- },
27
- "devDependencies": {
28
- "@rollup/plugin-commonjs": "^28.0.3",
29
- "@rollup/plugin-node-resolve": "^15.3.0",
30
- "@rollup/plugin-terser": "^0.4.4",
31
- "@rollup/plugin-typescript": "^12.1.1",
32
- "@types/mockjs": "^1.0.10",
33
- "@types/node": "^22.10.1",
34
- "@types/pubsub-js": "^1.8.5",
35
- "@types/react": "^19.0.4",
36
- "@types/react-dom": "^19.2.3",
37
- "@vitejs/plugin-react": "^6.0.1",
38
- "chalk": "^5.4.1",
39
- "mockjs": "^1.1.0",
40
- "react-syntax-highlighter": "^15.6.1",
41
- "rimraf": "^6.0.1",
42
- "rollup": "^4.59.0",
43
- "rollup-plugin-dts": "^6.1.1",
44
- "rollup-plugin-peer-deps-external": "^2.2.4",
45
- "rollup-plugin-postcss": "^4.0.2",
46
- "typescript": "^5.7.2",
47
- "vite": "^8.0.0",
48
- "vite-plugin-dynamic-import": "^1.6.0"
49
- },
50
- "peerDependencies": {
51
- "react": ">=16.8.0",
52
- "react-dom": ">=16.8.0"
53
- },
54
- "main": "lib/cjs/index.js",
55
- "module": "lib/es/index.js",
56
- "types": "lib/types/index.d.ts",
57
- "exports": {
58
- ".": {
59
- "types": "./lib/types/index.d.ts",
60
- "import": "./lib/es/index.js",
61
- "require": "./lib/cjs/index.js"
62
- },
63
- "./index.css": "./lib/css/index.css",
64
- "./*": {
65
- "types": "./lib/types/*.d.ts",
66
- "import": "./lib/es/*.js",
67
- "require": "./lib/cjs/*.js"
68
- }
69
- },
70
- "files": [
71
- "lib"
72
- ],
73
- "publishConfig": {
74
- "access": "public"
75
- },
76
- "license": "MIT",
77
- "description": "ioca react ui components",
78
- "directories": {
79
- "doc": "docs"
80
- },
81
- "repository": {
82
- "type": "git",
83
- "url": "git+https://github.com/MunGaaKei/ioca-react.git"
84
- },
85
- "keywords": [
86
- "ioca",
87
- "react ui",
88
- "components"
89
- ],
90
- "author": "iannman",
91
- "bugs": {
92
- "url": "https://github.com/MunGaaKei/ioca-react/issues"
93
- },
94
- "homepage": "https://github.com/MunGaaKei/ioca-react#readme",
95
- "sideEffects": [
96
- "*.css"
97
- ],
98
- "packageManager": "pnpm@10.32.1"
2
+ "name": "@ioca/react",
3
+ "version": "1.5.12",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "tsc && vite build",
8
+ "preview": "vite preview",
9
+ "make": "node templates/index.js",
10
+ "lib": "rimraf lib && npx rollup -c"
11
+ },
12
+ "dependencies": {
13
+ "@rc-component/color-picker": "^2.0.1",
14
+ "@ricons/material": "^0.12.0",
15
+ "classnames": "^2.5.1",
16
+ "dayjs": "^1.11.13",
17
+ "highlight-words-core": "^1.2.3",
18
+ "pubsub-js": "^1.9.5",
19
+ "radash": "^12.1.0",
20
+ "react": ">=16.8.0",
21
+ "react-dom": ">=16.8.0",
22
+ "react-easy-sort": "^1.6.0",
23
+ "react-router": "^7.1.1",
24
+ "react-window": "^2.2.7",
25
+ "xss": "^1.0.15"
26
+ },
27
+ "devDependencies": {
28
+ "@rollup/plugin-commonjs": "^28.0.3",
29
+ "@rollup/plugin-node-resolve": "^15.3.0",
30
+ "@rollup/plugin-terser": "^0.4.4",
31
+ "@rollup/plugin-typescript": "^12.1.1",
32
+ "@types/mockjs": "^1.0.10",
33
+ "@types/node": "^22.10.1",
34
+ "@types/pubsub-js": "^1.8.5",
35
+ "@types/react": "^19.0.4",
36
+ "@types/react-dom": "^19.2.3",
37
+ "@vitejs/plugin-react": "^6.0.1",
38
+ "chalk": "^5.4.1",
39
+ "mockjs": "^1.1.0",
40
+ "react-syntax-highlighter": "^15.6.1",
41
+ "rimraf": "^6.0.1",
42
+ "rollup": "^4.59.0",
43
+ "rollup-plugin-dts": "^6.1.1",
44
+ "rollup-plugin-peer-deps-external": "^2.2.4",
45
+ "rollup-plugin-postcss": "^4.0.2",
46
+ "typescript": "^5.7.2",
47
+ "vite": "^8.0.0",
48
+ "vite-plugin-dynamic-import": "^1.6.0"
49
+ },
50
+ "peerDependencies": {
51
+ "react": ">=16.8.0",
52
+ "react-dom": ">=16.8.0"
53
+ },
54
+ "main": "lib/cjs/index.js",
55
+ "module": "lib/es/index.js",
56
+ "types": "lib/types/index.d.ts",
57
+ "exports": {
58
+ ".": {
59
+ "types": "./lib/types/index.d.ts",
60
+ "import": "./lib/es/index.js",
61
+ "require": "./lib/cjs/index.js"
62
+ },
63
+ "./index.css": "./lib/css/index.css",
64
+ "./*": {
65
+ "types": "./lib/types/*.d.ts",
66
+ "import": "./lib/es/*.js",
67
+ "require": "./lib/cjs/*.js"
68
+ }
69
+ },
70
+ "files": [
71
+ "lib"
72
+ ],
73
+ "publishConfig": {
74
+ "access": "public"
75
+ },
76
+ "license": "MIT",
77
+ "description": "ioca react ui components",
78
+ "directories": {
79
+ "doc": "docs"
80
+ },
81
+ "repository": {
82
+ "type": "git",
83
+ "url": "git+https://github.com/MunGaaKei/ioca-react.git"
84
+ },
85
+ "keywords": [
86
+ "ioca",
87
+ "react ui",
88
+ "components"
89
+ ],
90
+ "author": "iannman",
91
+ "bugs": {
92
+ "url": "https://github.com/MunGaaKei/ioca-react/issues"
93
+ },
94
+ "homepage": "https://github.com/MunGaaKei/ioca-react#readme",
95
+ "sideEffects": [
96
+ "*.css"
97
+ ],
98
+ "packageManager": "pnpm@10.32.1"
99
99
  }