@ioca/react 1.5.13 → 1.5.15
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/lib/cjs/components/dropdown/dropdown.js +6 -3
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/dropdown/item.js +20 -4
- package/lib/cjs/components/dropdown/item.js.map +1 -1
- package/lib/cjs/components/editor/editor.js +27 -11
- package/lib/cjs/components/editor/editor.js.map +1 -1
- package/lib/cjs/components/loading/loading.js +4 -3
- package/lib/cjs/components/loading/loading.js.map +1 -1
- package/lib/cjs/components/popup/popup.js +7 -17
- package/lib/cjs/components/popup/popup.js.map +1 -1
- package/lib/cjs/components/scroll/index.js +10 -0
- package/lib/cjs/components/scroll/index.js.map +1 -0
- package/lib/cjs/components/scroll/scroll.js +78 -0
- package/lib/cjs/components/scroll/scroll.js.map +1 -0
- package/lib/cjs/components/upload/upload.js +5 -5
- package/lib/cjs/components/upload/upload.js.map +1 -1
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/js/hooks.js +8 -6
- package/lib/cjs/js/hooks.js.map +1 -1
- package/lib/css/colors.css +784 -784
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/dropdown/dropdown.js +7 -5
- package/lib/es/components/dropdown/dropdown.js.map +1 -1
- package/lib/es/components/dropdown/item.js +20 -4
- package/lib/es/components/dropdown/item.js.map +1 -1
- package/lib/es/components/editor/editor.js +27 -11
- package/lib/es/components/editor/editor.js.map +1 -1
- package/lib/es/components/loading/loading.js +4 -3
- package/lib/es/components/loading/loading.js.map +1 -1
- package/lib/es/components/popup/popup.js +7 -17
- package/lib/es/components/popup/popup.js.map +1 -1
- package/lib/es/components/scroll/index.js +6 -0
- package/lib/es/components/scroll/index.js.map +1 -0
- package/lib/es/components/scroll/scroll.js +70 -0
- package/lib/es/components/scroll/scroll.js.map +1 -0
- package/lib/es/components/upload/upload.js +7 -7
- package/lib/es/components/upload/upload.js.map +1 -1
- package/lib/es/index.js +1 -0
- package/lib/es/index.js.map +1 -1
- package/lib/es/js/hooks.js +8 -6
- package/lib/es/js/hooks.js.map +1 -1
- package/lib/index.js +140 -51
- package/lib/types/components/dropdown/dropdown.d.ts +1 -1
- package/lib/types/components/editor/type.d.ts +1 -1
- package/lib/types/components/scroll/index.d.ts +5 -0
- package/lib/types/components/scroll/scroll.d.ts +6 -0
- package/lib/types/components/scroll/type.d.ts +7 -0
- package/lib/types/components/upload/type.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
package/lib/es/js/hooks.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
4
|
+
const os = window.navigator.platform;
|
|
5
|
+
if (os.toLowerCase().includes("mac")) {
|
|
6
|
+
document.documentElement.classList.add("os-mac");
|
|
7
|
+
}
|
|
8
|
+
else if (os.toLowerCase().includes("win")) {
|
|
9
|
+
document.documentElement.classList.add("os-windows");
|
|
10
|
+
}
|
|
9
11
|
}
|
|
10
12
|
const MouseMoveEvents = new Set();
|
|
11
13
|
const MouseUpEvents = new Set();
|
package/lib/es/js/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../../../packages/js/hooks.ts"],"sourcesContent":["import {\n\tDependencyList,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\n\ntype TMouseEvent = (e: MouseEvent) => void;\ntype TKeyboardEvent = (e: KeyboardEvent) => void;\ntype TEventOption = {\n\tdisabled?: boolean;\n};\n\nconst os = window.navigator.platform;\n\nif (os.toLowerCase().includes(\"mac\")) {\n\tdocument.documentElement.classList.add(\"os-mac\");\n} else if (os.toLowerCase().includes(\"win\")) {\n\tdocument.documentElement.classList.add(\"os-windows\");\n}\n\nconst MouseMoveEvents = new Set<TMouseEvent>();\nconst MouseUpEvents = new Set<TMouseEvent>();\nconst KeydownEvents = new Set<TKeyboardEvent>();\n\nlet initialized = false;\n\nconst initEvents = () => {\n\tif (typeof document === \"undefined\" || initialized) return;\n\tinitialized = true;\n\n\tconst touchable = \"ontouchend\" in document;\n\tconst EVENTS: Record<string, any> = {\n\t\tMOVE: touchable ? \"touchmove\" : \"mousemove\",\n\t\tUP: touchable ? \"touchend\" : \"mouseup\",\n\t\tKEYDOWN: \"keydown\",\n\t};\n\n\tdocument.addEventListener(\n\t\tEVENTS.MOVE,\n\t\t(e) => {\n\t\t\tfor (const listener of MouseMoveEvents.values()) {\n\t\t\t\tlistener(e);\n\t\t\t}\n\t\t},\n\t\t{ passive: false },\n\t);\n\n\tdocument.addEventListener(EVENTS.UP, (e) => {\n\t\tfor (const listener of MouseUpEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n\n\tdocument.addEventListener(EVENTS.KEYDOWN, (e) => {\n\t\tfor (const listener of KeydownEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n};\n\nfunction initEventsOnce() {\n\tuseEffect(initEvents, []);\n}\n\nexport function useMouseMove(listener: TMouseEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseMoveEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseMoveEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useMouseUp(listener: TMouseEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseUpEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseUpEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useKeydown(listener: TKeyboardEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tKeydownEvents.add(listener);\n\t\treturn () => {\n\t\t\tKeydownEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useCreation<T>(factory: () => T, deps: DependencyList) {\n\treturn useMemo(factory, deps);\n}\n\nexport function useReactive<T extends object>(initialState: T): T {\n\tconst [, setFlag] = useState(0);\n\tconst scheduledRef = useRef(false);\n\tconst proxyCacheRef = useRef(new WeakMap<object, any>());\n\tconst rootRef = useRef<T | null>(null);\n\tconst proxyRef = useRef<T | null>(null);\n\n\tconst notify = () => {\n\t\tif (scheduledRef.current) return;\n\t\tscheduledRef.current = true;\n\n\t\tconst flush = () => {\n\t\t\tscheduledRef.current = false;\n\t\t\tsetFlag((n) => n + 1);\n\t\t};\n\n\t\tif (typeof queueMicrotask !== \"undefined\") {\n\t\t\tqueueMicrotask(flush);\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.resolve().then(flush);\n\t};\n\n\tconst createProxy = (target: any): any => {\n\t\tif (!target || typeof target !== \"object\") return target;\n\n\t\tif (!Array.isArray(target)) {\n\t\t\tconst proto = Object.getPrototypeOf(target);\n\t\t\tconst isPlainObject = proto === Object.prototype || proto === null;\n\t\t\tif (!isPlainObject) return target;\n\t\t}\n\n\t\tconst cached = proxyCacheRef.current.get(target);\n\t\tif (cached) return cached;\n\n\t\tconst proxy = new Proxy(target, {\n\t\t\tget(t, p, r) {\n\t\t\t\treturn createProxy(Reflect.get(t, p, r));\n\t\t\t},\n\t\t\tset(t, p, v, r) {\n\t\t\t\tconst prev = Reflect.get(t, p, r);\n\t\t\t\tconst ok = Reflect.set(t, p, v, r);\n\t\t\t\tif (prev !== v) notify();\n\t\t\t\treturn ok;\n\t\t\t},\n\t\t\tdeleteProperty(t, p) {\n\t\t\t\tconst had = Object.prototype.hasOwnProperty.call(t, p);\n\t\t\t\tconst ok = Reflect.deleteProperty(t, p);\n\t\t\t\tif (had) notify();\n\t\t\t\treturn ok;\n\t\t\t},\n\t\t});\n\n\t\tproxyCacheRef.current.set(target, proxy);\n\t\treturn proxy;\n\t};\n\n\tif (!proxyRef.current) {\n\t\trootRef.current = initialState;\n\t\tproxyRef.current = createProxy(rootRef.current);\n\t}\n\n\treturn proxyRef.current as T;\n}\n\ntype TSetState<T> = (\n\tvalue: T | undefined | ((prev: T | undefined) => T),\n) => void;\n\ntype TLocalStorageOptions<T> = {\n\tdefaultValue?: T | (() => T);\n\tlistenStorageChange?: boolean;\n};\n\nexport function useLocalStorageState<T>(\n\tkey: string,\n\toptions?: TLocalStorageOptions<T>,\n): [T | undefined, TSetState<T>] {\n\tconst { defaultValue, listenStorageChange } = options ?? {};\n\n\tconst getDefault = () => {\n\t\treturn typeof defaultValue === \"function\"\n\t\t\t? (defaultValue as () => T)()\n\t\t\t: defaultValue;\n\t};\n\n\tconst read = (): T | undefined => {\n\t\tif (typeof window === \"undefined\") return getDefault();\n\n\t\tconst raw = window.localStorage.getItem(key);\n\t\tif (raw === null) return getDefault();\n\n\t\ttry {\n\t\t\treturn JSON.parse(raw) as T;\n\t\t} catch (e) {\n\t\t\treturn raw as unknown as T;\n\t\t}\n\t};\n\n\tconst [state, setState] = useState<T | undefined>(() => read());\n\n\tconst set: TSetState<T> = (value) => {\n\t\tsetState((prev) => {\n\t\t\tconst next =\n\t\t\t\ttypeof value === \"function\"\n\t\t\t\t\t? (value as (prev: T | undefined) => T)(prev)\n\t\t\t\t\t: value;\n\n\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\twindow.localStorage.removeItem(key);\n\t\t\t\t} else {\n\t\t\t\t\twindow.localStorage.setItem(key, JSON.stringify(next));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn next;\n\t\t});\n\t};\n\n\tuseEffect(() => {\n\t\tif (!listenStorageChange) return;\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst onStorage = (e: StorageEvent) => {\n\t\t\tif (e.key !== key) return;\n\n\t\t\tif (e.newValue === null) {\n\t\t\t\tsetState(getDefault());\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tsetState(JSON.parse(e.newValue) as T);\n\t\t\t} catch (err) {\n\t\t\t\tsetState(e.newValue as unknown as T);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"storage\", onStorage);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"storage\", onStorage);\n\t\t};\n\t}, [key, listenStorageChange]);\n\n\treturn [state, set];\n}\n\ntype TResponsiveConfig = Record<string, number>;\n\nlet responsiveConfig: TResponsiveConfig = {};\n\nexport function configResponsive(config: TResponsiveConfig) {\n\tresponsiveConfig = config;\n}\n\nexport function useResponsive() {\n\tconst compute = () => {\n\t\tif (typeof window === \"undefined\") return {};\n\t\tconst w = window.innerWidth;\n\t\tconst result: Record<string, boolean> = {};\n\n\t\tfor (const key in responsiveConfig) {\n\t\t\tresult[key] = w >= responsiveConfig[key];\n\t\t}\n\n\t\treturn result;\n\t};\n\n\tconst [state, setState] = useState<Record<string, boolean>>(() =>\n\t\tcompute(),\n\t);\n\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst onResize = () => {\n\t\t\tconst next = compute();\n\t\t\tsetState((prev) => {\n\t\t\t\tconst prevKeys = Object.keys(prev);\n\t\t\t\tconst nextKeys = Object.keys(next);\n\t\t\t\tif (prevKeys.length !== nextKeys.length) return next;\n\n\t\t\t\tfor (const k of nextKeys) {\n\t\t\t\t\tif (prev[k] !== next[k]) return next;\n\t\t\t\t}\n\n\t\t\t\treturn prev;\n\t\t\t});\n\t\t};\n\n\t\tonResize();\n\t\twindow.addEventListener(\"resize\", onResize);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"resize\", onResize);\n\t\t};\n\t}, []);\n\n\treturn state;\n}\n\ntype TSize = { width: number; height: number };\n\nexport function useSize(target: any): TSize | undefined {\n\tconst [size, setSize] = useState<TSize>();\n\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst resolveTarget = () => {\n\t\t\tif (!target) return null;\n\t\t\tif (typeof target === \"function\") return target();\n\t\t\tif (typeof target === \"object\" && \"current\" in target) {\n\t\t\t\treturn target.current;\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tconst el = resolveTarget() as HTMLElement | null;\n\t\tif (!el) return;\n\n\t\tconst update = () => {\n\t\t\tconst rect = el.getBoundingClientRect();\n\t\t\tsetSize({ width: rect.width, height: rect.height });\n\t\t};\n\n\t\tupdate();\n\n\t\tlet ro: ResizeObserver | undefined;\n\t\tif (typeof ResizeObserver !== \"undefined\") {\n\t\t\tro = new ResizeObserver(update);\n\t\t\tro.observe(el);\n\t\t}\n\n\t\twindow.addEventListener(\"resize\", update);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"resize\", update);\n\t\t\tro?.disconnect();\n\t\t};\n\t}, [target]);\n\n\treturn size;\n}\n\nconst defaultObserver = {\n\tobserve: undefined,\n\tunobserve: undefined,\n\tdisconnect: undefined,\n};\n\nexport function useIntersectionObserver(configs?: IntersectionObserverInit) {\n\tconst wmRef = useRef(new WeakMap());\n\tconst ioRef = useRef<IntersectionObserver | undefined>(undefined);\n\n\tif (typeof window !== \"undefined\" && !ioRef.current) {\n\t\tioRef.current = new IntersectionObserver((entries) => {\n\t\t\tentries.map((entry) => {\n\t\t\t\tconst callback = wmRef.current.get(entry.target);\n\t\t\t\tcallback?.(entry.target, entry.isIntersecting);\n\t\t\t});\n\t\t}, configs);\n\t}\n\n\tconst observe = useCallback((target: HTMLElement, callback: Function) => {\n\t\tif (!target || !ioRef.current || wmRef.current.get(target)) return;\n\t\twmRef.current.set(target, callback);\n\t\tioRef.current.observe(target);\n\t}, []);\n\n\tconst unobserve = useCallback((target: HTMLElement) => {\n\t\tif (!target || !ioRef.current) return;\n\t\tioRef.current.unobserve(target);\n\t\twmRef.current.delete(target);\n\t}, []);\n\n\tconst disconnect = useCallback(() => {\n\t\tioRef.current?.disconnect();\n\t}, []);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tioRef.current?.disconnect();\n\t\t};\n\t}, []);\n\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n\nexport function useResizeObserver() {\n\tconst wmRef = useRef(new WeakMap());\n\tconst ioRef = useRef<ResizeObserver | undefined>(undefined);\n\n\tif (typeof window !== \"undefined\" && !ioRef.current) {\n\t\tioRef.current = new ResizeObserver((entries) => {\n\t\t\tentries.map((entry) => {\n\t\t\t\tconst callback = wmRef.current.get(entry.target);\n\t\t\t\tcallback?.(entry.target);\n\t\t\t});\n\t\t});\n\t}\n\n\tconst observe = useCallback((target: HTMLElement, callback: Function) => {\n\t\tif (!target || !ioRef.current || wmRef.current.get(target)) return;\n\t\tioRef.current.observe(target);\n\t\twmRef.current.set(target, callback);\n\t}, []);\n\n\tconst unobserve = useCallback((target: HTMLElement) => {\n\t\tif (!target || !ioRef.current) return;\n\t\tioRef.current.unobserve(target);\n\t\twmRef.current.delete(target);\n\t}, []);\n\n\tconst disconnect = useCallback(() => {\n\t\tioRef.current?.disconnect();\n\t}, []);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tioRef.current?.disconnect();\n\t\t};\n\t}, []);\n\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n"],"names":[],"mappings":";;AAeA,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ;AAEpC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;IACrC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;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AI;AACrD,QAAA,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO;YAAE;AAC/B,QAAA,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;AAC/B,QAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,UAAU,GAAG,WAAW,CAAC,MAAK;AACnC,QAAA,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE;IAC5B,CAAC,EAAE,EAAE,CAAC;IAEN,SAAS,CAAC,MAAK;AACd,QAAA,OAAO,MAAK;AACX,YAAA,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE;AAC5B,QAAA,CAAC;IACF,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAClC,OAAO;AACN,YAAA,GAAG,eAAe;SAClB;IACF;IAEA,OAAO;QACN,OAAO;QACP,SAAS;QACT,UAAU;KACV;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../packages/js/hooks.ts"],"sourcesContent":["import {\n\tDependencyList,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\n\ntype TMouseEvent = (e: MouseEvent) => void;\ntype TKeyboardEvent = (e: KeyboardEvent) => void;\ntype TEventOption = {\n\tdisabled?: boolean;\n};\n\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n\tconst os = window.navigator.platform;\n\n\tif (os.toLowerCase().includes(\"mac\")) {\n\t\tdocument.documentElement.classList.add(\"os-mac\");\n\t} else if (os.toLowerCase().includes(\"win\")) {\n\t\tdocument.documentElement.classList.add(\"os-windows\");\n\t}\n}\n\nconst MouseMoveEvents = new Set<TMouseEvent>();\nconst MouseUpEvents = new Set<TMouseEvent>();\nconst KeydownEvents = new Set<TKeyboardEvent>();\n\nlet initialized = false;\n\nconst initEvents = () => {\n\tif (typeof document === \"undefined\" || initialized) return;\n\tinitialized = true;\n\n\tconst touchable = \"ontouchend\" in document;\n\tconst EVENTS: Record<string, any> = {\n\t\tMOVE: touchable ? \"touchmove\" : \"mousemove\",\n\t\tUP: touchable ? \"touchend\" : \"mouseup\",\n\t\tKEYDOWN: \"keydown\",\n\t};\n\n\tdocument.addEventListener(\n\t\tEVENTS.MOVE,\n\t\t(e) => {\n\t\t\tfor (const listener of MouseMoveEvents.values()) {\n\t\t\t\tlistener(e);\n\t\t\t}\n\t\t},\n\t\t{ passive: false },\n\t);\n\n\tdocument.addEventListener(EVENTS.UP, (e) => {\n\t\tfor (const listener of MouseUpEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n\n\tdocument.addEventListener(EVENTS.KEYDOWN, (e) => {\n\t\tfor (const listener of KeydownEvents.values()) {\n\t\t\tlistener(e);\n\t\t}\n\t});\n};\n\nfunction initEventsOnce() {\n\tuseEffect(initEvents, []);\n}\n\nexport function useMouseMove(listener: TMouseEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseMoveEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseMoveEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useMouseUp(listener: TMouseEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tMouseUpEvents.add(listener);\n\t\treturn () => {\n\t\t\tMouseUpEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useKeydown(listener: TKeyboardEvent, options?: TEventOption) {\n\tinitEventsOnce();\n\n\tuseEffect(() => {\n\t\tif (options?.disabled) return;\n\n\t\tKeydownEvents.add(listener);\n\t\treturn () => {\n\t\t\tKeydownEvents.delete(listener);\n\t\t};\n\t}, []);\n}\n\nexport function useCreation<T>(factory: () => T, deps: DependencyList) {\n\treturn useMemo(factory, deps);\n}\n\nexport function useReactive<T extends object>(initialState: T): T {\n\tconst [, setFlag] = useState(0);\n\tconst scheduledRef = useRef(false);\n\tconst proxyCacheRef = useRef(new WeakMap<object, any>());\n\tconst rootRef = useRef<T | null>(null);\n\tconst proxyRef = useRef<T | null>(null);\n\n\tconst notify = () => {\n\t\tif (scheduledRef.current) return;\n\t\tscheduledRef.current = true;\n\n\t\tconst flush = () => {\n\t\t\tscheduledRef.current = false;\n\t\t\tsetFlag((n) => n + 1);\n\t\t};\n\n\t\tif (typeof queueMicrotask !== \"undefined\") {\n\t\t\tqueueMicrotask(flush);\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.resolve().then(flush);\n\t};\n\n\tconst createProxy = (target: any): any => {\n\t\tif (!target || typeof target !== \"object\") return target;\n\n\t\tif (!Array.isArray(target)) {\n\t\t\tconst proto = Object.getPrototypeOf(target);\n\t\t\tconst isPlainObject = proto === Object.prototype || proto === null;\n\t\t\tif (!isPlainObject) return target;\n\t\t}\n\n\t\tconst cached = proxyCacheRef.current.get(target);\n\t\tif (cached) return cached;\n\n\t\tconst proxy = new Proxy(target, {\n\t\t\tget(t, p, r) {\n\t\t\t\treturn createProxy(Reflect.get(t, p, r));\n\t\t\t},\n\t\t\tset(t, p, v, r) {\n\t\t\t\tconst prev = Reflect.get(t, p, r);\n\t\t\t\tconst ok = Reflect.set(t, p, v, r);\n\t\t\t\tif (prev !== v) notify();\n\t\t\t\treturn ok;\n\t\t\t},\n\t\t\tdeleteProperty(t, p) {\n\t\t\t\tconst had = Object.prototype.hasOwnProperty.call(t, p);\n\t\t\t\tconst ok = Reflect.deleteProperty(t, p);\n\t\t\t\tif (had) notify();\n\t\t\t\treturn ok;\n\t\t\t},\n\t\t});\n\n\t\tproxyCacheRef.current.set(target, proxy);\n\t\treturn proxy;\n\t};\n\n\tif (!proxyRef.current) {\n\t\trootRef.current = initialState;\n\t\tproxyRef.current = createProxy(rootRef.current);\n\t}\n\n\treturn proxyRef.current as T;\n}\n\ntype TSetState<T> = (\n\tvalue: T | undefined | ((prev: T | undefined) => T),\n) => void;\n\ntype TLocalStorageOptions<T> = {\n\tdefaultValue?: T | (() => T);\n\tlistenStorageChange?: boolean;\n};\n\nexport function useLocalStorageState<T>(\n\tkey: string,\n\toptions?: TLocalStorageOptions<T>,\n): [T | undefined, TSetState<T>] {\n\tconst { defaultValue, listenStorageChange } = options ?? {};\n\n\tconst getDefault = () => {\n\t\treturn typeof defaultValue === \"function\"\n\t\t\t? (defaultValue as () => T)()\n\t\t\t: defaultValue;\n\t};\n\n\tconst read = (): T | undefined => {\n\t\tif (typeof window === \"undefined\") return getDefault();\n\n\t\tconst raw = window.localStorage.getItem(key);\n\t\tif (raw === null) return getDefault();\n\n\t\ttry {\n\t\t\treturn JSON.parse(raw) as T;\n\t\t} catch (e) {\n\t\t\treturn raw as unknown as T;\n\t\t}\n\t};\n\n\tconst [state, setState] = useState<T | undefined>(() => read());\n\n\tconst set: TSetState<T> = (value) => {\n\t\tsetState((prev) => {\n\t\t\tconst next =\n\t\t\t\ttypeof value === \"function\"\n\t\t\t\t\t? (value as (prev: T | undefined) => T)(prev)\n\t\t\t\t\t: value;\n\n\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\twindow.localStorage.removeItem(key);\n\t\t\t\t} else {\n\t\t\t\t\twindow.localStorage.setItem(key, JSON.stringify(next));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn next;\n\t\t});\n\t};\n\n\tuseEffect(() => {\n\t\tif (!listenStorageChange) return;\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst onStorage = (e: StorageEvent) => {\n\t\t\tif (e.key !== key) return;\n\n\t\t\tif (e.newValue === null) {\n\t\t\t\tsetState(getDefault());\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tsetState(JSON.parse(e.newValue) as T);\n\t\t\t} catch (err) {\n\t\t\t\tsetState(e.newValue as unknown as T);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"storage\", onStorage);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"storage\", onStorage);\n\t\t};\n\t}, [key, listenStorageChange]);\n\n\treturn [state, set];\n}\n\ntype TResponsiveConfig = Record<string, number>;\n\nlet responsiveConfig: TResponsiveConfig = {};\n\nexport function configResponsive(config: TResponsiveConfig) {\n\tresponsiveConfig = config;\n}\n\nexport function useResponsive() {\n\tconst compute = () => {\n\t\tif (typeof window === \"undefined\") return {};\n\t\tconst w = window.innerWidth;\n\t\tconst result: Record<string, boolean> = {};\n\n\t\tfor (const key in responsiveConfig) {\n\t\t\tresult[key] = w >= responsiveConfig[key];\n\t\t}\n\n\t\treturn result;\n\t};\n\n\tconst [state, setState] = useState<Record<string, boolean>>(() =>\n\t\tcompute(),\n\t);\n\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst onResize = () => {\n\t\t\tconst next = compute();\n\t\t\tsetState((prev) => {\n\t\t\t\tconst prevKeys = Object.keys(prev);\n\t\t\t\tconst nextKeys = Object.keys(next);\n\t\t\t\tif (prevKeys.length !== nextKeys.length) return next;\n\n\t\t\t\tfor (const k of nextKeys) {\n\t\t\t\t\tif (prev[k] !== next[k]) return next;\n\t\t\t\t}\n\n\t\t\t\treturn prev;\n\t\t\t});\n\t\t};\n\n\t\tonResize();\n\t\twindow.addEventListener(\"resize\", onResize);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"resize\", onResize);\n\t\t};\n\t}, []);\n\n\treturn state;\n}\n\ntype TSize = { width: number; height: number };\n\nexport function useSize(target: any): TSize | undefined {\n\tconst [size, setSize] = useState<TSize>();\n\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\n\t\tconst resolveTarget = () => {\n\t\t\tif (!target) return null;\n\t\t\tif (typeof target === \"function\") return target();\n\t\t\tif (typeof target === \"object\" && \"current\" in target) {\n\t\t\t\treturn target.current;\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tconst el = resolveTarget() as HTMLElement | null;\n\t\tif (!el) return;\n\n\t\tconst update = () => {\n\t\t\tconst rect = el.getBoundingClientRect();\n\t\t\tsetSize({ width: rect.width, height: rect.height });\n\t\t};\n\n\t\tupdate();\n\n\t\tlet ro: ResizeObserver | undefined;\n\t\tif (typeof ResizeObserver !== \"undefined\") {\n\t\t\tro = new ResizeObserver(update);\n\t\t\tro.observe(el);\n\t\t}\n\n\t\twindow.addEventListener(\"resize\", update);\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"resize\", update);\n\t\t\tro?.disconnect();\n\t\t};\n\t}, [target]);\n\n\treturn size;\n}\n\nconst defaultObserver = {\n\tobserve: undefined,\n\tunobserve: undefined,\n\tdisconnect: undefined,\n};\n\nexport function useIntersectionObserver(configs?: IntersectionObserverInit) {\n\tconst wmRef = useRef(new WeakMap());\n\tconst ioRef = useRef<IntersectionObserver | undefined>(undefined);\n\n\tif (typeof window !== \"undefined\" && !ioRef.current) {\n\t\tioRef.current = new IntersectionObserver((entries) => {\n\t\t\tentries.map((entry) => {\n\t\t\t\tconst callback = wmRef.current.get(entry.target);\n\t\t\t\tcallback?.(entry.target, entry.isIntersecting);\n\t\t\t});\n\t\t}, configs);\n\t}\n\n\tconst observe = useCallback((target: HTMLElement, callback: Function) => {\n\t\tif (!target || !ioRef.current || wmRef.current.get(target)) return;\n\t\twmRef.current.set(target, callback);\n\t\tioRef.current.observe(target);\n\t}, []);\n\n\tconst unobserve = useCallback((target: HTMLElement) => {\n\t\tif (!target || !ioRef.current) return;\n\t\tioRef.current.unobserve(target);\n\t\twmRef.current.delete(target);\n\t}, []);\n\n\tconst disconnect = useCallback(() => {\n\t\tioRef.current?.disconnect();\n\t}, []);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tioRef.current?.disconnect();\n\t\t};\n\t}, []);\n\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n\nexport function useResizeObserver() {\n\tconst wmRef = useRef(new WeakMap());\n\tconst ioRef = useRef<ResizeObserver | undefined>(undefined);\n\n\tif (typeof window !== \"undefined\" && !ioRef.current) {\n\t\tioRef.current = new ResizeObserver((entries) => {\n\t\t\tentries.map((entry) => {\n\t\t\t\tconst callback = wmRef.current.get(entry.target);\n\t\t\t\tcallback?.(entry.target);\n\t\t\t});\n\t\t});\n\t}\n\n\tconst observe = useCallback((target: HTMLElement, callback: Function) => {\n\t\tif (!target || !ioRef.current || wmRef.current.get(target)) return;\n\t\tioRef.current.observe(target);\n\t\twmRef.current.set(target, callback);\n\t}, []);\n\n\tconst unobserve = useCallback((target: HTMLElement) => {\n\t\tif (!target || !ioRef.current) return;\n\t\tioRef.current.unobserve(target);\n\t\twmRef.current.delete(target);\n\t}, []);\n\n\tconst disconnect = useCallback(() => {\n\t\tioRef.current?.disconnect();\n\t}, []);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tioRef.current?.disconnect();\n\t\t};\n\t}, []);\n\n\tif (typeof window === \"undefined\") {\n\t\treturn {\n\t\t\t...defaultObserver,\n\t\t};\n\t}\n\n\treturn {\n\t\tobserve,\n\t\tunobserve,\n\t\tdisconnect,\n\t};\n}\n"],"names":[],"mappings":";;AAeA,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACrE,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ;IAEpC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACrC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;IACjD;SAAO,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5C,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAA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AA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,UAAU,GAAG,WAAW,CAAC,MAAK;AACnC,QAAA,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE;IAC5B,CAAC,EAAE,EAAE,CAAC;IAEN,SAAS,CAAC,MAAK;AACd,QAAA,OAAO,MAAK;AACX,YAAA,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE;AAC5B,QAAA,CAAC;IACF,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAClC,OAAO;AACN,YAAA,GAAG,eAAe;SAClB;IACF;IAEA,OAAO;QACN,OAAO;QACP,SAAS;QACT,UAAU;KACV;AACF;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { debounce, uid, throttle } from 'radash';
|
|
4
|
-
import { useState, useRef, useEffect, useCallback, useMemo, Children, cloneElement, createElement, isValidElement, memo, Fragment as Fragment$1, useTransition, forwardRef, useLayoutEffect,
|
|
5
|
-
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, UndoRound, RedoRound, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, ClearAllRound, PlayArrowRound, PauseRound, StopRound, VolumeDownRound, VolumeOffRound, FullscreenRound, FullscreenExitRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, KeyboardDoubleArrowUpRound, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, MoveToInboxTwotone, OutboxTwotone, FilePresentOutlined, DriveFolderUploadOutlined
|
|
4
|
+
import { useState, useRef, useEffect, useCallback, useMemo, Children, cloneElement, createElement, isValidElement, memo, Fragment as Fragment$1, useTransition, forwardRef, useLayoutEffect, useContext, createContext, useImperativeHandle } from 'react';
|
|
5
|
+
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, UndoRound, RedoRound, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, ClearAllRound, PlayArrowRound, PauseRound, StopRound, VolumeDownRound, VolumeOffRound, FullscreenRound, FullscreenExitRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, KeyboardDoubleArrowUpRound, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, MoveToInboxTwotone, OutboxTwotone, FilePresentOutlined, DriveFolderUploadOutlined } from '@ricons/material';
|
|
6
6
|
import { createRoot } from 'react-dom/client';
|
|
7
7
|
import { getScrollbarSize, List as List$2 } from 'react-window';
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
@@ -62,22 +62,25 @@ function createRipple() {
|
|
|
62
62
|
|
|
63
63
|
const Loading = (props) => {
|
|
64
64
|
const { icon, text, size, absolute, style, className, ...restProps } = props;
|
|
65
|
+
const iconSize = size != null
|
|
66
|
+
? { fontSize: typeof size === "number" ? `${size}px` : size }
|
|
67
|
+
: undefined;
|
|
65
68
|
return (jsxs("div", { className: classNames("i-loading-container", {
|
|
66
69
|
absolute,
|
|
67
70
|
}, className), style: {
|
|
68
71
|
...style,
|
|
69
72
|
inset: absolute ? 0 : "unset",
|
|
70
|
-
}, ...restProps, children: [icon ??
|
|
71
|
-
fontSize: size,
|
|
72
|
-
}, children: jsx("circle", { cx: '12', cy: '12', r: '9.5', fill: 'none', strokeWidth: '3', strokeLinecap: 'round', strokeDasharray: 40, strokeDashoffset: 0 }) })), text] }));
|
|
73
|
+
}, ...restProps, children: [icon ?? jsx("span", { className: "i-loading-icon", style: iconSize }), text] }));
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
77
|
+
const os = window.navigator.platform;
|
|
78
|
+
if (os.toLowerCase().includes("mac")) {
|
|
79
|
+
document.documentElement.classList.add("os-mac");
|
|
80
|
+
}
|
|
81
|
+
else if (os.toLowerCase().includes("win")) {
|
|
82
|
+
document.documentElement.classList.add("os-windows");
|
|
83
|
+
}
|
|
81
84
|
}
|
|
82
85
|
const MouseMoveEvents = new Set();
|
|
83
86
|
const MouseUpEvents = new Set();
|
|
@@ -1839,19 +1842,7 @@ function Popup(props) {
|
|
|
1839
1842
|
const [show, setShow] = useState(false);
|
|
1840
1843
|
const showRef = useRef(false);
|
|
1841
1844
|
showRef.current = show;
|
|
1842
|
-
const latestRef = useRef({
|
|
1843
|
-
disabled,
|
|
1844
|
-
trigger,
|
|
1845
|
-
touchable,
|
|
1846
|
-
showDelay,
|
|
1847
|
-
hideDelay,
|
|
1848
|
-
position,
|
|
1849
|
-
gap,
|
|
1850
|
-
offset,
|
|
1851
|
-
align,
|
|
1852
|
-
fitSize,
|
|
1853
|
-
onVisibleChange,
|
|
1854
|
-
});
|
|
1845
|
+
const latestRef = useRef({});
|
|
1855
1846
|
latestRef.current = {
|
|
1856
1847
|
disabled,
|
|
1857
1848
|
trigger,
|
|
@@ -1905,9 +1896,8 @@ function Popup(props) {
|
|
|
1905
1896
|
};
|
|
1906
1897
|
const applyFitSize = () => {
|
|
1907
1898
|
const o = latestRef.current;
|
|
1908
|
-
const triggerEl = triggerRef.current;
|
|
1909
1899
|
const contentEl = contentRef.current;
|
|
1910
|
-
if (!
|
|
1900
|
+
if (!contentEl)
|
|
1911
1901
|
return;
|
|
1912
1902
|
const vertical = ["top", "bottom"].includes(o.position);
|
|
1913
1903
|
const key = vertical ? "width" : "height";
|
|
@@ -1915,6 +1905,9 @@ function Popup(props) {
|
|
|
1915
1905
|
contentEl.style[key] = "";
|
|
1916
1906
|
return;
|
|
1917
1907
|
}
|
|
1908
|
+
const triggerEl = triggerRef.current;
|
|
1909
|
+
if (!triggerEl)
|
|
1910
|
+
return;
|
|
1918
1911
|
const size = triggerEl[vertical ? "offsetWidth" : "offsetHeight"];
|
|
1919
1912
|
contentEl.style[key] =
|
|
1920
1913
|
typeof size === "number" ? `${size}px` : "";
|
|
@@ -2151,8 +2144,8 @@ function Popup(props) {
|
|
|
2151
2144
|
e.stopPropagation();
|
|
2152
2145
|
setTriggerEl(e);
|
|
2153
2146
|
pointRef.current = {
|
|
2154
|
-
pageX: e.
|
|
2155
|
-
pageY: e.
|
|
2147
|
+
pageX: e.clientX,
|
|
2148
|
+
pageY: e.clientY,
|
|
2156
2149
|
};
|
|
2157
2150
|
if (showRef.current) {
|
|
2158
2151
|
ensureBaseStyle();
|
|
@@ -2309,22 +2302,38 @@ function Popup(props) {
|
|
|
2309
2302
|
|
|
2310
2303
|
const { Item: ListItem } = List$1;
|
|
2311
2304
|
const Item$3 = (props) => {
|
|
2312
|
-
const { more, moreProps, onClick, ...restProps } = props;
|
|
2313
|
-
const
|
|
2305
|
+
const { more, moreProps, onClick, ref: itemRef, children, ...restProps } = props;
|
|
2306
|
+
const close = useContext(DropdownCloseCtx);
|
|
2307
|
+
const liRef = useRef(null);
|
|
2308
|
+
const [position, setPosition] = useState("right");
|
|
2309
|
+
const { position: morePosition, onVisibleChange: moreOnVisibleChange, width: moreWidth, ...restMoreProps } = moreProps ?? {};
|
|
2310
|
+
const effectivePosition = morePosition ?? position;
|
|
2311
|
+
const handleVisibleChange = (v) => {
|
|
2312
|
+
if (v && liRef.current) {
|
|
2313
|
+
const rect = liRef.current.getBoundingClientRect();
|
|
2314
|
+
setPosition(rect.left > window.innerWidth / 2 ? "left" : "right");
|
|
2315
|
+
}
|
|
2316
|
+
moreOnVisibleChange?.(v);
|
|
2317
|
+
};
|
|
2318
|
+
const Li = (jsx(ListItem, { ref: itemRef ?? liRef, onClick: (e) => {
|
|
2314
2319
|
e.stopPropagation();
|
|
2320
|
+
if (!more)
|
|
2321
|
+
close?.();
|
|
2315
2322
|
onClick?.(e);
|
|
2316
|
-
}, ...restProps }));
|
|
2323
|
+
}, ...restProps, children: children }));
|
|
2317
2324
|
if (!more)
|
|
2318
2325
|
return Li;
|
|
2319
|
-
return (jsx(Popup, { position:
|
|
2326
|
+
return (jsx(Popup, { ...restMoreProps, position: effectivePosition, touchable: true, arrow: false, align: "start", offset: 11, hideDelay: 240, onVisibleChange: handleVisibleChange, content: jsx(List$1, { className: "i-dropdown-content", style: { minWidth: moreWidth }, onClick: (e) => e.stopPropagation(), children: more }), children: Li }));
|
|
2320
2327
|
};
|
|
2321
2328
|
|
|
2329
|
+
const DropdownCloseCtx = createContext(null);
|
|
2322
2330
|
const Dropdown = (props) => {
|
|
2323
2331
|
const { visible, width, content, children, ...restProps } = props;
|
|
2324
2332
|
const [active, setActive] = useState(visible);
|
|
2325
2333
|
if (!content) {
|
|
2326
2334
|
return children;
|
|
2327
2335
|
}
|
|
2336
|
+
const close = () => setActive(false);
|
|
2328
2337
|
const handleVisibleChange = (v) => {
|
|
2329
2338
|
setActive(v);
|
|
2330
2339
|
if (props.onVisibleChange) {
|
|
@@ -2334,9 +2343,9 @@ const Dropdown = (props) => {
|
|
|
2334
2343
|
useEffect(() => {
|
|
2335
2344
|
setActive(visible);
|
|
2336
2345
|
}, [visible]);
|
|
2337
|
-
return (jsx(Popup, { trigger: 'click', position: 'bottom', content: jsx(List$1, { className: 'i-dropdown-content', style: { minWidth: width }, children: typeof content === "function"
|
|
2338
|
-
|
|
2339
|
-
|
|
2346
|
+
return (jsx(Popup, { trigger: 'click', position: 'bottom', content: jsx(DropdownCloseCtx.Provider, { value: close, children: jsx(List$1, { className: 'i-dropdown-content', style: { minWidth: width }, children: typeof content === "function"
|
|
2347
|
+
? content(close)
|
|
2348
|
+
: content }) }), ...restProps, touchable: true, visible: active, onVisibleChange: handleVisibleChange, children: children }));
|
|
2340
2349
|
};
|
|
2341
2350
|
Dropdown.Item = Item$3;
|
|
2342
2351
|
|
|
@@ -2690,7 +2699,13 @@ const Editor = (props) => {
|
|
|
2690
2699
|
const [memtionRect, setMemtionRect] = useState(null);
|
|
2691
2700
|
const [memtionKeyword, setMemtionKeyword] = useState("");
|
|
2692
2701
|
const [memtionActiveIndex, setMemtionActiveIndex] = useState(0);
|
|
2693
|
-
const
|
|
2702
|
+
const [activeMemtionIndex, setActiveMemtionIndex] = useState(-1);
|
|
2703
|
+
const memtionOptions = useMemo(() => {
|
|
2704
|
+
if (activeMemtionIndex < 0 || !memtion?.length)
|
|
2705
|
+
return [];
|
|
2706
|
+
const active = memtion?.[activeMemtionIndex];
|
|
2707
|
+
return filterMemtionOptions(active?.options ?? [], memtionKeyword);
|
|
2708
|
+
}, [memtion, memtionKeyword, activeMemtionIndex]);
|
|
2694
2709
|
const sanitizeValue = (nextValue) => {
|
|
2695
2710
|
if (isPlaintextMode) {
|
|
2696
2711
|
return nextValue === "\n" ? "" : nextValue;
|
|
@@ -2745,18 +2760,20 @@ const Editor = (props) => {
|
|
|
2745
2760
|
setMemtionRect(null);
|
|
2746
2761
|
setMemtionKeyword("");
|
|
2747
2762
|
setMemtionActiveIndex(0);
|
|
2763
|
+
setActiveMemtionIndex(-1);
|
|
2748
2764
|
};
|
|
2749
2765
|
const syncEditorState = () => {
|
|
2750
2766
|
selectionRef.current = null;
|
|
2751
2767
|
hideMemtion();
|
|
2752
2768
|
};
|
|
2753
2769
|
const insertMemtion = (option) => {
|
|
2770
|
+
const activeMemtion = memtion?.[activeMemtionIndex];
|
|
2754
2771
|
const replaceRange = getMemtionReplaceRange(memtionTriggerRangeRef.current, selectionRef.current);
|
|
2755
2772
|
const range = insertMemtionOption({
|
|
2756
2773
|
editor: editorRef.current,
|
|
2757
2774
|
range: replaceRange,
|
|
2758
2775
|
mode,
|
|
2759
|
-
memtion,
|
|
2776
|
+
memtion: activeMemtion,
|
|
2760
2777
|
option,
|
|
2761
2778
|
sanitizeValue,
|
|
2762
2779
|
});
|
|
@@ -2792,7 +2809,6 @@ const Editor = (props) => {
|
|
|
2792
2809
|
editorRef.current?.dispatchEvent(new Event("input", { bubbles: true }));
|
|
2793
2810
|
return;
|
|
2794
2811
|
}
|
|
2795
|
-
const memtionKey = memtion?.key ?? "@";
|
|
2796
2812
|
if (memtionVisible && e.key === " ") {
|
|
2797
2813
|
hideMemtion();
|
|
2798
2814
|
}
|
|
@@ -2812,11 +2828,15 @@ const Editor = (props) => {
|
|
|
2812
2828
|
return;
|
|
2813
2829
|
}
|
|
2814
2830
|
}
|
|
2815
|
-
if (memtion
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2831
|
+
if (memtion?.length) {
|
|
2832
|
+
const matchedIndex = memtion.findIndex((m) => e.key === m.key);
|
|
2833
|
+
if (matchedIndex >= 0) {
|
|
2834
|
+
rememberSelection();
|
|
2835
|
+
memtionTriggerRangeRef.current =
|
|
2836
|
+
selectionRef.current?.cloneRange() ?? null;
|
|
2837
|
+
pendingMemtionRef.current = true;
|
|
2838
|
+
setActiveMemtionIndex(matchedIndex);
|
|
2839
|
+
}
|
|
2820
2840
|
}
|
|
2821
2841
|
switch (e.key) {
|
|
2822
2842
|
case "Tab":
|
|
@@ -2864,8 +2884,13 @@ const Editor = (props) => {
|
|
|
2864
2884
|
setEditorValue(nextValue);
|
|
2865
2885
|
}
|
|
2866
2886
|
rememberSelection();
|
|
2867
|
-
if (
|
|
2868
|
-
const
|
|
2887
|
+
if (activeMemtionIndex >= 0 && (pendingMemtionRef.current || memtionVisible)) {
|
|
2888
|
+
const active = memtion?.[activeMemtionIndex];
|
|
2889
|
+
if (!active) {
|
|
2890
|
+
hideMemtion();
|
|
2891
|
+
return;
|
|
2892
|
+
}
|
|
2893
|
+
const memtionKey = active.key ?? "@";
|
|
2869
2894
|
const memtionText = getMemtionText(memtionTriggerRangeRef.current, selectionRef.current);
|
|
2870
2895
|
if (!memtionText.startsWith(memtionKey) || /\s/.test(memtionText)) {
|
|
2871
2896
|
hideMemtion();
|
|
@@ -2920,7 +2945,7 @@ const Editor = (props) => {
|
|
|
2920
2945
|
...style,
|
|
2921
2946
|
[autosize ? "minHeight" : "height"]: height,
|
|
2922
2947
|
width,
|
|
2923
|
-
}, children: [!hideControl && (jsx("div", { className: "i-editor-controls", children: controls })), memtion && (jsx(Memtion$1, { visible: memtionVisible, rect: memtionRect, options: memtionOptions, activeIndex: memtionActiveIndex, onActiveChange: setMemtionActiveIndex, onSelect: insertMemtion })), jsx("div", { ref: handleRef, className: "i-editor-content", "data-placeholder": placeholder, contentEditable: isPlaintextMode ? "plaintext-only" : true, onFocus: handleFocus, onBlur: handleBlur, onMouseUp: handleMouseUp, onPaste: handlePaste, onInput: handleInput, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, ...restProps })] }));
|
|
2948
|
+
}, children: [!hideControl && (jsx("div", { className: "i-editor-controls", children: controls })), memtion?.length && (jsx(Memtion$1, { visible: memtionVisible, rect: memtionRect, options: memtionOptions, activeIndex: memtionActiveIndex, onActiveChange: setMemtionActiveIndex, onSelect: insertMemtion })), jsx("div", { ref: handleRef, className: "i-editor-content", "data-placeholder": placeholder, contentEditable: isPlaintextMode ? "plaintext-only" : true, onFocus: handleFocus, onBlur: handleBlur, onMouseUp: handleMouseUp, onPaste: handlePaste, onInput: handleInput, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, ...restProps })] }));
|
|
2924
2949
|
};
|
|
2925
2950
|
|
|
2926
2951
|
const Flex = (props) => {
|
|
@@ -5231,6 +5256,70 @@ const River = (props) => {
|
|
|
5231
5256
|
})] }) }));
|
|
5232
5257
|
};
|
|
5233
5258
|
|
|
5259
|
+
const Scroll = (props) => {
|
|
5260
|
+
const { style, className, draggable, onScroll, children, ...restProps } = props;
|
|
5261
|
+
const scrollRef = useRef(null);
|
|
5262
|
+
const [dragging, setDragging] = useState(false);
|
|
5263
|
+
const dragState = useRef({ down: false, startX: 0, scrollLeft: 0 });
|
|
5264
|
+
useEffect(() => {
|
|
5265
|
+
const el = scrollRef.current;
|
|
5266
|
+
if (!el)
|
|
5267
|
+
return;
|
|
5268
|
+
const onWheel = (e) => {
|
|
5269
|
+
const canScroll = el.scrollWidth > el.clientWidth + 1;
|
|
5270
|
+
if (!canScroll)
|
|
5271
|
+
return;
|
|
5272
|
+
e.preventDefault();
|
|
5273
|
+
e.stopPropagation();
|
|
5274
|
+
const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY)
|
|
5275
|
+
? e.deltaX
|
|
5276
|
+
: e.deltaY;
|
|
5277
|
+
el.scrollLeft += delta;
|
|
5278
|
+
};
|
|
5279
|
+
const opts = {
|
|
5280
|
+
passive: false,
|
|
5281
|
+
capture: true,
|
|
5282
|
+
};
|
|
5283
|
+
el.addEventListener("wheel", onWheel, opts);
|
|
5284
|
+
return () => el.removeEventListener("wheel", onWheel, opts);
|
|
5285
|
+
}, []);
|
|
5286
|
+
useEffect(() => {
|
|
5287
|
+
if (!draggable)
|
|
5288
|
+
return;
|
|
5289
|
+
const handleMouseMove = (e) => {
|
|
5290
|
+
if (!dragState.current.down || !scrollRef.current)
|
|
5291
|
+
return;
|
|
5292
|
+
const x = e.clientX - dragState.current.startX;
|
|
5293
|
+
scrollRef.current.scrollLeft =
|
|
5294
|
+
dragState.current.scrollLeft - x;
|
|
5295
|
+
};
|
|
5296
|
+
const handleMouseUp = () => {
|
|
5297
|
+
dragState.current.down = false;
|
|
5298
|
+
setDragging(false);
|
|
5299
|
+
};
|
|
5300
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
5301
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
5302
|
+
return () => {
|
|
5303
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
5304
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
5305
|
+
};
|
|
5306
|
+
}, [draggable]);
|
|
5307
|
+
const handleMouseDown = (e) => {
|
|
5308
|
+
if (!draggable || !scrollRef.current)
|
|
5309
|
+
return;
|
|
5310
|
+
setDragging(true);
|
|
5311
|
+
dragState.current = {
|
|
5312
|
+
down: true,
|
|
5313
|
+
startX: e.clientX,
|
|
5314
|
+
scrollLeft: scrollRef.current.scrollLeft,
|
|
5315
|
+
};
|
|
5316
|
+
};
|
|
5317
|
+
return (jsx("div", { ref: scrollRef, className: classNames("i-scroll", className, {
|
|
5318
|
+
"i-scroll-draggable": draggable,
|
|
5319
|
+
"i-scroll-dragging": dragging,
|
|
5320
|
+
}), style: style, onScroll: onScroll, onMouseDown: handleMouseDown, ...restProps, children: children }));
|
|
5321
|
+
};
|
|
5322
|
+
|
|
5234
5323
|
function Divider() {
|
|
5235
5324
|
return jsx("i", { className: 'i-step-divider' });
|
|
5236
5325
|
}
|
|
@@ -6151,7 +6240,7 @@ const normalizeFiles = (files) => (files ?? []).map((item) => {
|
|
|
6151
6240
|
};
|
|
6152
6241
|
});
|
|
6153
6242
|
const Upload = (props) => {
|
|
6154
|
-
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;
|
|
6243
|
+
const { label, labelInline, value, files, placeholder, status = "normal", message, icon = jsx(Icon, { icon: jsx(DriveFolderUploadOutlined, {}) }), 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;
|
|
6155
6244
|
const [internalFileList, setInternalFileList] = useState([]);
|
|
6156
6245
|
const isControlled = useMemo(() => value !== undefined || files !== undefined, [value, files]);
|
|
6157
6246
|
const fileList = isControlled
|
|
@@ -6161,7 +6250,7 @@ const Upload = (props) => {
|
|
|
6161
6250
|
const inputRef = useRef(null);
|
|
6162
6251
|
const preview = usePreview();
|
|
6163
6252
|
const defBtnProps = useMemo(() => ({
|
|
6164
|
-
children:
|
|
6253
|
+
children: jsxs(Fragment, { children: [icon, " \u4E0A\u4F20"] }),
|
|
6165
6254
|
...defaultButtonProps,
|
|
6166
6255
|
}), [defaultButtonProps]);
|
|
6167
6256
|
const trigger = useMemo(() => {
|
|
@@ -6169,11 +6258,11 @@ const Upload = (props) => {
|
|
|
6169
6258
|
return children;
|
|
6170
6259
|
switch (mode) {
|
|
6171
6260
|
case "card":
|
|
6172
|
-
return (jsx(Button, { className: "i-upload-card-btn color-5", square: true, flat: true, outline: true, disabled: disabled, children:
|
|
6261
|
+
return (jsx(Button, { className: "i-upload-card-btn color-5", square: true, flat: true, outline: true, disabled: disabled, children: icon }));
|
|
6173
6262
|
default:
|
|
6174
6263
|
return (jsx(Button, { ...defBtnProps, className: classNames("i-upload-btn", defBtnProps.className), disabled: disabled }));
|
|
6175
6264
|
}
|
|
6176
|
-
}, [mode, children, disabled, defBtnProps]);
|
|
6265
|
+
}, [mode, children, disabled, defBtnProps, icon]);
|
|
6177
6266
|
const handleUpload = useCallback(async (files) => {
|
|
6178
6267
|
if (!uploader)
|
|
6179
6268
|
return;
|
|
@@ -6416,4 +6505,4 @@ const useTheme = (props) => {
|
|
|
6416
6505
|
};
|
|
6417
6506
|
};
|
|
6418
6507
|
|
|
6419
|
-
export { Affix, Badge, Button, Card, Checkbox, Collapse, ColorPicker, Datagrid, Datepicker as DatePicker, Description, Drawer, Dropdown, Editor, Flex, Form, Icon, MemoImage as Image, Input, List$1 as List, Loading, message as Message, Modal, Pagination, Popconfirm, Popup, Progress, Radio, Resizable, River, Select, Step, Swiper, Tabs, Tag, Text, TimePicker, Tree, Upload, Video, usePreview, useTheme };
|
|
6508
|
+
export { Affix, Badge, Button, Card, Checkbox, Collapse, ColorPicker, Datagrid, Datepicker as DatePicker, Description, Drawer, Dropdown, Editor, Flex, Form, Icon, MemoImage as Image, Input, List$1 as List, Loading, message as Message, Modal, Pagination, Popconfirm, Popup, Progress, Radio, Resizable, River, Scroll, Select, Step, Swiper, Tabs, Tag, Text, TimePicker, Tree, Upload, Video, usePreview, useTheme };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IDropdown, IDropItem } from './type.js';
|
|
2
|
-
import * as react from 'react';
|
|
3
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import * as react from 'react';
|
|
4
4
|
|
|
5
5
|
declare const Dropdown: {
|
|
6
6
|
(props: IDropdown): string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode>>;
|
|
@@ -23,7 +23,7 @@ interface IEditor extends Omit<HTMLAttributes<HTMLDivElement>, "onInput" | "onCh
|
|
|
23
23
|
mode?: "rich" | "plaintext" | "plaintextOnMemtion";
|
|
24
24
|
hideControl?: boolean;
|
|
25
25
|
addtionControls?: IEditorAddtionControl[];
|
|
26
|
-
memtion?: IEditorMemtion;
|
|
26
|
+
memtion?: IEditorMemtion[];
|
|
27
27
|
border?: boolean;
|
|
28
28
|
onChange?: (value: string, e: SyntheticEvent<HTMLDivElement>) => void;
|
|
29
29
|
onEnter?: (e: KeyboardEvent<HTMLDivElement>) => void;
|
|
@@ -14,6 +14,7 @@ interface IUpload extends Omit<BaseInput, "ref">, Omit<InputHTMLAttributes<HTMLI
|
|
|
14
14
|
dropbox?: (dragging?: boolean) => ReactNode;
|
|
15
15
|
getDropboxContainer?: () => HTMLElement;
|
|
16
16
|
cardSize?: string;
|
|
17
|
+
icon?: ReactNode;
|
|
17
18
|
defaultButtonProps?: IButton;
|
|
18
19
|
shouldUpload?: (file: IFile) => boolean;
|
|
19
20
|
uploader?: (file: IFile) => Promise<IFile>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { default as Progress } from './components/progress/progress.js';
|
|
|
28
28
|
export { default as Radio } from './components/radio/radio.js';
|
|
29
29
|
export { default as Resizable } from './components/resizable/resizable.js';
|
|
30
30
|
export { default as River } from './components/river/river.js';
|
|
31
|
+
export { default as Scroll } from './components/scroll/scroll.js';
|
|
31
32
|
export { default as Select } from './components/select/select.js';
|
|
32
33
|
export { default as Step } from './components/step/step.js';
|
|
33
34
|
export { default as Swiper } from './components/swiper/swiper.js';
|