@propellerads/editable-field 3.0.1 → 3.0.3
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.
|
@@ -13,15 +13,11 @@ var styled = require('styled-components');
|
|
|
13
13
|
var styled__default = _interopDefault(styled);
|
|
14
14
|
var stylevariables = require('@propellerads/stylevariables');
|
|
15
15
|
|
|
16
|
-
function _taggedTemplateLiteralLoose(
|
|
17
|
-
|
|
18
|
-
raw = strings.slice(0);
|
|
19
|
-
}
|
|
20
|
-
strings.raw = raw;
|
|
21
|
-
return strings;
|
|
16
|
+
function _taggedTemplateLiteralLoose(e, t) {
|
|
17
|
+
return t || (t = e.slice(0)), e.raw = t, e;
|
|
22
18
|
}
|
|
23
19
|
|
|
24
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9,
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject0, _templateObject1;
|
|
25
21
|
var spin = /*#__PURE__*/styled.keyframes(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"])));
|
|
26
22
|
var StyledEditableFieldWrapper = /*#__PURE__*/styled__default.div(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: fit-content;\n\n ", "\n"])), function (props) {
|
|
27
23
|
return props.isEditable && styled.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n align-items: flex-end;\n flex-direction: ", ";\n width: 100%;\n "])), props.direction === CONTAINER_DIRECTION.COLUMN ? 'column' : 'row');
|
|
@@ -35,8 +31,8 @@ var StyledEditableFieldInputWrapper = /*#__PURE__*/styled__default.div(_template
|
|
|
35
31
|
var StyledEditableFieldInputSpinner = /*#__PURE__*/styled__default.div(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n\n &:after {\n content: '';\n position: absolute;\n display: block;\n height: 14px;\n width: 14px;\n border: 1px solid;\n border-color: ", " ", " ", ";\n border-radius: 50%;\n animation: ", " 0.5s linear infinite;\n margin-top: -7px;\n }\n"])), stylevariables.white, stylevariables.gray80, stylevariables.gray80, spin);
|
|
36
32
|
var StyledEditableFieldInput = /*#__PURE__*/styled__default.input(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ", "px;\n height: ", "px;\n"])), stylevariables.spacing * 2, stylevariables.lineHeight);
|
|
37
33
|
var StyledEditableFieldValue = /*#__PURE__*/styled__default.div(_templateObject9 || (_templateObject9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ", "px;\n"])), stylevariables.spacing * 2);
|
|
38
|
-
var StyledEditableFieldIcon = /*#__PURE__*/styled__default.div(
|
|
39
|
-
var StyledEditableFieldActions = /*#__PURE__*/styled__default.div(
|
|
34
|
+
var StyledEditableFieldIcon = /*#__PURE__*/styled__default.div(_templateObject0 || (_templateObject0 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n pointer-events: none;\n"])));
|
|
35
|
+
var StyledEditableFieldActions = /*#__PURE__*/styled__default.div(_templateObject1 || (_templateObject1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n margin-top: ", "px;\n\n button {\n margin-left: ", "px;\n width: 36px;\n height: 36px;\n border-radius: ", "px;\n border: solid 1px ", ";\n padding: 0;\n cursor: pointer;\n outline: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n &:hover {\n background-color: #e6e6e6;\n border-color: gray;\n color: #000;\n }\n }\n"])), stylevariables.spacing * 2, stylevariables.spacing * 2, stylevariables.borderRadius, stylevariables.gray80);
|
|
40
36
|
|
|
41
37
|
var EDIT_ICON_COLOR = {
|
|
42
38
|
GRAY: icon.COLOR.GRAY_DARK,
|
|
@@ -91,7 +87,7 @@ var EditableField = function EditableField(_ref) {
|
|
|
91
87
|
onClick: onErrorClick
|
|
92
88
|
}), isLoading && React.createElement(StyledEditableFieldInputSpinner, null), !isEditable && !isLoading && React.createElement(Button__default, {
|
|
93
89
|
elementId: elementId + "-editable-field-icon",
|
|
94
|
-
type: Button.
|
|
90
|
+
type: Button.ButtonType.Plain,
|
|
95
91
|
onClick: onFocus
|
|
96
92
|
}, React.createElement(StyledEditableFieldIcon, {
|
|
97
93
|
className: fieldClassName
|
|
@@ -100,14 +96,14 @@ var EditableField = function EditableField(_ref) {
|
|
|
100
96
|
size: editIconSize
|
|
101
97
|
})))), isEditable && !isLoading && React.createElement(StyledEditableFieldActions, null, React.createElement(Button__default, {
|
|
102
98
|
elementId: elementId + "-editable-field-save",
|
|
103
|
-
type: Button.
|
|
99
|
+
type: Button.ButtonType.Plain,
|
|
104
100
|
onClick: onSave
|
|
105
101
|
}, React.createElement(icon.Check, {
|
|
106
102
|
color: icon.COLOR.GRAY_DARK,
|
|
107
103
|
size: icon.SIZE.SMALL
|
|
108
104
|
})), React.createElement(Button__default, {
|
|
109
105
|
elementId: elementId + "-editable-field-cancel",
|
|
110
|
-
type: Button.
|
|
106
|
+
type: Button.ButtonType.Plain,
|
|
111
107
|
onClick: onCancel
|
|
112
108
|
}, React.createElement(icon.Close, {
|
|
113
109
|
color: icon.COLOR.GRAY_DARK,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable-field.cjs.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editable-field.cjs.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n,i,r,
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n,i,t,r,o,a,l,d,s,c,p,u=e(require("react")),m=require("@propellerads/icon"),g=require("@propellerads/button"),x=e(g),b=e(require("@propellerads/error-label")),E=require("styled-components"),f=e(E),h=require("@propellerads/stylevariables");function v(e,n){return n||(n=e.slice(0)),e.raw=n,e}var C=E.keyframes(n||(n=v(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"]))),y=f.div(i||(i=v(["\n display: flex;\n width: fit-content;\n\n ","\n"])),(function(e){return e.isEditable&&E.css(t||(t=v(["\n align-items: flex-end;\n flex-direction: ",";\n width: 100%;\n "])),e.direction===N.COLUMN?"column":"row")})),I=f.div(r||(r=v(["\n box-shadow: inset 0 0 0 1px transparent;\n transition: box-shadow 0.3s ease, width 0.3s ease;\n border-radius: ","px;\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n padding-right: 4px;\n\n &:hover {\n box-shadow: inset 0 0 0 1px ",";\n }\n\n ","\n\n ","\n"])),h.borderRadius,h.gray80,(function(e){var n;return e.isEditable&&E.css(o||(o=v(["\n box-shadow: inset 0 0 0 1px "," !important;\n width: 100%;\n "])),(null==e||null==(n=e.theme)||null==(n=n.actionColor)?void 0:n.main)||"#1787fc")}),(function(e){return e.isLoading&&E.css(a||(a=v(["\n box-shadow: inset 0 0 0 1px "," !important;\n padding-right: 20px;\n "])),h.gray80)})),L=f.div(l||(l=v(["\n position: relative;\n\n &:after {\n content: '';\n position: absolute;\n display: block;\n height: 14px;\n width: 14px;\n border: 1px solid;\n border-color: "," "," ",";\n border-radius: 50%;\n animation: "," 0.5s linear infinite;\n margin-top: -7px;\n }\n"])),h.white,h.gray80,h.gray80,C),O=f.input(d||(d=v(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ","px;\n height: ","px;\n"])),2*h.spacing,h.lineHeight),w=f.div(s||(s=v(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ","px;\n"])),2*h.spacing),R=f.div(c||(c=v(["\n pointer-events: none;\n"]))),M=f.div(p||(p=v(["\n display: flex;\n margin-top: ","px;\n\n button {\n margin-left: ","px;\n width: 36px;\n height: 36px;\n border-radius: ","px;\n border: solid 1px ",";\n padding: 0;\n cursor: pointer;\n outline: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n &:hover {\n background-color: #e6e6e6;\n border-color: gray;\n color: #000;\n }\n }\n"])),2*h.spacing,2*h.spacing,h.borderRadius,h.gray80),A={GRAY:m.COLOR.GRAY_DARK,BLUE:m.COLOR.BLUE},k={SMALL:m.SIZE.SMALL,MEDIUM:m.SIZE.MEDIUM},N={ROW:"row",COLUMN:"column"};exports.CONTAINER_DIRECTION=N,exports.EDIT_ICON_COLOR=A,exports.EDIT_ICON_SIZE=k,exports.default=function(e){var n=e.value,i=e.errors,t=void 0===i?[]:i,r=e.isLoading,o=e.isEditable,a=e.onFocus,l=e.fieldClassName,d=void 0===l?"":l,s=e.onCancel,c=e.onSave,p=e.onErrorClick,E=void 0===p?void 0:p,f=e.editIconColor,h=void 0===f?A.GRAY:f,v=e.editIconSize,C=void 0===v?k.MEDIUM:v,S=e.containerDirection,D=e.elementId;return u.createElement(y,{isEditable:o,direction:void 0===S?N.COLUMN:S},u.createElement(I,{isEditable:o,isLoading:r},o&&u.createElement(O,{className:d,value:n,disabled:r,onChange:e.onChange}),!o&&u.createElement(w,{className:d,onClick:a},n),t&&u.createElement(b,{elementId:D,errors:t,onClick:E}),r&&u.createElement(L,null),!o&&!r&&u.createElement(x,{elementId:D+"-editable-field-icon",type:g.ButtonType.Plain,onClick:a},u.createElement(R,{className:d},u.createElement(m.Edit,{color:h,size:C})))),o&&!r&&u.createElement(M,null,u.createElement(x,{elementId:D+"-editable-field-save",type:g.ButtonType.Plain,onClick:c},u.createElement(m.Check,{color:m.COLOR.GRAY_DARK,size:m.SIZE.SMALL})),u.createElement(x,{elementId:D+"-editable-field-cancel",type:g.ButtonType.Plain,onClick:s},u.createElement(m.Close,{color:m.COLOR.GRAY_DARK,size:m.SIZE.SMALL}))))};
|
|
2
2
|
//# sourceMappingURL=editable-field.cjs.production.min.js.map
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { COLOR, SIZE, Edit, Check, Close } from '@propellerads/icon';
|
|
3
|
-
import Button, {
|
|
3
|
+
import Button, { ButtonType } from '@propellerads/button';
|
|
4
4
|
import ErrorLabel from '@propellerads/error-label';
|
|
5
5
|
import styled, { css, keyframes } from 'styled-components';
|
|
6
6
|
import { borderRadius, gray80, white, spacing, lineHeight } from '@propellerads/stylevariables';
|
|
7
7
|
|
|
8
|
-
function _taggedTemplateLiteralLoose(
|
|
9
|
-
|
|
10
|
-
raw = strings.slice(0);
|
|
11
|
-
}
|
|
12
|
-
strings.raw = raw;
|
|
13
|
-
return strings;
|
|
8
|
+
function _taggedTemplateLiteralLoose(e, t) {
|
|
9
|
+
return t || (t = e.slice(0)), e.raw = t, e;
|
|
14
10
|
}
|
|
15
11
|
|
|
16
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9,
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject0, _templateObject1;
|
|
17
13
|
var spin = /*#__PURE__*/keyframes(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"])));
|
|
18
14
|
var StyledEditableFieldWrapper = /*#__PURE__*/styled.div(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: fit-content;\n\n ", "\n"])), function (props) {
|
|
19
15
|
return props.isEditable && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n align-items: flex-end;\n flex-direction: ", ";\n width: 100%;\n "])), props.direction === CONTAINER_DIRECTION.COLUMN ? 'column' : 'row');
|
|
@@ -27,8 +23,8 @@ var StyledEditableFieldInputWrapper = /*#__PURE__*/styled.div(_templateObject4 |
|
|
|
27
23
|
var StyledEditableFieldInputSpinner = /*#__PURE__*/styled.div(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n\n &:after {\n content: '';\n position: absolute;\n display: block;\n height: 14px;\n width: 14px;\n border: 1px solid;\n border-color: ", " ", " ", ";\n border-radius: 50%;\n animation: ", " 0.5s linear infinite;\n margin-top: -7px;\n }\n"])), white, gray80, gray80, spin);
|
|
28
24
|
var StyledEditableFieldInput = /*#__PURE__*/styled.input(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ", "px;\n height: ", "px;\n"])), spacing * 2, lineHeight);
|
|
29
25
|
var StyledEditableFieldValue = /*#__PURE__*/styled.div(_templateObject9 || (_templateObject9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ", "px;\n"])), spacing * 2);
|
|
30
|
-
var StyledEditableFieldIcon = /*#__PURE__*/styled.div(
|
|
31
|
-
var StyledEditableFieldActions = /*#__PURE__*/styled.div(
|
|
26
|
+
var StyledEditableFieldIcon = /*#__PURE__*/styled.div(_templateObject0 || (_templateObject0 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n pointer-events: none;\n"])));
|
|
27
|
+
var StyledEditableFieldActions = /*#__PURE__*/styled.div(_templateObject1 || (_templateObject1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n margin-top: ", "px;\n\n button {\n margin-left: ", "px;\n width: 36px;\n height: 36px;\n border-radius: ", "px;\n border: solid 1px ", ";\n padding: 0;\n cursor: pointer;\n outline: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n &:hover {\n background-color: #e6e6e6;\n border-color: gray;\n color: #000;\n }\n }\n"])), spacing * 2, spacing * 2, borderRadius, gray80);
|
|
32
28
|
|
|
33
29
|
var EDIT_ICON_COLOR = {
|
|
34
30
|
GRAY: COLOR.GRAY_DARK,
|
|
@@ -83,7 +79,7 @@ var EditableField = function EditableField(_ref) {
|
|
|
83
79
|
onClick: onErrorClick
|
|
84
80
|
}), isLoading && React.createElement(StyledEditableFieldInputSpinner, null), !isEditable && !isLoading && React.createElement(Button, {
|
|
85
81
|
elementId: elementId + "-editable-field-icon",
|
|
86
|
-
type:
|
|
82
|
+
type: ButtonType.Plain,
|
|
87
83
|
onClick: onFocus
|
|
88
84
|
}, React.createElement(StyledEditableFieldIcon, {
|
|
89
85
|
className: fieldClassName
|
|
@@ -92,14 +88,14 @@ var EditableField = function EditableField(_ref) {
|
|
|
92
88
|
size: editIconSize
|
|
93
89
|
})))), isEditable && !isLoading && React.createElement(StyledEditableFieldActions, null, React.createElement(Button, {
|
|
94
90
|
elementId: elementId + "-editable-field-save",
|
|
95
|
-
type:
|
|
91
|
+
type: ButtonType.Plain,
|
|
96
92
|
onClick: onSave
|
|
97
93
|
}, React.createElement(Check, {
|
|
98
94
|
color: COLOR.GRAY_DARK,
|
|
99
95
|
size: SIZE.SMALL
|
|
100
96
|
})), React.createElement(Button, {
|
|
101
97
|
elementId: elementId + "-editable-field-cancel",
|
|
102
|
-
type:
|
|
98
|
+
type: ButtonType.Plain,
|
|
103
99
|
onClick: onCancel
|
|
104
100
|
}, React.createElement(Close, {
|
|
105
101
|
color: COLOR.GRAY_DARK,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable-field.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editable-field.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/editable-field",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "EditableField component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/editable-field.esm.js",
|
|
@@ -14,22 +14,21 @@
|
|
|
14
14
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"prepublishOnly": "tsdx build",
|
|
18
17
|
"start": "tsdx watch",
|
|
19
18
|
"build": "tsdx build"
|
|
20
19
|
},
|
|
21
20
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
22
21
|
"private": false,
|
|
23
22
|
"dependencies": {
|
|
24
|
-
"@propellerads/button": "^
|
|
25
|
-
"@propellerads/error-label": "
|
|
26
|
-
"@propellerads/icon": "^
|
|
27
|
-
"@propellerads/stylevariables": "^
|
|
23
|
+
"@propellerads/button": "^9.0.0",
|
|
24
|
+
"@propellerads/error-label": "^5.0.0",
|
|
25
|
+
"@propellerads/icon": "^6.0.2",
|
|
26
|
+
"@propellerads/stylevariables": "^2.0.2"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
|
-
"tsdx": "
|
|
31
|
-
"tslib": "
|
|
32
|
-
"typescript": "
|
|
29
|
+
"tsdx": "0.14.1",
|
|
30
|
+
"tslib": "2.6.2",
|
|
31
|
+
"typescript": "4.9.5"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"styled-components": "5.1.1",
|