@propellerads/editable-field 1.5.0 → 2.1.0
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/CHANGELOG.md +8 -0
- package/dist/Components/EditableField/src/index.d.ts +31 -0
- package/dist/Components/EditableField/src/style.d.ts +16 -0
- package/dist/editable-field.cjs.development.js +119 -0
- package/dist/editable-field.cjs.development.js.map +1 -0
- package/dist/editable-field.cjs.production.min.js +2 -0
- package/dist/editable-field.cjs.production.min.js.map +1 -0
- package/dist/editable-field.esm.js +109 -0
- package/dist/editable-field.esm.js.map +1 -0
- package/dist/index.js +8 -0
- package/package.json +13 -15
- package/dist/index.esm.js +0 -232
- package/dist/index.esm.min.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
### `2.1.0`
|
|
2
|
+
* Updated `@propellerads/error-label` to latest
|
|
3
|
+
|
|
4
|
+
### `2.0.0`
|
|
5
|
+
* migrated to TypeScript
|
|
6
|
+
* new prop "containerDirection" for changing wrapper's flex-direction
|
|
7
|
+
* focused input border can be overwritten via ThemeProvider
|
|
8
|
+
|
|
1
9
|
### `1.5.0`
|
|
2
10
|
* updated peerDependencies
|
|
3
11
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { COLOR, SIZE } from '@propellerads/icon';
|
|
2
|
+
export declare const EDIT_ICON_COLOR: {
|
|
3
|
+
GRAY: COLOR;
|
|
4
|
+
BLUE: COLOR;
|
|
5
|
+
};
|
|
6
|
+
export declare const EDIT_ICON_SIZE: {
|
|
7
|
+
SMALL: SIZE;
|
|
8
|
+
MEDIUM: SIZE;
|
|
9
|
+
};
|
|
10
|
+
export declare const CONTAINER_DIRECTION: {
|
|
11
|
+
ROW: string;
|
|
12
|
+
COLUMN: string;
|
|
13
|
+
};
|
|
14
|
+
interface IProps {
|
|
15
|
+
errors?: string[];
|
|
16
|
+
value: string;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
isEditable: boolean;
|
|
19
|
+
fieldClassName?: string;
|
|
20
|
+
editIconColor?: typeof EDIT_ICON_COLOR[keyof typeof EDIT_ICON_COLOR];
|
|
21
|
+
editIconSize?: typeof EDIT_ICON_SIZE[keyof typeof EDIT_ICON_SIZE];
|
|
22
|
+
containerDirection?: typeof CONTAINER_DIRECTION[keyof typeof CONTAINER_DIRECTION];
|
|
23
|
+
elementId: string;
|
|
24
|
+
onFocus: () => void;
|
|
25
|
+
onCancel: () => void;
|
|
26
|
+
onSave: () => void;
|
|
27
|
+
onChange: () => void;
|
|
28
|
+
onErrorClick?: () => void;
|
|
29
|
+
}
|
|
30
|
+
declare const EditableField: ({ value, errors, isLoading, isEditable, onFocus, fieldClassName, onCancel, onSave, onChange, onErrorClick, editIconColor, editIconSize, containerDirection, elementId, }: IProps) => JSX.Element;
|
|
31
|
+
export default EditableField;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { THEME } from '../../../ThemeComponent/types';
|
|
2
|
+
declare const StyledEditableFieldWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
isEditable: boolean;
|
|
4
|
+
direction: string;
|
|
5
|
+
}, never>;
|
|
6
|
+
declare const StyledEditableFieldInputWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
7
|
+
isEditable: boolean;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
theme: THEME;
|
|
10
|
+
}, never>;
|
|
11
|
+
declare const StyledEditableFieldInputSpinner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
declare const StyledEditableFieldInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
13
|
+
declare const StyledEditableFieldValue: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
14
|
+
declare const StyledEditableFieldIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
15
|
+
declare const StyledEditableFieldActions: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
|
+
export { StyledEditableFieldInputWrapper, StyledEditableFieldInputSpinner, StyledEditableFieldInput, StyledEditableFieldValue, StyledEditableFieldIcon, StyledEditableFieldActions, StyledEditableFieldWrapper, };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var React = _interopDefault(require('react'));
|
|
8
|
+
var icon = require('@propellerads/icon');
|
|
9
|
+
var Button = require('@propellerads/button');
|
|
10
|
+
var Button__default = _interopDefault(Button);
|
|
11
|
+
var ErrorLabel = _interopDefault(require('@propellerads/error-label'));
|
|
12
|
+
var styled = require('styled-components');
|
|
13
|
+
var styled__default = _interopDefault(styled);
|
|
14
|
+
var stylevariables = require('@propellerads/stylevariables');
|
|
15
|
+
|
|
16
|
+
function _taggedTemplateLiteralLoose(strings, raw) {
|
|
17
|
+
if (!raw) {
|
|
18
|
+
raw = strings.slice(0);
|
|
19
|
+
}
|
|
20
|
+
strings.raw = raw;
|
|
21
|
+
return strings;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
25
|
+
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
|
+
var StyledEditableFieldWrapper = /*#__PURE__*/styled__default.div(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: fit-content;\n\n ", "\n"])), function (props) {
|
|
27
|
+
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');
|
|
28
|
+
});
|
|
29
|
+
var StyledEditableFieldInputWrapper = /*#__PURE__*/styled__default.div(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\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"])), stylevariables.borderRadius, stylevariables.gray80, function (props) {
|
|
30
|
+
var _props$theme;
|
|
31
|
+
return props.isEditable && styled.css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n box-shadow: inset 0 0 0 1px ", " !important;\n width: 100%;\n "])), (props == null || (_props$theme = props.theme) == null || (_props$theme = _props$theme.actionColor) == null ? void 0 : _props$theme.main) || '#1787fc');
|
|
32
|
+
}, function (props) {
|
|
33
|
+
return props.isLoading && styled.css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n box-shadow: inset 0 0 0 1px ", " !important;\n padding-right: 20px;\n "])), stylevariables.gray80);
|
|
34
|
+
});
|
|
35
|
+
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
|
+
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
|
+
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(_templateObject10 || (_templateObject10 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n pointer-events: none;\n"])));
|
|
39
|
+
var StyledEditableFieldActions = /*#__PURE__*/styled__default.div(_templateObject11 || (_templateObject11 = /*#__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
|
+
|
|
41
|
+
var EDIT_ICON_COLOR = {
|
|
42
|
+
GRAY: icon.COLOR.GRAY_DARK,
|
|
43
|
+
BLUE: icon.COLOR.BLUE
|
|
44
|
+
};
|
|
45
|
+
var EDIT_ICON_SIZE = {
|
|
46
|
+
SMALL: icon.SIZE.SMALL,
|
|
47
|
+
MEDIUM: icon.SIZE.MEDIUM
|
|
48
|
+
};
|
|
49
|
+
var CONTAINER_DIRECTION = {
|
|
50
|
+
ROW: 'row',
|
|
51
|
+
COLUMN: 'column'
|
|
52
|
+
};
|
|
53
|
+
var EditableField = function EditableField(_ref) {
|
|
54
|
+
var value = _ref.value,
|
|
55
|
+
_ref$errors = _ref.errors,
|
|
56
|
+
errors = _ref$errors === void 0 ? [] : _ref$errors,
|
|
57
|
+
isLoading = _ref.isLoading,
|
|
58
|
+
isEditable = _ref.isEditable,
|
|
59
|
+
onFocus = _ref.onFocus,
|
|
60
|
+
_ref$fieldClassName = _ref.fieldClassName,
|
|
61
|
+
fieldClassName = _ref$fieldClassName === void 0 ? '' : _ref$fieldClassName,
|
|
62
|
+
onCancel = _ref.onCancel,
|
|
63
|
+
onSave = _ref.onSave,
|
|
64
|
+
onChange = _ref.onChange,
|
|
65
|
+
_ref$onErrorClick = _ref.onErrorClick,
|
|
66
|
+
onErrorClick = _ref$onErrorClick === void 0 ? undefined : _ref$onErrorClick,
|
|
67
|
+
_ref$editIconColor = _ref.editIconColor,
|
|
68
|
+
editIconColor = _ref$editIconColor === void 0 ? EDIT_ICON_COLOR.GRAY : _ref$editIconColor,
|
|
69
|
+
_ref$editIconSize = _ref.editIconSize,
|
|
70
|
+
editIconSize = _ref$editIconSize === void 0 ? EDIT_ICON_SIZE.MEDIUM : _ref$editIconSize,
|
|
71
|
+
_ref$containerDirecti = _ref.containerDirection,
|
|
72
|
+
containerDirection = _ref$containerDirecti === void 0 ? CONTAINER_DIRECTION.COLUMN : _ref$containerDirecti,
|
|
73
|
+
elementId = _ref.elementId;
|
|
74
|
+
return React.createElement(StyledEditableFieldWrapper, {
|
|
75
|
+
isEditable: isEditable,
|
|
76
|
+
direction: containerDirection
|
|
77
|
+
}, React.createElement(StyledEditableFieldInputWrapper, {
|
|
78
|
+
isEditable: isEditable,
|
|
79
|
+
isLoading: isLoading
|
|
80
|
+
}, isEditable && React.createElement(StyledEditableFieldInput, {
|
|
81
|
+
className: fieldClassName,
|
|
82
|
+
value: value,
|
|
83
|
+
disabled: isLoading,
|
|
84
|
+
onChange: onChange
|
|
85
|
+
}), !isEditable && React.createElement(StyledEditableFieldValue, {
|
|
86
|
+
onClick: onFocus
|
|
87
|
+
}, value), errors && React.createElement(ErrorLabel, {
|
|
88
|
+
elementId: elementId,
|
|
89
|
+
errors: errors,
|
|
90
|
+
onClick: onErrorClick
|
|
91
|
+
}), isLoading && React.createElement(StyledEditableFieldInputSpinner, null), !isEditable && !isLoading && React.createElement(Button__default, {
|
|
92
|
+
elementId: elementId + "-editable-field-icon",
|
|
93
|
+
type: Button.BUTTON_TYPE.PLAIN,
|
|
94
|
+
onClick: onFocus
|
|
95
|
+
}, React.createElement(StyledEditableFieldIcon, null, React.createElement(icon.Edit, {
|
|
96
|
+
color: editIconColor,
|
|
97
|
+
size: editIconSize
|
|
98
|
+
})))), isEditable && !isLoading && React.createElement(StyledEditableFieldActions, null, React.createElement(Button__default, {
|
|
99
|
+
elementId: elementId + "-editable-field-save",
|
|
100
|
+
type: Button.BUTTON_TYPE.PLAIN,
|
|
101
|
+
onClick: onSave
|
|
102
|
+
}, React.createElement(icon.Check, {
|
|
103
|
+
color: icon.COLOR.GRAY_DARK,
|
|
104
|
+
size: icon.SIZE.SMALL
|
|
105
|
+
})), React.createElement(Button__default, {
|
|
106
|
+
elementId: elementId + "-editable-field-cancel",
|
|
107
|
+
type: Button.BUTTON_TYPE.PLAIN,
|
|
108
|
+
onClick: onCancel
|
|
109
|
+
}, React.createElement(icon.Close, {
|
|
110
|
+
color: icon.COLOR.GRAY_DARK,
|
|
111
|
+
size: icon.SIZE.SMALL
|
|
112
|
+
}))));
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
exports.CONTAINER_DIRECTION = CONTAINER_DIRECTION;
|
|
116
|
+
exports.EDIT_ICON_COLOR = EDIT_ICON_COLOR;
|
|
117
|
+
exports.EDIT_ICON_SIZE = EDIT_ICON_SIZE;
|
|
118
|
+
exports.default = EditableField;
|
|
119
|
+
//# sourceMappingURL=editable-field.cjs.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editable-field.cjs.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +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,t,o,a,l,d,s,c,p,u=e(require("react")),m=require("@propellerads/icon"),E=require("@propellerads/button"),g=e(E),x=e(require("@propellerads/error-label")),b=require("styled-components"),f=e(b),h=require("@propellerads/stylevariables");function v(e,n){return n||(n=e.slice(0)),e.raw=n,e}var C=b.keyframes(n||(n=v(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"]))),I=f.div(i||(i=v(["\n display: flex;\n width: fit-content;\n\n ","\n"])),(function(e){return e.isEditable&&b.css(r||(r=v(["\n align-items: flex-end;\n flex-direction: ",";\n width: 100%;\n "])),e.direction===T.COLUMN?"column":"row")})),L=f.div(t||(t=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&&b.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&&b.css(a||(a=v(["\n box-shadow: inset 0 0 0 1px "," !important;\n padding-right: 20px;\n "])),h.gray80)})),O=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),y=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"]))),A=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),N={GRAY:m.COLOR.GRAY_DARK,BLUE:m.COLOR.BLUE},M={SMALL:m.SIZE.SMALL,MEDIUM:m.SIZE.MEDIUM},T={ROW:"row",COLUMN:"column"};exports.CONTAINER_DIRECTION=T,exports.EDIT_ICON_COLOR=N,exports.EDIT_ICON_SIZE=M,exports.default=function(e){var n=e.value,i=e.errors,r=void 0===i?[]:i,t=e.isLoading,o=e.isEditable,a=e.onFocus,l=e.fieldClassName,d=e.onCancel,s=e.onSave,c=e.onErrorClick,p=void 0===c?void 0:c,b=e.editIconColor,f=void 0===b?N.GRAY:b,h=e.editIconSize,v=void 0===h?M.MEDIUM:h,C=e.containerDirection,_=e.elementId;return u.createElement(I,{isEditable:o,direction:void 0===C?T.COLUMN:C},u.createElement(L,{isEditable:o,isLoading:t},o&&u.createElement(y,{className:void 0===l?"":l,value:n,disabled:t,onChange:e.onChange}),!o&&u.createElement(w,{onClick:a},n),r&&u.createElement(x,{elementId:_,errors:r,onClick:p}),t&&u.createElement(O,null),!o&&!t&&u.createElement(g,{elementId:_+"-editable-field-icon",type:E.BUTTON_TYPE.PLAIN,onClick:a},u.createElement(R,null,u.createElement(m.Edit,{color:f,size:v})))),o&&!t&&u.createElement(A,null,u.createElement(g,{elementId:_+"-editable-field-save",type:E.BUTTON_TYPE.PLAIN,onClick:s},u.createElement(m.Check,{color:m.COLOR.GRAY_DARK,size:m.SIZE.SMALL})),u.createElement(g,{elementId:_+"-editable-field-cancel",type:E.BUTTON_TYPE.PLAIN,onClick:d},u.createElement(m.Close,{color:m.COLOR.GRAY_DARK,size:m.SIZE.SMALL}))))};
|
|
2
|
+
//# sourceMappingURL=editable-field.cjs.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editable-field.cjs.production.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { COLOR, SIZE, Edit, Check, Close } from '@propellerads/icon';
|
|
3
|
+
import Button, { BUTTON_TYPE } from '@propellerads/button';
|
|
4
|
+
import ErrorLabel from '@propellerads/error-label';
|
|
5
|
+
import styled, { css, keyframes } from 'styled-components';
|
|
6
|
+
import { borderRadius, gray80, white, spacing, lineHeight } from '@propellerads/stylevariables';
|
|
7
|
+
|
|
8
|
+
function _taggedTemplateLiteralLoose(strings, raw) {
|
|
9
|
+
if (!raw) {
|
|
10
|
+
raw = strings.slice(0);
|
|
11
|
+
}
|
|
12
|
+
strings.raw = raw;
|
|
13
|
+
return strings;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
17
|
+
var spin = /*#__PURE__*/keyframes(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"])));
|
|
18
|
+
var StyledEditableFieldWrapper = /*#__PURE__*/styled.div(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: fit-content;\n\n ", "\n"])), function (props) {
|
|
19
|
+
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');
|
|
20
|
+
});
|
|
21
|
+
var StyledEditableFieldInputWrapper = /*#__PURE__*/styled.div(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\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"])), borderRadius, gray80, function (props) {
|
|
22
|
+
var _props$theme;
|
|
23
|
+
return props.isEditable && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n box-shadow: inset 0 0 0 1px ", " !important;\n width: 100%;\n "])), (props == null || (_props$theme = props.theme) == null || (_props$theme = _props$theme.actionColor) == null ? void 0 : _props$theme.main) || '#1787fc');
|
|
24
|
+
}, function (props) {
|
|
25
|
+
return props.isLoading && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n box-shadow: inset 0 0 0 1px ", " !important;\n padding-right: 20px;\n "])), gray80);
|
|
26
|
+
});
|
|
27
|
+
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
|
+
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
|
+
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(_templateObject10 || (_templateObject10 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n pointer-events: none;\n"])));
|
|
31
|
+
var StyledEditableFieldActions = /*#__PURE__*/styled.div(_templateObject11 || (_templateObject11 = /*#__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
|
+
|
|
33
|
+
var EDIT_ICON_COLOR = {
|
|
34
|
+
GRAY: COLOR.GRAY_DARK,
|
|
35
|
+
BLUE: COLOR.BLUE
|
|
36
|
+
};
|
|
37
|
+
var EDIT_ICON_SIZE = {
|
|
38
|
+
SMALL: SIZE.SMALL,
|
|
39
|
+
MEDIUM: SIZE.MEDIUM
|
|
40
|
+
};
|
|
41
|
+
var CONTAINER_DIRECTION = {
|
|
42
|
+
ROW: 'row',
|
|
43
|
+
COLUMN: 'column'
|
|
44
|
+
};
|
|
45
|
+
var EditableField = function EditableField(_ref) {
|
|
46
|
+
var value = _ref.value,
|
|
47
|
+
_ref$errors = _ref.errors,
|
|
48
|
+
errors = _ref$errors === void 0 ? [] : _ref$errors,
|
|
49
|
+
isLoading = _ref.isLoading,
|
|
50
|
+
isEditable = _ref.isEditable,
|
|
51
|
+
onFocus = _ref.onFocus,
|
|
52
|
+
_ref$fieldClassName = _ref.fieldClassName,
|
|
53
|
+
fieldClassName = _ref$fieldClassName === void 0 ? '' : _ref$fieldClassName,
|
|
54
|
+
onCancel = _ref.onCancel,
|
|
55
|
+
onSave = _ref.onSave,
|
|
56
|
+
onChange = _ref.onChange,
|
|
57
|
+
_ref$onErrorClick = _ref.onErrorClick,
|
|
58
|
+
onErrorClick = _ref$onErrorClick === void 0 ? undefined : _ref$onErrorClick,
|
|
59
|
+
_ref$editIconColor = _ref.editIconColor,
|
|
60
|
+
editIconColor = _ref$editIconColor === void 0 ? EDIT_ICON_COLOR.GRAY : _ref$editIconColor,
|
|
61
|
+
_ref$editIconSize = _ref.editIconSize,
|
|
62
|
+
editIconSize = _ref$editIconSize === void 0 ? EDIT_ICON_SIZE.MEDIUM : _ref$editIconSize,
|
|
63
|
+
_ref$containerDirecti = _ref.containerDirection,
|
|
64
|
+
containerDirection = _ref$containerDirecti === void 0 ? CONTAINER_DIRECTION.COLUMN : _ref$containerDirecti,
|
|
65
|
+
elementId = _ref.elementId;
|
|
66
|
+
return React.createElement(StyledEditableFieldWrapper, {
|
|
67
|
+
isEditable: isEditable,
|
|
68
|
+
direction: containerDirection
|
|
69
|
+
}, React.createElement(StyledEditableFieldInputWrapper, {
|
|
70
|
+
isEditable: isEditable,
|
|
71
|
+
isLoading: isLoading
|
|
72
|
+
}, isEditable && React.createElement(StyledEditableFieldInput, {
|
|
73
|
+
className: fieldClassName,
|
|
74
|
+
value: value,
|
|
75
|
+
disabled: isLoading,
|
|
76
|
+
onChange: onChange
|
|
77
|
+
}), !isEditable && React.createElement(StyledEditableFieldValue, {
|
|
78
|
+
onClick: onFocus
|
|
79
|
+
}, value), errors && React.createElement(ErrorLabel, {
|
|
80
|
+
elementId: elementId,
|
|
81
|
+
errors: errors,
|
|
82
|
+
onClick: onErrorClick
|
|
83
|
+
}), isLoading && React.createElement(StyledEditableFieldInputSpinner, null), !isEditable && !isLoading && React.createElement(Button, {
|
|
84
|
+
elementId: elementId + "-editable-field-icon",
|
|
85
|
+
type: BUTTON_TYPE.PLAIN,
|
|
86
|
+
onClick: onFocus
|
|
87
|
+
}, React.createElement(StyledEditableFieldIcon, null, React.createElement(Edit, {
|
|
88
|
+
color: editIconColor,
|
|
89
|
+
size: editIconSize
|
|
90
|
+
})))), isEditable && !isLoading && React.createElement(StyledEditableFieldActions, null, React.createElement(Button, {
|
|
91
|
+
elementId: elementId + "-editable-field-save",
|
|
92
|
+
type: BUTTON_TYPE.PLAIN,
|
|
93
|
+
onClick: onSave
|
|
94
|
+
}, React.createElement(Check, {
|
|
95
|
+
color: COLOR.GRAY_DARK,
|
|
96
|
+
size: SIZE.SMALL
|
|
97
|
+
})), React.createElement(Button, {
|
|
98
|
+
elementId: elementId + "-editable-field-cancel",
|
|
99
|
+
type: BUTTON_TYPE.PLAIN,
|
|
100
|
+
onClick: onCancel
|
|
101
|
+
}, React.createElement(Close, {
|
|
102
|
+
color: COLOR.GRAY_DARK,
|
|
103
|
+
size: SIZE.SMALL
|
|
104
|
+
}))));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default EditableField;
|
|
108
|
+
export { CONTAINER_DIRECTION, EDIT_ICON_COLOR, EDIT_ICON_SIZE };
|
|
109
|
+
//# sourceMappingURL=editable-field.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editable-field.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/editable-field",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "EditableField component",
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"module": "dist/
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/editable-field.esm.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
@@ -14,29 +14,27 @@
|
|
|
14
14
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"prepublishOnly": "
|
|
17
|
+
"prepublishOnly": "tsdx build",
|
|
18
|
+
"start": "tsdx watch",
|
|
19
|
+
"build": "tsdx build"
|
|
18
20
|
},
|
|
19
21
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
20
22
|
"private": false,
|
|
21
23
|
"dependencies": {
|
|
22
|
-
"@propellerads/button": "^
|
|
23
|
-
"@propellerads/error-label": "
|
|
24
|
-
"@propellerads/icon": "^
|
|
24
|
+
"@propellerads/button": "^6.3.0",
|
|
25
|
+
"@propellerads/error-label": "3.1.0",
|
|
26
|
+
"@propellerads/icon": "^5.13.1",
|
|
25
27
|
"@propellerads/stylevariables": "^1.3.1"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"@babel/preset-react": "^7.10.1",
|
|
32
|
-
"rollup": "^2.18.0",
|
|
33
|
-
"rollup-plugin-babel": "^4.4.0",
|
|
34
|
-
"rollup-plugin-terser": "^6.1.0"
|
|
30
|
+
"tsdx": "^0.14.1",
|
|
31
|
+
"tslib": "^2.3.1",
|
|
32
|
+
"typescript": "^4.4.2"
|
|
35
33
|
},
|
|
36
34
|
"peerDependencies": {
|
|
37
35
|
"prop-types": "15.7.2",
|
|
38
36
|
"react": "^17.0.2",
|
|
39
37
|
"styled-components": "5.1.1"
|
|
40
38
|
},
|
|
41
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "ceecda4693937eb4957e158dbd621301d2869ea2"
|
|
42
40
|
}
|
package/dist/index.esm.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { COLOR, SIZE, Edit, Check, Close } from '@propellerads/icon';
|
|
4
|
-
import Button, { BUTTON_TYPE } from '@propellerads/button';
|
|
5
|
-
import ErrorLabel from '@propellerads/error-label';
|
|
6
|
-
import styled, { keyframes, css } from 'styled-components';
|
|
7
|
-
import { borderRadius, gray80, white, spacing, lineHeight } from '@propellerads/stylevariables';
|
|
8
|
-
|
|
9
|
-
function _taggedTemplateLiteral(strings, raw) {
|
|
10
|
-
if (!raw) {
|
|
11
|
-
raw = strings.slice(0);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return Object.freeze(Object.defineProperties(strings, {
|
|
15
|
-
raw: {
|
|
16
|
-
value: Object.freeze(raw)
|
|
17
|
-
}
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function _templateObject11() {
|
|
22
|
-
var data = _taggedTemplateLiteral(["\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"]);
|
|
23
|
-
|
|
24
|
-
_templateObject11 = function _templateObject11() {
|
|
25
|
-
return data;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return data;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function _templateObject10() {
|
|
32
|
-
var data = _taggedTemplateLiteral(["\n pointer-events: none;\n"]);
|
|
33
|
-
|
|
34
|
-
_templateObject10 = function _templateObject10() {
|
|
35
|
-
return data;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return data;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function _templateObject9() {
|
|
42
|
-
var data = _taggedTemplateLiteral(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ", "px;\n"]);
|
|
43
|
-
|
|
44
|
-
_templateObject9 = function _templateObject9() {
|
|
45
|
-
return data;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return data;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function _templateObject8() {
|
|
52
|
-
var data = _taggedTemplateLiteral(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ", "px;\n height: ", "px;\n"]);
|
|
53
|
-
|
|
54
|
-
_templateObject8 = function _templateObject8() {
|
|
55
|
-
return data;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return data;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function _templateObject7() {
|
|
62
|
-
var data = _taggedTemplateLiteral(["\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"]);
|
|
63
|
-
|
|
64
|
-
_templateObject7 = function _templateObject7() {
|
|
65
|
-
return data;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
return data;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function _templateObject6() {
|
|
72
|
-
var data = _taggedTemplateLiteral(["\n box-shadow: inset 0 0 0 1px ", " !important;\n padding-right: 20px;\n "]);
|
|
73
|
-
|
|
74
|
-
_templateObject6 = function _templateObject6() {
|
|
75
|
-
return data;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return data;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function _templateObject5() {
|
|
82
|
-
var data = _taggedTemplateLiteral(["\n box-shadow: inset 0 0 0 1px #1787fc !important;\n width: 100%;\n "]);
|
|
83
|
-
|
|
84
|
-
_templateObject5 = function _templateObject5() {
|
|
85
|
-
return data;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
return data;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function _templateObject4() {
|
|
92
|
-
var data = _taggedTemplateLiteral(["\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"]);
|
|
93
|
-
|
|
94
|
-
_templateObject4 = function _templateObject4() {
|
|
95
|
-
return data;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
return data;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function _templateObject3() {
|
|
102
|
-
var data = _taggedTemplateLiteral(["\n align-items: flex-end;\n width: 100%;\n "]);
|
|
103
|
-
|
|
104
|
-
_templateObject3 = function _templateObject3() {
|
|
105
|
-
return data;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
return data;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function _templateObject2() {
|
|
112
|
-
var data = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n width: fit-content;\n\n ", "\n"]);
|
|
113
|
-
|
|
114
|
-
_templateObject2 = function _templateObject2() {
|
|
115
|
-
return data;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
return data;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function _templateObject() {
|
|
122
|
-
var data = _taggedTemplateLiteral(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"]);
|
|
123
|
-
|
|
124
|
-
_templateObject = function _templateObject() {
|
|
125
|
-
return data;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
return data;
|
|
129
|
-
}
|
|
130
|
-
var spin = keyframes(_templateObject());
|
|
131
|
-
var StyledEditableFieldWrapper = styled.div(_templateObject2(), function (props) {
|
|
132
|
-
return props.isEditable && css(_templateObject3());
|
|
133
|
-
});
|
|
134
|
-
var StyledEditableFieldInputWrapper = styled.div(_templateObject4(), borderRadius, gray80, function (props) {
|
|
135
|
-
return props.isEditable && css(_templateObject5());
|
|
136
|
-
}, function (props) {
|
|
137
|
-
return props.isLoading && css(_templateObject6(), gray80);
|
|
138
|
-
});
|
|
139
|
-
var StyledEditableFieldInputSpinner = styled.div(_templateObject7(), white, gray80, gray80, spin);
|
|
140
|
-
var StyledEditableFieldInput = styled.input(_templateObject8(), spacing * 2, lineHeight);
|
|
141
|
-
var StyledEditableFieldValue = styled.div(_templateObject9(), spacing * 2);
|
|
142
|
-
var StyledEditableFieldIcon = styled.div(_templateObject10());
|
|
143
|
-
var StyledEditableFieldActions = styled.div(_templateObject11(), spacing * 2, spacing * 2, borderRadius, gray80);
|
|
144
|
-
|
|
145
|
-
var EDIT_ICON_COLOR = {
|
|
146
|
-
GRAY: COLOR.GRAY_DARK,
|
|
147
|
-
BLUE: COLOR.BLUE
|
|
148
|
-
};
|
|
149
|
-
var EDIT_ICON_SIZE = {
|
|
150
|
-
SMALL: SIZE.SMALL,
|
|
151
|
-
MEDIUM: SIZE.MEDIUM
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
var EditableField = function EditableField(_ref) {
|
|
155
|
-
var value = _ref.value,
|
|
156
|
-
errors = _ref.errors,
|
|
157
|
-
isLoading = _ref.isLoading,
|
|
158
|
-
isEditable = _ref.isEditable,
|
|
159
|
-
onFocus = _ref.onFocus,
|
|
160
|
-
fieldClassName = _ref.fieldClassName,
|
|
161
|
-
onCancel = _ref.onCancel,
|
|
162
|
-
onSave = _ref.onSave,
|
|
163
|
-
onChange = _ref.onChange,
|
|
164
|
-
onErrorClick = _ref.onErrorClick,
|
|
165
|
-
editIconColor = _ref.editIconColor,
|
|
166
|
-
editIconSize = _ref.editIconSize,
|
|
167
|
-
elementId = _ref.elementId;
|
|
168
|
-
return /*#__PURE__*/React.createElement(StyledEditableFieldWrapper, {
|
|
169
|
-
isEditable: isEditable
|
|
170
|
-
}, /*#__PURE__*/React.createElement(StyledEditableFieldInputWrapper, {
|
|
171
|
-
isEditable: isEditable,
|
|
172
|
-
isLoading: isLoading
|
|
173
|
-
}, isEditable && /*#__PURE__*/React.createElement(StyledEditableFieldInput, {
|
|
174
|
-
className: fieldClassName,
|
|
175
|
-
value: value,
|
|
176
|
-
disabled: isLoading,
|
|
177
|
-
onChange: onChange
|
|
178
|
-
}), !isEditable && /*#__PURE__*/React.createElement(StyledEditableFieldValue, {
|
|
179
|
-
onClick: onFocus
|
|
180
|
-
}, value), errors && /*#__PURE__*/React.createElement(ErrorLabel, {
|
|
181
|
-
elementId: elementId,
|
|
182
|
-
errors: errors,
|
|
183
|
-
onClick: onErrorClick
|
|
184
|
-
}), isLoading && /*#__PURE__*/React.createElement(StyledEditableFieldInputSpinner, null), !isEditable && !isLoading && /*#__PURE__*/React.createElement(Button, {
|
|
185
|
-
elementId: "".concat(elementId, "-editable-field-icon"),
|
|
186
|
-
type: BUTTON_TYPE.PLAIN,
|
|
187
|
-
onClick: onFocus
|
|
188
|
-
}, /*#__PURE__*/React.createElement(StyledEditableFieldIcon, null, /*#__PURE__*/React.createElement(Edit, {
|
|
189
|
-
color: editIconColor,
|
|
190
|
-
size: editIconSize
|
|
191
|
-
})))), isEditable && !isLoading && /*#__PURE__*/React.createElement(StyledEditableFieldActions, null, /*#__PURE__*/React.createElement(Button, {
|
|
192
|
-
elementId: "".concat(elementId, "-editable-field-save"),
|
|
193
|
-
type: BUTTON_TYPE.PLAIN,
|
|
194
|
-
onClick: onSave
|
|
195
|
-
}, /*#__PURE__*/React.createElement(Check, {
|
|
196
|
-
color: COLOR.GRAY_DARK,
|
|
197
|
-
size: SIZE.SMALL
|
|
198
|
-
})), /*#__PURE__*/React.createElement(Button, {
|
|
199
|
-
elementId: "".concat(elementId, "-editable-field-cancel"),
|
|
200
|
-
type: BUTTON_TYPE.PLAIN,
|
|
201
|
-
onClick: onCancel
|
|
202
|
-
}, /*#__PURE__*/React.createElement(Close, {
|
|
203
|
-
color: COLOR.GRAY_DARK,
|
|
204
|
-
size: SIZE.SMALL
|
|
205
|
-
}))));
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
EditableField.propTypes = {
|
|
209
|
-
errors: PropTypes.arrayOf(PropTypes.string),
|
|
210
|
-
value: PropTypes.string.isRequired,
|
|
211
|
-
isLoading: PropTypes.bool.isRequired,
|
|
212
|
-
isEditable: PropTypes.bool.isRequired,
|
|
213
|
-
fieldClassName: PropTypes.string,
|
|
214
|
-
onFocus: PropTypes.func.isRequired,
|
|
215
|
-
onCancel: PropTypes.func.isRequired,
|
|
216
|
-
onSave: PropTypes.func.isRequired,
|
|
217
|
-
onChange: PropTypes.func.isRequired,
|
|
218
|
-
onErrorClick: PropTypes.func,
|
|
219
|
-
editIconColor: PropTypes.oneOf(Object.values(EDIT_ICON_COLOR)),
|
|
220
|
-
editIconSize: PropTypes.oneOf(Object.values(EDIT_ICON_SIZE)),
|
|
221
|
-
elementId: PropTypes.string.isRequired
|
|
222
|
-
};
|
|
223
|
-
EditableField.defaultProps = {
|
|
224
|
-
errors: [],
|
|
225
|
-
fieldClassName: '',
|
|
226
|
-
editIconColor: EDIT_ICON_COLOR.GRAY,
|
|
227
|
-
editIconSize: EDIT_ICON_SIZE.MEDIUM,
|
|
228
|
-
onErrorClick: undefined
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
export default EditableField;
|
|
232
|
-
export { EDIT_ICON_COLOR, EDIT_ICON_SIZE };
|
package/dist/index.esm.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import n from"react";import e from"prop-types";import{COLOR as r,SIZE as t,Edit as i,Check as o,Close as a}from"@propellerads/icon";import l,{BUTTON_TYPE as c}from"@propellerads/button";import d from"@propellerads/error-label";import s,{keyframes as u,css as p}from"styled-components";import{borderRadius as f,gray80 as m,white as b,spacing as v,lineHeight as g}from"@propellerads/stylevariables";function x(n,e){return e||(e=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(e)}}))}function E(){var n=x(["\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"]);return E=function(){return n},n}function h(){var n=x(["\n pointer-events: none;\n"]);return h=function(){return n},n}function C(){var n=x(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ","px;\n"]);return C=function(){return n},n}function I(){var n=x(["\n outline: none;\n width: 100%;\n background: transparent;\n border: 0;\n resize: none;\n padding: ","px;\n height: ","px;\n"]);return I=function(){return n},n}function L(){var n=x(["\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"]);return L=function(){return n},n}function R(){var n=x(["\n box-shadow: inset 0 0 0 1px "," !important;\n padding-right: 20px;\n "]);return R=function(){return n},n}function w(){var n=x(["\n box-shadow: inset 0 0 0 1px #1787fc !important;\n width: 100%;\n "]);return w=function(){return n},n}function A(){var n=x(["\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"]);return A=function(){return n},n}function y(){var n=x(["\n align-items: flex-end;\n width: 100%;\n "]);return y=function(){return n},n}function k(){var n=x(["\n display: flex;\n flex-direction: column;\n width: fit-content;\n\n ","\n"]);return k=function(){return n},n}function z(){var n=x(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"]);return z=function(){return n},n}var M=u(z()),S=s.div(k(),(function(n){return n.isEditable&&p(y())})),q=s.div(A(),f,m,(function(n){return n.isEditable&&p(w())}),(function(n){return n.isLoading&&p(R(),m)})),O=s.div(L(),b,m,m,M),N=s.input(I(),2*v,g),j=s.div(C(),2*v),D=s.div(h()),G=s.div(E(),2*v,2*v,f,m),P={GRAY:r.GRAY_DARK,BLUE:r.BLUE},U={SMALL:t.SMALL,MEDIUM:t.MEDIUM},Y=function(e){var s=e.value,u=e.errors,p=e.isLoading,f=e.isEditable,m=e.onFocus,b=e.fieldClassName,v=e.onCancel,g=e.onSave,x=e.onChange,E=e.onErrorClick,h=e.editIconColor,C=e.editIconSize,I=e.elementId;return n.createElement(S,{isEditable:f},n.createElement(q,{isEditable:f,isLoading:p},f&&n.createElement(N,{className:b,value:s,disabled:p,onChange:x}),!f&&n.createElement(j,{onClick:m},s),u&&n.createElement(d,{elementId:I,errors:u,onClick:E}),p&&n.createElement(O,null),!f&&!p&&n.createElement(l,{elementId:"".concat(I,"-editable-field-icon"),type:c.PLAIN,onClick:m},n.createElement(D,null,n.createElement(i,{color:h,size:C})))),f&&!p&&n.createElement(G,null,n.createElement(l,{elementId:"".concat(I,"-editable-field-save"),type:c.PLAIN,onClick:g},n.createElement(o,{color:r.GRAY_DARK,size:t.SMALL})),n.createElement(l,{elementId:"".concat(I,"-editable-field-cancel"),type:c.PLAIN,onClick:v},n.createElement(a,{color:r.GRAY_DARK,size:t.SMALL}))))};Y.propTypes={errors:e.arrayOf(e.string),value:e.string.isRequired,isLoading:e.bool.isRequired,isEditable:e.bool.isRequired,fieldClassName:e.string,onFocus:e.func.isRequired,onCancel:e.func.isRequired,onSave:e.func.isRequired,onChange:e.func.isRequired,onErrorClick:e.func,editIconColor:e.oneOf(Object.values(P)),editIconSize:e.oneOf(Object.values(U)),elementId:e.string.isRequired},Y.defaultProps={errors:[],fieldClassName:"",editIconColor:P.GRAY,editIconSize:U.MEDIUM,onErrorClick:void 0};export default Y;export{P as EDIT_ICON_COLOR,U as EDIT_ICON_SIZE};
|