ag-common 0.0.270 → 0.0.273
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.
|
@@ -43,7 +43,8 @@ export declare function objectToString(obj: Record<string, string>, joinKeyValue
|
|
|
43
43
|
* @returns
|
|
44
44
|
*/
|
|
45
45
|
export declare const castObject: <TIn, TOut>(orig: Record<string, TIn>, castF: (t: TIn) => TOut) => Record<string, TOut>;
|
|
46
|
-
|
|
46
|
+
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
47
|
+
export declare const removeUndefValuesFromObject: <T>(orig: Record<string, T>, ...additionalRemoves: T[]) => Record<string, T>;
|
|
47
48
|
/**
|
|
48
49
|
* cast Record<string,string[]|string> to Record<string,string>. can be used for querystring params
|
|
49
50
|
* @param orig
|
|
@@ -128,10 +128,13 @@ const castObject = (orig, castF) => {
|
|
|
128
128
|
return ret;
|
|
129
129
|
};
|
|
130
130
|
exports.castObject = castObject;
|
|
131
|
-
|
|
131
|
+
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
132
|
+
const removeUndefValuesFromObject = (orig,
|
|
133
|
+
/** other than null or undefined */
|
|
134
|
+
...additionalRemoves) => {
|
|
132
135
|
const ret = {};
|
|
133
136
|
Object.entries(orig).forEach(([k, v]) => {
|
|
134
|
-
if (v !== null && v !== undefined) {
|
|
137
|
+
if (v !== null && v !== undefined && !(additionalRemoves === null || additionalRemoves === void 0 ? void 0 : additionalRemoves.includes(v))) {
|
|
135
138
|
ret[k] = v;
|
|
136
139
|
}
|
|
137
140
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ITextEdit } from './types';
|
|
2
2
|
import { StyledComponent } from 'styled-components';
|
|
3
3
|
export declare const ValueReadonly: StyledComponent<"div", any, {}, never>;
|
|
4
|
-
export declare const TextEdit: (
|
|
4
|
+
export declare const TextEdit: (p: ITextEdit) => JSX.Element;
|
|
@@ -29,6 +29,7 @@ const common_1 = require("./common");
|
|
|
29
29
|
const LengthBox_1 = require("./LengthBox");
|
|
30
30
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
31
31
|
const common_2 = require("../../styles/common");
|
|
32
|
+
const dom_1 = require("../../helpers/dom");
|
|
32
33
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
33
34
|
const react_1 = __importStar(require("react"));
|
|
34
35
|
exports.ValueReadonly = styled_components_1.default.div `
|
|
@@ -81,7 +82,8 @@ const Icon = styled_components_1.default.div `
|
|
|
81
82
|
filter: saturate(3);
|
|
82
83
|
}
|
|
83
84
|
`;
|
|
84
|
-
const TextEdit = (
|
|
85
|
+
const TextEdit = (p) => {
|
|
86
|
+
const { defaultValue = '', defaultEditing, disableEdit = false, placeholder, className, singleLine = false, noGrow = false, leftContent, onSubmit, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, allowUndo = true, onEscape, maxLength, onKeyDown, } = p;
|
|
85
87
|
const ref = (0, react_1.useRef)(null);
|
|
86
88
|
const taref = (0, react_1.useRef)(null);
|
|
87
89
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
@@ -123,7 +125,7 @@ const TextEdit = ({ defaultValue = '', defaultEditing, disableEdit = false, plac
|
|
|
123
125
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
126
|
}, []);
|
|
125
127
|
if (!editing || disableEdit) {
|
|
126
|
-
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "false", onClick: () => onClickNotEditing === null || onClickNotEditing === void 0 ? void 0 : onClickNotEditing(), "data-pointer": onClickNotEditing ? 'true' : 'false', "data-nogrow": noGrow },
|
|
128
|
+
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "false", onClick: () => onClickNotEditing === null || onClickNotEditing === void 0 ? void 0 : onClickNotEditing(), "data-pointer": onClickNotEditing ? 'true' : 'false', "data-nogrow": noGrow }, (0, dom_1.filterDataProps)(p)),
|
|
127
129
|
leftContent || null,
|
|
128
130
|
react_1.default.createElement(exports.ValueReadonly, { "data-type": "text" }, value || react_1.default.createElement("span", { style: { color: '#ccc' } }, placeholder)),
|
|
129
131
|
react_1.default.createElement(Right, null, !disableEdit && (react_1.default.createElement(Icon, { style: common_1.iconRight, onClick: (e) => {
|
|
@@ -139,7 +141,7 @@ const TextEdit = ({ defaultValue = '', defaultEditing, disableEdit = false, plac
|
|
|
139
141
|
: ValueTextArea;
|
|
140
142
|
return (react_1.default.createElement(ValueBoxEdit, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "true",
|
|
141
143
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
-
ref: ref, tabIndex: -1, "data-nogrow": noGrow },
|
|
144
|
+
ref: ref, tabIndex: -1, "data-nogrow": noGrow }, (0, dom_1.filterDataProps)(p)),
|
|
143
145
|
leftContent || null,
|
|
144
146
|
react_1.default.createElement(Comp, { tabIndex: editing ? 0 : undefined, "data-editing": "true", "data-valuechange": valueChange.toString(), ref: taref, "data-type": "text", value: value, onChange: (v) => {
|
|
145
147
|
setValue(v.currentTarget.value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.273",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"typescript": "4.x"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "7.18.
|
|
33
|
+
"@babel/core": "7.18.6",
|
|
34
34
|
"@storybook/addon-actions": "6.5.9",
|
|
35
35
|
"@storybook/addon-docs": "6.5.9",
|
|
36
36
|
"@storybook/addon-essentials": "6.5.9",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"@types/react": "17.0.43",
|
|
45
45
|
"@types/react-dom": "17.0.14",
|
|
46
46
|
"@types/styled-components": "5.1.25",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
48
|
-
"@typescript-eslint/parser": "5.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "5.30.0",
|
|
48
|
+
"@typescript-eslint/parser": "5.30.0",
|
|
49
49
|
"cross-env": "7.0.3",
|
|
50
50
|
"eslint": "8.18.0",
|
|
51
51
|
"eslint-config-airbnb-typescript": "17.0.0",
|
|
52
52
|
"eslint-config-prettier": "8.5.0",
|
|
53
53
|
"eslint-plugin-import": "2.26.0",
|
|
54
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
55
|
-
"eslint-plugin-prettier": "4.
|
|
56
|
-
"eslint-plugin-react": "7.30.
|
|
54
|
+
"eslint-plugin-jsx-a11y": "6.6.0",
|
|
55
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
56
|
+
"eslint-plugin-react": "7.30.1",
|
|
57
57
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
58
58
|
"prettier": "2.7.1",
|
|
59
59
|
"rimraf": "3.0.2"
|