@neko-os/ui 0.5.2 → 0.5.4
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/README.md +2 -0
- package/dist/abstractions/Image.native.js +1 -1
- package/dist/abstractions/Image.web.js +1 -1
- package/dist/components/form/FormItem.js +1 -0
- package/dist/components/form/useNewForm.js +41 -1
- package/dist/components/inputs/InputWrapper.js +12 -11
- package/dist/components/inputs/SegmentedPicker.js +3 -2
- package/dist/components/presentation/Avatar.js +3 -3
- package/dist/modifiers/flex.js +8 -3
- package/dist/theme/default/blackTheme.js +3 -1
- package/dist/theme/default/cyberpunkTheme.js +3 -1
- package/dist/theme/default/darkTheme.js +3 -1
- package/dist/theme/default/hackerTheme.js +3 -1
- package/dist/theme/default/lightTheme.js +3 -1
- package/dist/theme/default/paperTheme.js +3 -1
- package/package.json +1 -1
- package/src/abstractions/Image.native.js +1 -1
- package/src/abstractions/Image.web.js +1 -1
- package/src/components/form/FormItem.js +1 -0
- package/src/components/form/useNewForm.js +40 -0
- package/src/components/inputs/InputWrapper.js +3 -2
- package/src/components/inputs/SegmentedPicker.js +2 -1
- package/src/components/presentation/Avatar.js +2 -2
- package/src/modifiers/flex.js +7 -2
- package/src/theme/default/blackTheme.js +2 -0
- package/src/theme/default/cyberpunkTheme.js +2 -0
- package/src/theme/default/darkTheme.js +2 -0
- package/src/theme/default/hackerTheme.js +2 -0
- package/src/theme/default/lightTheme.js +2 -0
- package/src/theme/default/paperTheme.js +2 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/abstractions/Image.native.js";var _excluded = ["src", "source", "resizeMode"];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 { Image as RNImage } from "react-native-web";import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
export function AbsImage(_ref) {var src = _ref.src,source = _ref.source,_ref$resizeMode = _ref.resizeMode,resizeMode = _ref$resizeMode === void 0 ? 'cover' : _ref$resizeMode,props = _objectWithoutProperties(_ref, _excluded);
|
|
4
|
-
if (!source &&
|
|
4
|
+
if (!source && src != null) source = typeof src === 'string' ? { uri: src } : src;
|
|
5
5
|
|
|
6
6
|
return _jsx(RNImage, Object.assign({ source: source, resizeMode: resizeMode }, props));
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/abstractions/Image.web.js";var _excluded = ["src", "source", "resizeMode"];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 { Image as RNImage } from "react-native-web";import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
export function AbsImage(_ref) {var src = _ref.src,source = _ref.source,_ref$resizeMode = _ref.resizeMode,resizeMode = _ref$resizeMode === void 0 ? 'cover' : _ref$resizeMode,props = _objectWithoutProperties(_ref, _excluded);
|
|
4
|
-
if (!source &&
|
|
4
|
+
if (!source && src != null) source = typeof src === 'string' ? { uri: src } : src;
|
|
5
5
|
|
|
6
6
|
return _jsx(RNImage, Object.assign({ source: source, resizeMode: resizeMode }, props));
|
|
7
7
|
}
|
|
@@ -62,6 +62,7 @@ export function FormItem(_ref)
|
|
|
62
62
|
|
|
63
63
|
var handleBlur = function handleBlur(e, originalOnBlur) {
|
|
64
64
|
if (originalOnBlur) originalOnBlur(e);
|
|
65
|
+
form.markTouched(listPath);
|
|
65
66
|
|
|
66
67
|
if (shouldValidateOn('onBlur', rules, validateTrigger)) {
|
|
67
68
|
form.validateField(listPath, 'onBlur');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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
|
|
1
|
+
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 _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 _toConsumableArray(r) {return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();}function _nonIterableSpread() {throw new TypeError("Invalid attempt to spread 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 _iterableToArray(r) {if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);}function _arrayWithoutHoles(r) {if (Array.isArray(r)) return _arrayLikeToArray(r);}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;}import { assocPath, path } from 'ramda';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { validateRules, validateAllFields, normalizeRules } from "./validation";
|
|
4
4
|
|
|
@@ -6,6 +6,8 @@ export function useNewForm() {var _ref = arguments.length > 0 && arguments[0] !=
|
|
|
6
6
|
var valuesRef = React.useRef(Object.assign({}, initialValues));
|
|
7
7
|
var initialValuesRef = React.useRef(Object.assign({}, initialValues));
|
|
8
8
|
var errorsRef = React.useRef({});
|
|
9
|
+
var touchedRef = React.useRef(new Set());
|
|
10
|
+
var dirtyRef = React.useRef(new Set());
|
|
9
11
|
var listenersRef = React.useRef({});
|
|
10
12
|
var errorListenersRef = React.useRef({});
|
|
11
13
|
var rulesRegistryRef = React.useRef(new Map());
|
|
@@ -45,8 +47,39 @@ export function useNewForm() {var _ref = arguments.length > 0 && arguments[0] !=
|
|
|
45
47
|
});
|
|
46
48
|
};
|
|
47
49
|
|
|
50
|
+
var markTouched = function markTouched(name) {
|
|
51
|
+
touchedRef.current.add(toKey(name));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var updateDirty = function updateDirty(name) {
|
|
55
|
+
var key = toKey(name);
|
|
56
|
+
var current = path(toPath(name), valuesRef.current);
|
|
57
|
+
var initial = path(toPath(name), initialValuesRef.current);
|
|
58
|
+
if (current === initial) {
|
|
59
|
+
dirtyRef.current.delete(key);
|
|
60
|
+
} else {
|
|
61
|
+
dirtyRef.current.add(key);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var isTouched = function isTouched(name) {
|
|
66
|
+
if (!name) return touchedRef.current.size > 0;
|
|
67
|
+
if (Array.isArray(name)) return name.some(function (n) {return touchedRef.current.has(toKey(n));});
|
|
68
|
+
return touchedRef.current.has(toKey(name));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
var isDirty = function isDirty(name) {
|
|
72
|
+
if (!name) return dirtyRef.current.size > 0;
|
|
73
|
+
if (Array.isArray(name)) return name.some(function (n) {return dirtyRef.current.has(toKey(n));});
|
|
74
|
+
return dirtyRef.current.has(toKey(name));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var getTouchedFields = function getTouchedFields() {return _toConsumableArray(touchedRef.current);};
|
|
78
|
+
var getDirtyFields = function getDirtyFields() {return _toConsumableArray(dirtyRef.current);};
|
|
79
|
+
|
|
48
80
|
var setFieldValue = function setFieldValue(name, value) {
|
|
49
81
|
valuesRef.current = assocPath(toPath(name), value, valuesRef.current);
|
|
82
|
+
updateDirty(name);
|
|
50
83
|
notify(name);
|
|
51
84
|
var fn = callbacksRef.current.onValuesChange;
|
|
52
85
|
if (fn) fn(name, valuesRef.current);
|
|
@@ -69,6 +102,8 @@ export function useNewForm() {var _ref = arguments.length > 0 && arguments[0] !=
|
|
|
69
102
|
var resetFields = function resetFields() {
|
|
70
103
|
valuesRef.current = Object.assign({}, initialValuesRef.current);
|
|
71
104
|
errorsRef.current = {};
|
|
105
|
+
touchedRef.current.clear();
|
|
106
|
+
dirtyRef.current.clear();
|
|
72
107
|
notifyAll();
|
|
73
108
|
notifyAllErrors();
|
|
74
109
|
};
|
|
@@ -196,6 +231,11 @@ export function useNewForm() {var _ref = arguments.length > 0 && arguments[0] !=
|
|
|
196
231
|
getError: getError,
|
|
197
232
|
setError: setError,
|
|
198
233
|
clearErrors: clearErrors,
|
|
234
|
+
markTouched: markTouched,
|
|
235
|
+
isTouched: isTouched,
|
|
236
|
+
isDirty: isDirty,
|
|
237
|
+
getTouchedFields: getTouchedFields,
|
|
238
|
+
getDirtyFields: getDirtyFields,
|
|
199
239
|
registerListener: registerListener,
|
|
200
240
|
registerErrorListener: registerErrorListener,
|
|
201
241
|
registerRules: registerRules,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/inputs/InputWrapper.js";var _excluded = ["prefix", "suffix", "prefixIcon", "prefixIconColor", "suffixIcon", "suffixIconColor", "loading", "error", "multiline", "children", "ref"];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;}
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/inputs/InputWrapper.js";var _excluded = ["prefix", "suffix", "prefixIcon", "prefixIconColor", "suffixIcon", "suffixIconColor", "loading", "error", "multiline", "children", "ref"];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;}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;}import { pipe, is } from 'ramda';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import { Icon } from "../presentation/Icon";
|
|
@@ -9,16 +9,17 @@ import { useDefaultModifier } from "../../modifiers/default";
|
|
|
9
9
|
import { useSizeConverter } from "../../modifiers/sizeConverter";
|
|
10
10
|
import { useThemeComponentModifier } from "../../modifiers/themeComponent";import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
|
-
var DEFAULT_PROPS = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
var DEFAULT_PROPS = function DEFAULT_PROPS(_ref) {var _ref2 = _slicedToArray(_ref, 1),sizeCode = _ref2[0].sizeCode;return {
|
|
13
|
+
paddingH: 'sm',
|
|
14
|
+
bg: 'overlayBG',
|
|
15
|
+
border: true,
|
|
16
|
+
br: 'md',
|
|
17
|
+
row: true,
|
|
18
|
+
gap: 'sm',
|
|
19
|
+
br: sizeCode
|
|
20
|
+
};};
|
|
20
21
|
|
|
21
|
-
export function InputWrapper(
|
|
22
|
+
export function InputWrapper(_ref3)
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
|
|
@@ -31,7 +32,7 @@ export function InputWrapper(_ref)
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
34
|
-
{var prefix =
|
|
35
|
+
{var prefix = _ref3.prefix,suffix = _ref3.suffix,prefixIcon = _ref3.prefixIcon,prefixIconColor = _ref3.prefixIconColor,suffixIcon = _ref3.suffixIcon,suffixIconColor = _ref3.suffixIconColor,loading = _ref3.loading,error = _ref3.error,multiline = _ref3.multiline,children = _ref3.children,ref = _ref3.ref,rootProps = _objectWithoutProperties(_ref3, _excluded);
|
|
35
36
|
var _React$useState = React.useState(false),_React$useState2 = _slicedToArray(_React$useState, 2),hover = _React$useState2[0],setHover = _React$useState2[1];
|
|
36
37
|
var fallbackInputRef = React.useRef();
|
|
37
38
|
var inputRef = ref || fallbackInputRef;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/presentation/Avatar.js";var _excluded = ["initials", "name", "icon", "src", "invert", "textProps", "iconProps", "iconSize"];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;}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;}import { pipe } from 'ramda';
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/presentation/Avatar.js";var _excluded = ["initials", "name", "icon", "src", "invert", "textProps", "iconProps", "iconSize", "imageProps"];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;}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;}import { pipe } from 'ramda';
|
|
2
2
|
|
|
3
3
|
import { AbsView } from "../../abstractions/View";
|
|
4
4
|
import { IconLabel } from "./IconLabel";
|
|
@@ -54,7 +54,7 @@ export function Avatar(rootProps) {
|
|
|
54
54
|
useOverflowModifier
|
|
55
55
|
)([{}, rootProps]),_pipe2 = _slicedToArray(_pipe, 2),_pipe2$ = _pipe2[0],fontColor = _pipe2$.fontColor,sizeCode = _pipe2$.sizeCode,formattedProps = _pipe2[1];
|
|
56
56
|
|
|
57
|
-
var initials = formattedProps.initials,name = formattedProps.name,icon = formattedProps.icon,src = formattedProps.src,invert = formattedProps.invert,textProps = formattedProps.textProps,iconProps = formattedProps.iconProps,iconSize = formattedProps.iconSize,props = _objectWithoutProperties(formattedProps, _excluded);
|
|
57
|
+
var initials = formattedProps.initials,name = formattedProps.name,icon = formattedProps.icon,src = formattedProps.src,invert = formattedProps.invert,textProps = formattedProps.textProps,iconProps = formattedProps.iconProps,iconSize = formattedProps.iconSize,imageProps = formattedProps.imageProps,props = _objectWithoutProperties(formattedProps, _excluded);
|
|
58
58
|
initials = initials || getInitials(name);
|
|
59
59
|
|
|
60
60
|
var content =
|
|
@@ -69,7 +69,7 @@ export function Avatar(rootProps) {
|
|
|
69
69
|
iconProps: Object.assign({ size: iconSize }, iconProps) }
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
if (!!src) content = _jsx(Image, { br: 0, src: src, width: sizeCode, height: sizeCode });
|
|
72
|
+
if (!!src) content = _jsx(Image, Object.assign({ br: 0, src: src, width: sizeCode, height: sizeCode }, imageProps));
|
|
73
73
|
|
|
74
74
|
return (
|
|
75
75
|
_jsx(AbsView, Object.assign({ className: "neko-avatar" }, props, { children:
|
package/dist/modifiers/flex.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
var _excluded = ["flex"];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;}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;}import { clearProps, flattenStyle } from "./_helpers";
|
|
1
|
+
var _excluded = ["flex", "alignSelf", "selfStretch", "selfCenter", "selfStart", "selfEnd"];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;}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;}import { clearProps, flattenStyle } from "./_helpers";
|
|
2
2
|
|
|
3
3
|
export function useFlexModifier(_ref) {var _ref2 = _slicedToArray(_ref, 2),values = _ref2[0],props = _ref2[1];
|
|
4
|
-
var flex = props.flex,restProps = _objectWithoutProperties(props, _excluded);
|
|
4
|
+
var flex = props.flex,alignSelf = props.alignSelf,selfStretch = props.selfStretch,selfCenter = props.selfCenter,selfStart = props.selfStart,selfEnd = props.selfEnd,restProps = _objectWithoutProperties(props, _excluded);
|
|
5
5
|
|
|
6
6
|
if (flex === true) flex = 1;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
if (selfStretch) alignSelf = 'stretch';
|
|
9
|
+
if (selfCenter) alignSelf = 'center';
|
|
10
|
+
if (selfStart) alignSelf = 'flex-start';
|
|
11
|
+
if (selfEnd) alignSelf = 'flex-end';
|
|
12
|
+
|
|
13
|
+
var style = clearProps({ flex: flex, minWidth: 0, alignSelf: alignSelf });
|
|
9
14
|
|
|
10
15
|
return [
|
|
11
16
|
values, Object.assign({},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Image as RNImage } from 'react-native'
|
|
2
2
|
|
|
3
3
|
export function AbsImage({ src, source, resizeMode = 'cover', ...props }) {
|
|
4
|
-
if (!source &&
|
|
4
|
+
if (!source && src != null) source = typeof src === 'string' ? { uri: src } : src
|
|
5
5
|
|
|
6
6
|
return <RNImage source={source} resizeMode={resizeMode} {...props} />
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Image as RNImage } from 'react-native'
|
|
2
2
|
|
|
3
3
|
export function AbsImage({ src, source, resizeMode = 'cover', ...props }) {
|
|
4
|
-
if (!source &&
|
|
4
|
+
if (!source && src != null) source = typeof src === 'string' ? { uri: src } : src
|
|
5
5
|
|
|
6
6
|
return <RNImage source={source} resizeMode={resizeMode} {...props} />
|
|
7
7
|
}
|
|
@@ -6,6 +6,8 @@ export function useNewForm({ initialValues = {}, validate, onSubmit, onValuesCha
|
|
|
6
6
|
const valuesRef = React.useRef({ ...initialValues })
|
|
7
7
|
const initialValuesRef = React.useRef({ ...initialValues })
|
|
8
8
|
const errorsRef = React.useRef({}) // Flat structure: { 'users': 'error', 'users.0.name': 'error' }
|
|
9
|
+
const touchedRef = React.useRef(new Set())
|
|
10
|
+
const dirtyRef = React.useRef(new Set())
|
|
9
11
|
const listenersRef = React.useRef({})
|
|
10
12
|
const errorListenersRef = React.useRef({})
|
|
11
13
|
const rulesRegistryRef = React.useRef(new Map())
|
|
@@ -45,8 +47,39 @@ export function useNewForm({ initialValues = {}, validate, onSubmit, onValuesCha
|
|
|
45
47
|
})
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
const markTouched = (name) => {
|
|
51
|
+
touchedRef.current.add(toKey(name))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const updateDirty = (name) => {
|
|
55
|
+
const key = toKey(name)
|
|
56
|
+
const current = path(toPath(name), valuesRef.current)
|
|
57
|
+
const initial = path(toPath(name), initialValuesRef.current)
|
|
58
|
+
if (current === initial) {
|
|
59
|
+
dirtyRef.current.delete(key)
|
|
60
|
+
} else {
|
|
61
|
+
dirtyRef.current.add(key)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const isTouched = (name) => {
|
|
66
|
+
if (!name) return touchedRef.current.size > 0
|
|
67
|
+
if (Array.isArray(name)) return name.some((n) => touchedRef.current.has(toKey(n)))
|
|
68
|
+
return touchedRef.current.has(toKey(name))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const isDirty = (name) => {
|
|
72
|
+
if (!name) return dirtyRef.current.size > 0
|
|
73
|
+
if (Array.isArray(name)) return name.some((n) => dirtyRef.current.has(toKey(n)))
|
|
74
|
+
return dirtyRef.current.has(toKey(name))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const getTouchedFields = () => [...touchedRef.current]
|
|
78
|
+
const getDirtyFields = () => [...dirtyRef.current]
|
|
79
|
+
|
|
48
80
|
const setFieldValue = (name, value) => {
|
|
49
81
|
valuesRef.current = assocPath(toPath(name), value, valuesRef.current)
|
|
82
|
+
updateDirty(name)
|
|
50
83
|
notify(name)
|
|
51
84
|
const fn = callbacksRef.current.onValuesChange
|
|
52
85
|
if (fn) fn(name, valuesRef.current)
|
|
@@ -69,6 +102,8 @@ export function useNewForm({ initialValues = {}, validate, onSubmit, onValuesCha
|
|
|
69
102
|
const resetFields = () => {
|
|
70
103
|
valuesRef.current = { ...initialValuesRef.current }
|
|
71
104
|
errorsRef.current = {}
|
|
105
|
+
touchedRef.current.clear()
|
|
106
|
+
dirtyRef.current.clear()
|
|
72
107
|
notifyAll()
|
|
73
108
|
notifyAllErrors()
|
|
74
109
|
}
|
|
@@ -196,6 +231,11 @@ export function useNewForm({ initialValues = {}, validate, onSubmit, onValuesCha
|
|
|
196
231
|
getError,
|
|
197
232
|
setError,
|
|
198
233
|
clearErrors,
|
|
234
|
+
markTouched,
|
|
235
|
+
isTouched,
|
|
236
|
+
isDirty,
|
|
237
|
+
getTouchedFields,
|
|
238
|
+
getDirtyFields,
|
|
199
239
|
registerListener,
|
|
200
240
|
registerErrorListener,
|
|
201
241
|
registerRules,
|
|
@@ -9,14 +9,15 @@ import { useDefaultModifier } from '../../modifiers/default'
|
|
|
9
9
|
import { useSizeConverter } from '../../modifiers/sizeConverter'
|
|
10
10
|
import { useThemeComponentModifier } from '../../modifiers/themeComponent'
|
|
11
11
|
|
|
12
|
-
const DEFAULT_PROPS = {
|
|
12
|
+
const DEFAULT_PROPS = ([{ sizeCode }]) => ({
|
|
13
13
|
paddingH: 'sm',
|
|
14
14
|
bg: 'overlayBG',
|
|
15
15
|
border: true,
|
|
16
16
|
br: 'md',
|
|
17
17
|
row: true,
|
|
18
18
|
gap: 'sm',
|
|
19
|
-
|
|
19
|
+
br: sizeCode,
|
|
20
|
+
})
|
|
20
21
|
|
|
21
22
|
export function InputWrapper({
|
|
22
23
|
prefix,
|
|
@@ -54,7 +54,7 @@ export function Avatar(rootProps) {
|
|
|
54
54
|
useOverflowModifier
|
|
55
55
|
)([{}, rootProps])
|
|
56
56
|
|
|
57
|
-
let { initials, name, icon, src, invert, textProps, iconProps, iconSize, ...props } = formattedProps
|
|
57
|
+
let { initials, name, icon, src, invert, textProps, iconProps, iconSize, imageProps, ...props } = formattedProps
|
|
58
58
|
initials = initials || getInitials(name)
|
|
59
59
|
|
|
60
60
|
let content = (
|
|
@@ -69,7 +69,7 @@ export function Avatar(rootProps) {
|
|
|
69
69
|
iconProps={{ size: iconSize, ...iconProps }}
|
|
70
70
|
/>
|
|
71
71
|
)
|
|
72
|
-
if (!!src) content = <Image br={0} src={src} width={sizeCode} height={sizeCode} />
|
|
72
|
+
if (!!src) content = <Image br={0} src={src} width={sizeCode} height={sizeCode} {...imageProps} />
|
|
73
73
|
|
|
74
74
|
return (
|
|
75
75
|
<AbsView className="neko-avatar" {...props}>
|
package/src/modifiers/flex.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { clearProps, flattenStyle } from './_helpers'
|
|
2
2
|
|
|
3
3
|
export function useFlexModifier([values, props]) {
|
|
4
|
-
let { flex, ...restProps } = props
|
|
4
|
+
let { flex, alignSelf, selfStretch, selfCenter, selfStart, selfEnd, ...restProps } = props
|
|
5
5
|
|
|
6
6
|
if (flex === true) flex = 1
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
if (selfStretch) alignSelf = 'stretch'
|
|
9
|
+
if (selfCenter) alignSelf = 'center'
|
|
10
|
+
if (selfStart) alignSelf = 'flex-start'
|
|
11
|
+
if (selfEnd) alignSelf = 'flex-end'
|
|
12
|
+
|
|
13
|
+
const style = clearProps({ flex, minWidth: 0, alignSelf })
|
|
9
14
|
|
|
10
15
|
return [
|
|
11
16
|
values,
|