@neko-os/ui 0.6.0 → 0.6.2
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/dist/components/inputs/upload/Upload.js +7 -5
- package/dist/components/inputs/upload/Upload.native.js +6 -4
- package/dist/components/structure/popover/PopoverContent.js +3 -3
- package/dist/responsive/responsiveHooks.js +4 -1
- package/package.json +1 -1
- package/src/components/inputs/upload/Upload.js +5 -3
- package/src/components/inputs/upload/Upload.native.js +5 -3
- package/src/components/structure/popover/PopoverContent.js +1 -1
- package/src/responsive/responsiveHooks.js +6 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/inputs/upload/Upload.js";var _excluded = ["children", "onChange", "onUpload", "value", "accept", "multiple", "maxCount", "disabled", "dnd"];function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import React, { useRef, useState, useCallback } from 'react';
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/inputs/upload/Upload.js";var _excluded = ["children", "onChange", "onUpload", "value", "accept", "multiple", "maxCount", "disabled", "dnd", "onAddPress"];function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import React, { useRef, useState, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import { View } from "../../structure/View";
|
|
4
4
|
import { useUploadState } from "./useUploadState";import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -13,16 +13,18 @@ function normalizeFile(file) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function Upload(_ref) {var children = _ref.children,onChange = _ref.onChange,onUpload = _ref.onUpload,valueProp = _ref.value,accept = _ref.accept,_ref$multiple = _ref.multiple,multiple = _ref$multiple === void 0 ? false : _ref$multiple,maxCount = _ref.maxCount,_ref$disabled = _ref.disabled,disabled = _ref$disabled === void 0 ? false : _ref$disabled,_ref$dnd = _ref.dnd,dnd = _ref$dnd === void 0 ? true : _ref$dnd,props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
export function Upload(_ref) {var children = _ref.children,onChange = _ref.onChange,onUpload = _ref.onUpload,valueProp = _ref.value,accept = _ref.accept,_ref$multiple = _ref.multiple,multiple = _ref$multiple === void 0 ? false : _ref$multiple,maxCount = _ref.maxCount,_ref$disabled = _ref.disabled,disabled = _ref$disabled === void 0 ? false : _ref$disabled,_ref$dnd = _ref.dnd,dnd = _ref$dnd === void 0 ? true : _ref$dnd,onAddPress = _ref.onAddPress,props = _objectWithoutProperties(_ref, _excluded);
|
|
17
17
|
var _useUploadState = useUploadState({ onUpload: onUpload, onChange: onChange, multiple: multiple, maxCount: maxCount, value: valueProp }),value = _useUploadState.value,addFiles = _useUploadState.addFiles,remove = _useUploadState.remove;
|
|
18
18
|
var inputRef = useRef();
|
|
19
19
|
var _useState = useState(false),_useState2 = _slicedToArray(_useState, 2),isDragging = _useState2[0],setIsDragging = _useState2[1];
|
|
20
20
|
var dragCounter = useRef(0);
|
|
21
21
|
|
|
22
|
-
var handleClick = useCallback(function () {
|
|
22
|
+
var handleClick = useCallback(function () {
|
|
23
23
|
if (disabled) return;
|
|
24
|
-
(_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.click();
|
|
25
|
-
|
|
24
|
+
var open = function open() {var _inputRef$current;return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.click();};
|
|
25
|
+
if (onAddPress) return onAddPress(open);
|
|
26
|
+
open();
|
|
27
|
+
}, [disabled, onAddPress]);
|
|
26
28
|
|
|
27
29
|
var handleInputChange = useCallback(
|
|
28
30
|
function (e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/inputs/upload/Upload.native.js";var _excluded = ["children", "onChange", "onUpload", "value", "accept", "multiple", "maxCount", "disabled", "persistTo", "saveToLibrary", "compress"];function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import React, { useState, useCallback } from 'react';
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/inputs/upload/Upload.native.js";var _excluded = ["children", "onChange", "onUpload", "value", "accept", "multiple", "maxCount", "disabled", "onAddPress", "persistTo", "saveToLibrary", "compress"];function asyncGeneratorStep(n, t, e, r, o, a, c) {try {var i = n[a](c),u = i.value;} catch (n) {return void e(n);}i.done ? t(u) : Promise.resolve(u).then(r, o);}function _asyncToGenerator(n) {return function () {var t = this,e = arguments;return new Promise(function (r, o) {var a = n.apply(t, e);function _next(n) {asyncGeneratorStep(a, r, o, _next, _throw, "next", n);}function _throw(n) {asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);}_next(void 0);});};}function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import React, { useState, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import { BottomDrawer } from "../../modals/bottomDrawer";
|
|
4
4
|
import { Icon } from "../../presentation/Icon";
|
|
@@ -43,7 +43,7 @@ function getMediaTypes(accept) {
|
|
|
43
43
|
return undefined;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function Upload(_ref) {var children = _ref.children,onChange = _ref.onChange,onUpload = _ref.onUpload,valueProp = _ref.value,accept = _ref.accept,_ref$multiple = _ref.multiple,multiple = _ref$multiple === void 0 ? false : _ref$multiple,maxCount = _ref.maxCount,_ref$disabled = _ref.disabled,disabled = _ref$disabled === void 0 ? false : _ref$disabled,persistTo = _ref.persistTo,saveToLibrary = _ref.saveToLibrary,_ref$compress = _ref.compress,compress = _ref$compress === void 0 ? true : _ref$compress,props = _objectWithoutProperties(_ref, _excluded);
|
|
46
|
+
export function Upload(_ref) {var children = _ref.children,onChange = _ref.onChange,onUpload = _ref.onUpload,valueProp = _ref.value,accept = _ref.accept,_ref$multiple = _ref.multiple,multiple = _ref$multiple === void 0 ? false : _ref$multiple,maxCount = _ref.maxCount,_ref$disabled = _ref.disabled,disabled = _ref$disabled === void 0 ? false : _ref$disabled,onAddPress = _ref.onAddPress,persistTo = _ref.persistTo,saveToLibrary = _ref.saveToLibrary,_ref$compress = _ref.compress,compress = _ref$compress === void 0 ? true : _ref$compress,props = _objectWithoutProperties(_ref, _excluded);
|
|
47
47
|
var _useUploadState = useUploadState({ onUpload: onUpload, onChange: onChange, multiple: multiple, maxCount: maxCount, value: valueProp }),value = _useUploadState.value,addFiles = _useUploadState.addFiles,remove = _useUploadState.remove;
|
|
48
48
|
var _useState = useState(false),_useState2 = _slicedToArray(_useState, 2),open = _useState2[0],setOpen = _useState2[1];
|
|
49
49
|
|
|
@@ -62,8 +62,10 @@ export function Upload(_ref) {var children = _ref.children,onChange = _ref.onCha
|
|
|
62
62
|
|
|
63
63
|
var handlePress = useCallback(function () {
|
|
64
64
|
if (disabled) return;
|
|
65
|
-
setOpen(true);
|
|
66
|
-
|
|
65
|
+
var open = function open() {return setOpen(true);};
|
|
66
|
+
if (onAddPress) return onAddPress(open);
|
|
67
|
+
open();
|
|
68
|
+
}, [disabled, onAddPress]);
|
|
67
69
|
|
|
68
70
|
|
|
69
71
|
|
|
@@ -8,9 +8,9 @@ export function PopoverContent(_ref) {var children = _ref.children,_ref$placemen
|
|
|
8
8
|
br: "sm",
|
|
9
9
|
className: "neko-popover-content",
|
|
10
10
|
bg: "overlayBG",
|
|
11
|
-
border: true,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
border: true },
|
|
12
|
+
props, {
|
|
13
|
+
borderColor: "divider", children:
|
|
14
14
|
|
|
15
15
|
children })
|
|
16
16
|
));
|
|
@@ -30,6 +30,8 @@ export function useGetResponsiveValue() {
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
|
|
34
|
+
|
|
33
35
|
var bpNames = breakpoints.map(function (b) {return b.name;});
|
|
34
36
|
var isResponsiveKey = function isResponsiveKey(k) {return (
|
|
35
37
|
k === 'df' ||
|
|
@@ -39,7 +41,8 @@ export function useGetResponsiveValue() {
|
|
|
39
41
|
k === 'android' ||
|
|
40
42
|
bpNames.includes(k) ||
|
|
41
43
|
/^(\w+)[du]$/.test(k) && bpNames.includes(k.slice(0, -1)));};
|
|
42
|
-
|
|
44
|
+
var objKeys = Object.keys(value);
|
|
45
|
+
if (objKeys.length > 0 && !objKeys.some(isResponsiveKey)) return value;
|
|
43
46
|
|
|
44
47
|
if (value[screen]) return value[screen];
|
|
45
48
|
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ function normalizeFile(file) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function Upload({ children, onChange, onUpload, value: valueProp, accept, multiple = false, maxCount, disabled = false, dnd = true, ...props }) {
|
|
16
|
+
export function Upload({ children, onChange, onUpload, value: valueProp, accept, multiple = false, maxCount, disabled = false, dnd = true, onAddPress, ...props }) {
|
|
17
17
|
const { value, addFiles, remove } = useUploadState({ onUpload, onChange, multiple, maxCount, value: valueProp })
|
|
18
18
|
const inputRef = useRef()
|
|
19
19
|
const [isDragging, setIsDragging] = useState(false)
|
|
@@ -21,8 +21,10 @@ export function Upload({ children, onChange, onUpload, value: valueProp, accept,
|
|
|
21
21
|
|
|
22
22
|
const handleClick = useCallback(() => {
|
|
23
23
|
if (disabled) return
|
|
24
|
-
inputRef.current?.click()
|
|
25
|
-
|
|
24
|
+
const open = () => inputRef.current?.click()
|
|
25
|
+
if (onAddPress) return onAddPress(open)
|
|
26
|
+
open()
|
|
27
|
+
}, [disabled, onAddPress])
|
|
26
28
|
|
|
27
29
|
const handleInputChange = useCallback(
|
|
28
30
|
(e) => {
|
|
@@ -43,7 +43,7 @@ function getMediaTypes(accept) {
|
|
|
43
43
|
return undefined
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function Upload({ children, onChange, onUpload, value: valueProp, accept, multiple = false, maxCount, disabled = false, persistTo, saveToLibrary, compress = true, ...props }) {
|
|
46
|
+
export function Upload({ children, onChange, onUpload, value: valueProp, accept, multiple = false, maxCount, disabled = false, onAddPress, persistTo, saveToLibrary, compress = true, ...props }) {
|
|
47
47
|
const { value, addFiles, remove } = useUploadState({ onUpload, onChange, multiple, maxCount, value: valueProp })
|
|
48
48
|
const [open, setOpen] = useState(false)
|
|
49
49
|
|
|
@@ -62,8 +62,10 @@ export function Upload({ children, onChange, onUpload, value: valueProp, accept,
|
|
|
62
62
|
|
|
63
63
|
const handlePress = useCallback(() => {
|
|
64
64
|
if (disabled) return
|
|
65
|
-
setOpen(true)
|
|
66
|
-
|
|
65
|
+
const open = () => setOpen(true)
|
|
66
|
+
if (onAddPress) return onAddPress(open)
|
|
67
|
+
open()
|
|
68
|
+
}, [disabled, onAddPress])
|
|
67
69
|
|
|
68
70
|
// NOTE: keep the drawer OPEN while presenting the native picker, and close it
|
|
69
71
|
// only after the picker returns. The drawer is a RN <Modal>; closing it first
|
|
@@ -28,8 +28,10 @@ export function useGetResponsiveValue() {
|
|
|
28
28
|
if (!isObj) return value
|
|
29
29
|
|
|
30
30
|
// Only treat the object as a responsive descriptor when it actually
|
|
31
|
-
// carries breakpoint / platform / df keys.
|
|
32
|
-
//
|
|
31
|
+
// carries breakpoint / platform / df keys. A non-empty plain object
|
|
32
|
+
// (e.g. titleProps) passes through untouched. An empty object carries
|
|
33
|
+
// no info either way, so it falls through to the df (undefined) result
|
|
34
|
+
// instead of returning itself truthy.
|
|
33
35
|
const bpNames = breakpoints.map((b) => b.name)
|
|
34
36
|
const isResponsiveKey = (k) =>
|
|
35
37
|
k === 'df' ||
|
|
@@ -39,7 +41,8 @@ export function useGetResponsiveValue() {
|
|
|
39
41
|
k === 'android' ||
|
|
40
42
|
bpNames.includes(k) ||
|
|
41
43
|
(/^(\w+)[du]$/.test(k) && bpNames.includes(k.slice(0, -1)))
|
|
42
|
-
|
|
44
|
+
const objKeys = Object.keys(value)
|
|
45
|
+
if (objKeys.length > 0 && !objKeys.some(isResponsiveKey)) return value
|
|
43
46
|
|
|
44
47
|
if (value[screen]) return value[screen]
|
|
45
48
|
|