ag-common 0.0.154 → 0.0.155

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.
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { StyledComponent } from 'styled-components';
3
3
  export declare const ValueReadonly: StyledComponent<"div", any, {}, never>;
4
- export declare const TextEdit: ({ defaultValue, defaultEditing, onSubmit, disableEdit, placeholder, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, className, singleLine, noGrow, }: {
4
+ export declare const TextEdit: ({ defaultValue, defaultEditing, onSubmit, disableEdit, placeholder, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, className, singleLine, noGrow, attributes, }: {
5
5
  /**
6
6
  * forces single row input style. will also enable 'Enter' to auto submit
7
7
  */
@@ -27,4 +27,8 @@ export declare const TextEdit: ({ defaultValue, defaultEditing, onSubmit, disabl
27
27
  * if true, will not grow. default false
28
28
  */
29
29
  noGrow?: boolean | undefined;
30
+ /**
31
+ * will set these attributes directly on element. can put data-* here
32
+ */
33
+ attributes?: Record<string, string | number | boolean> | undefined;
30
34
  }) => JSX.Element;
@@ -69,7 +69,7 @@ const Icon = styled_components_1.default.div `
69
69
  filter: saturate(3);
70
70
  }
71
71
  `;
72
- const TextEdit = ({ defaultValue, defaultEditing, onSubmit, disableEdit = false, placeholder, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, className, singleLine = false, noGrow = false, }) => {
72
+ const TextEdit = ({ defaultValue, defaultEditing, onSubmit, disableEdit = false, placeholder, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, className, singleLine = false, noGrow = false, attributes, }) => {
73
73
  const ref = (0, react_1.useRef)(null);
74
74
  const taref = (0, react_1.useRef)(null);
75
75
  const [value, setValue] = (0, react_1.useState)(defaultValue);
@@ -107,7 +107,7 @@ const TextEdit = ({ defaultValue, defaultEditing, onSubmit, disableEdit = false,
107
107
  // eslint-disable-next-line react-hooks/exhaustive-deps
108
108
  }, [defaultEditing]);
109
109
  if (!editing || disableEdit) {
110
- 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 }),
110
+ 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 }, attributes),
111
111
  react_1.default.createElement(exports.ValueReadonly, { "data-type": "text" }, value),
112
112
  react_1.default.createElement(Right, null, !disableEdit && (react_1.default.createElement(Icon, { style: common_1.iconRight, onClick: (e) => {
113
113
  e.stopPropagation();
@@ -125,7 +125,7 @@ const TextEdit = ({ defaultValue, defaultEditing, onSubmit, disableEdit = false,
125
125
  : ValueTextArea;
126
126
  return (react_1.default.createElement(ValueBoxEdit, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "true",
127
127
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
- ref: ref, tabIndex: editing ? 0 : undefined, "data-nogrow": noGrow }),
128
+ ref: ref, tabIndex: editing ? 0 : undefined, "data-nogrow": noGrow }, attributes),
129
129
  react_1.default.createElement(Comp, { "data-editing": "true", "data-valuechange": valueChange.toString(), ref: taref, "data-type": "text", value: value, onChange: (v) => setValue(v.currentTarget.value), placeholder: placeholder, rows: singleLine ? 1 : undefined, onKeyDown: (e) => singleLine &&
130
130
  e.code.endsWith('Enter') &&
131
131
  onSubmit(value, true) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.154",
3
+ "version": "0.0.155",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",