@pareto-engineering/design-system 4.0.0-alpha.42 → 4.0.0-alpha.44
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/dist/cjs/a/Removable/Removable.js +72 -0
- package/dist/cjs/a/Removable/index.js +13 -0
- package/dist/cjs/a/Removable/styles.scss +33 -0
- package/dist/cjs/a/index.js +8 -1
- package/dist/cjs/b/Button/Button.js +2 -1
- package/dist/cjs/b/Button/styles.scss +3 -3
- package/dist/cjs/f/common/Description/Description.js +5 -4
- package/dist/cjs/f/fields/Checkbox/styles.scss +1 -0
- package/dist/cjs/f/fields/ChoicesInput/styles.scss +1 -1
- package/dist/cjs/f/fields/EditorInput/EditorInput.js +0 -1
- package/dist/cjs/f/fields/EditorInput/common/Toolbar.js +64 -0
- package/dist/cjs/f/fields/EditorInput/styles.scss +26 -0
- package/dist/cjs/f/fields/TextInput/TextInput.js +3 -3
- package/dist/es/a/Removable/Removable.js +64 -0
- package/dist/es/a/Removable/index.js +2 -0
- package/dist/es/a/Removable/styles.scss +33 -0
- package/dist/es/a/index.js +2 -1
- package/dist/es/b/Button/Button.js +2 -1
- package/dist/es/b/Button/styles.scss +3 -3
- package/dist/es/f/common/Description/Description.js +5 -4
- package/dist/es/f/fields/Checkbox/styles.scss +1 -0
- package/dist/es/f/fields/ChoicesInput/styles.scss +1 -1
- package/dist/es/f/fields/EditorInput/EditorInput.js +0 -1
- package/dist/es/f/fields/EditorInput/common/Toolbar.js +66 -2
- package/dist/es/f/fields/EditorInput/styles.scss +26 -0
- package/dist/es/f/fields/TextInput/TextInput.js +3 -3
- package/package.json +3 -3
- package/src/stories/a/AppContext.stories.jsx +2 -2
- package/src/stories/a/Removable.stories.jsx +22 -0
- package/src/stories/b/SocialMediaButton.stories.jsx +2 -2
- package/src/stories/colors.js +2 -0
- package/src/ui/a/Removable/Removable.jsx +85 -0
- package/src/ui/a/Removable/index.js +2 -0
- package/src/ui/a/Removable/styles.scss +33 -0
- package/src/ui/a/index.js +1 -0
- package/src/ui/b/Button/Button.jsx +2 -0
- package/src/ui/b/Button/styles.scss +3 -3
- package/src/ui/f/common/Description/Description.jsx +5 -4
- package/src/ui/f/fields/Checkbox/styles.scss +1 -0
- package/src/ui/f/fields/ChoicesInput/styles.scss +1 -1
- package/src/ui/f/fields/EditorInput/EditorInput.jsx +0 -1
- package/src/ui/f/fields/EditorInput/common/Toolbar.jsx +103 -1
- package/src/ui/f/fields/EditorInput/styles.scss +26 -0
- package/src/ui/f/fields/TextInput/TextInput.jsx +2 -1
- package/tests/__snapshots__/Storyshots.test.js.snap +1027 -11
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /* @pareto-engineering/generator-front 1.1.1-alpha.1 */
|
|
13
|
+
// Local Definitions
|
|
14
|
+
|
|
15
|
+
const baseClassName = _exports.default.base;
|
|
16
|
+
const componentClassName = 'removable';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This is a wrapper component that adds a close button to its children.
|
|
20
|
+
*/
|
|
21
|
+
const Removable = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
id,
|
|
24
|
+
className: userClassName,
|
|
25
|
+
style,
|
|
26
|
+
handleClose,
|
|
27
|
+
children
|
|
28
|
+
// ...otherProps
|
|
29
|
+
} = _ref;
|
|
30
|
+
(0, React.useInsertionEffect)(() => {
|
|
31
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
32
|
+
}, []);
|
|
33
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
id: id,
|
|
35
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
36
|
+
style: style
|
|
37
|
+
// {...otherProps}
|
|
38
|
+
}, children, /*#__PURE__*/React.createElement("button", {
|
|
39
|
+
type: "button",
|
|
40
|
+
className: "close-button",
|
|
41
|
+
onClick: handleClose || (() => null)
|
|
42
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
className: "icon"
|
|
44
|
+
}, "Y")));
|
|
45
|
+
};
|
|
46
|
+
Removable.propTypes = {
|
|
47
|
+
/**
|
|
48
|
+
* The HTML id for this element
|
|
49
|
+
*/
|
|
50
|
+
id: _propTypes.default.string,
|
|
51
|
+
/**
|
|
52
|
+
* The HTML class names for this element
|
|
53
|
+
*/
|
|
54
|
+
className: _propTypes.default.string,
|
|
55
|
+
/**
|
|
56
|
+
* The React-written, css properties for this element.
|
|
57
|
+
*/
|
|
58
|
+
style: _propTypes.default.objectOf(_propTypes.default.string),
|
|
59
|
+
/**
|
|
60
|
+
* The function to call when the close button is clicked
|
|
61
|
+
*/
|
|
62
|
+
handleClose: _propTypes.default.func,
|
|
63
|
+
/**
|
|
64
|
+
* The children JSX
|
|
65
|
+
*/
|
|
66
|
+
children: _propTypes.default.node
|
|
67
|
+
};
|
|
68
|
+
Removable.defaultProps = {
|
|
69
|
+
// someProp:false
|
|
70
|
+
};
|
|
71
|
+
var _default = Removable;
|
|
72
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Removable", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Removable.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Removable = _interopRequireDefault(require("./Removable"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.1 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-padding: .5rem;
|
|
6
|
+
|
|
7
|
+
.#{bem.$base}.removable {
|
|
8
|
+
align-items: center;
|
|
9
|
+
background-color: var(--background-inputs);
|
|
10
|
+
border: var(--theme-default-border-style) var(--main2);
|
|
11
|
+
border-radius: $default-padding;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
padding: $default-padding;
|
|
15
|
+
|
|
16
|
+
> :first-child {
|
|
17
|
+
flex-grow: 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.close-button {
|
|
21
|
+
background-color: transparent;
|
|
22
|
+
border: none;
|
|
23
|
+
color: var(--metadata);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
margin-left: var(--gap);
|
|
26
|
+
|
|
27
|
+
&:hover {
|
|
28
|
+
color: var(--hard-metadata);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
package/dist/cjs/a/index.js
CHANGED
|
@@ -111,6 +111,12 @@ Object.defineProperty(exports, "Quote", {
|
|
|
111
111
|
return _Quote.Quote;
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
|
+
Object.defineProperty(exports, "Removable", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _Removable.Removable;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
114
120
|
Object.defineProperty(exports, "SVG", {
|
|
115
121
|
enumerable: true,
|
|
116
122
|
get: function () {
|
|
@@ -181,4 +187,5 @@ var _MetaCard = require("./MetaCard");
|
|
|
181
187
|
var _AnimatedBlobs = require("./AnimatedBlobs");
|
|
182
188
|
var _Tip = require("./Tip");
|
|
183
189
|
var _AnimatedGradient = require("./AnimatedGradient");
|
|
184
|
-
var _TextSteps = require("./TextSteps");
|
|
190
|
+
var _TextSteps = require("./TextSteps");
|
|
191
|
+
var _Removable = require("./Removable");
|
|
@@ -25,6 +25,7 @@ const Button = _ref => {
|
|
|
25
25
|
children,
|
|
26
26
|
isLoading,
|
|
27
27
|
color,
|
|
28
|
+
textColor,
|
|
28
29
|
isCompact,
|
|
29
30
|
isGhost,
|
|
30
31
|
isSimple,
|
|
@@ -41,7 +42,7 @@ const Button = _ref => {
|
|
|
41
42
|
}, children) : children;
|
|
42
43
|
return /*#__PURE__*/React.createElement("button", _extends({
|
|
43
44
|
id: id,
|
|
44
|
-
className: [baseClassName, componentClassName, userClassName, `x-${color}`, isGhost && _exports.default.modifierGhost, isCompact && _exports.default.modifierCompact, isSimple && _exports.default.modifierSimple, isGradient && _exports.default.modifierGradient, isSpaced && _exports.default.modifierSpaced, !isLoading && arrowDirection && `arrow-${arrowDirection}`].filter(e => e).join(' '),
|
|
45
|
+
className: [baseClassName, componentClassName, userClassName, `x-${color}`, textColor && `y-${textColor}`, isGhost && _exports.default.modifierGhost, isCompact && _exports.default.modifierCompact, isSimple && _exports.default.modifierSimple, isGradient && _exports.default.modifierGradient, isSpaced && _exports.default.modifierSpaced, !isLoading && arrowDirection && `arrow-${arrowDirection}`].filter(e => e).join(' '),
|
|
45
46
|
style: style,
|
|
46
47
|
type: "button"
|
|
47
48
|
}, otherProps), isLoading ? /*#__PURE__*/React.createElement(_.LoadingCircle, {
|
|
@@ -92,7 +92,7 @@ $default-animation-time: .31s;
|
|
|
92
92
|
&.#{bem.$modifier-ghost} {
|
|
93
93
|
background: transparent;
|
|
94
94
|
border: 1px solid var(--x, var(--#{$default-color}));
|
|
95
|
-
color: var(--x, var(--#{$default-color}));
|
|
95
|
+
color: var(--y, var(--x, var(--#{$default-color})));
|
|
96
96
|
|
|
97
97
|
&:hover,
|
|
98
98
|
&:focus,
|
|
@@ -103,12 +103,12 @@ $default-animation-time: .31s;
|
|
|
103
103
|
&:not(:disabled) {
|
|
104
104
|
&:hover {
|
|
105
105
|
border: 1px solid var(--soft-x, var(--soft-#{$default-color}));
|
|
106
|
-
color: var(--soft-x, var(--soft-#{$default-color}));
|
|
106
|
+
color: var(--soft-y, var(--soft-x, var(--soft-#{$default-color})));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
&:focus {
|
|
110
110
|
border: 1px solid var(--hard-x, var(--hard-#{$default-color}));
|
|
111
|
-
color: var(--hard-x, var(--hard-#{$default-color}));
|
|
111
|
+
color: var(--hard-y, var(--hard-x, var(--hard-#{$default-color})));
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -32,13 +32,14 @@ const Description = _ref => {
|
|
|
32
32
|
(0, React.useInsertionEffect)(() => {
|
|
33
33
|
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
34
34
|
}, []);
|
|
35
|
-
const [
|
|
36
|
-
|
|
35
|
+
const [, meta] = (0, _formik.useField)(name);
|
|
36
|
+
const hasError = meta.touched && meta.error;
|
|
37
|
+
if (hasError || description) {
|
|
37
38
|
return /*#__PURE__*/React.createElement("div", {
|
|
38
39
|
id: id,
|
|
39
|
-
className: [baseClassName, componentClassName, userClassName,
|
|
40
|
+
className: [baseClassName, componentClassName, userClassName, hasError ? 'x-error' : `x-${color}`].filter(e => e).join(' '),
|
|
40
41
|
style: style
|
|
41
|
-
}, meta.error
|
|
42
|
+
}, hasError ? meta.error : description);
|
|
42
43
|
}
|
|
43
44
|
return null;
|
|
44
45
|
};
|
|
@@ -11,6 +11,7 @@ var _selection = require("@lexical/selection");
|
|
|
11
11
|
var _link = require("@lexical/link");
|
|
12
12
|
var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
|
|
13
13
|
var _utils = require("@lexical/utils");
|
|
14
|
+
var _ = require("../../../..");
|
|
14
15
|
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -35,6 +36,8 @@ const getSelectedNode = selection => {
|
|
|
35
36
|
}
|
|
36
37
|
return (0, _selection.$isAtNodeEnd)(anchor) ? focusNode : anchorNode;
|
|
37
38
|
};
|
|
39
|
+
const defaultColor = 'var(--paragraph)';
|
|
40
|
+
const colorOptions = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink', 'brown'];
|
|
38
41
|
const Toolbar = () => {
|
|
39
42
|
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
40
43
|
const [isBold, setIsBold] = (0, React.useState)(false);
|
|
@@ -43,6 +46,8 @@ const Toolbar = () => {
|
|
|
43
46
|
const [blockType, setBlockType] = (0, React.useState)('paragraph');
|
|
44
47
|
const [isLink, setIsLink] = (0, React.useState)(false);
|
|
45
48
|
const [isUnderline, setIsUnderline] = (0, React.useState)(false);
|
|
49
|
+
const [color, setColor] = (0, React.useState)(defaultColor);
|
|
50
|
+
const colorMenuRef = (0, React.useRef)(false);
|
|
46
51
|
const formatBulletList = () => {
|
|
47
52
|
if (blockType !== 'ul') {
|
|
48
53
|
editor.dispatchCommand(_list.INSERT_UNORDERED_LIST_COMMAND);
|
|
@@ -81,6 +86,18 @@ const Toolbar = () => {
|
|
|
81
86
|
setBlockType(element);
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
// Check nodes for color
|
|
90
|
+
const nodes = selection.getNodes().filter(node => node.getType() === 'text');
|
|
91
|
+
nodes.forEach(node => {
|
|
92
|
+
const style = node.getStyle();
|
|
93
|
+
const colorProperty = style.match(/color: ([^;]+)/);
|
|
94
|
+
if (colorProperty) {
|
|
95
|
+
setColor(colorProperty[1]);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
setColor(false);
|
|
99
|
+
});
|
|
100
|
+
|
|
84
101
|
// Check selection text styles
|
|
85
102
|
setIsBold(selection.hasFormat('bold'));
|
|
86
103
|
setIsItalic(selection.hasFormat('italic'));
|
|
@@ -98,6 +115,22 @@ const Toolbar = () => {
|
|
|
98
115
|
}
|
|
99
116
|
}
|
|
100
117
|
}, [editor]);
|
|
118
|
+
const UPDATE_COLOR_COMMAND = (0, _lexical.createCommand)();
|
|
119
|
+
editor.registerCommand(UPDATE_COLOR_COMMAND, payload => {
|
|
120
|
+
const selection = (0, _lexical.$getSelection)();
|
|
121
|
+
const nodes = selection?.extract().filter(node => node.getType() === 'text');
|
|
122
|
+
nodes?.forEach(node => {
|
|
123
|
+
const style = node.getStyle();
|
|
124
|
+
const colorProperty = style?.match(/color: ([^;]+)/);
|
|
125
|
+
if (colorProperty && color !== payload) {
|
|
126
|
+
node.setStyle(style.replace(colorProperty[0], `color: ${payload}`));
|
|
127
|
+
} else if (colorProperty) {
|
|
128
|
+
node.setStyle(`color: ${defaultColor}`);
|
|
129
|
+
} else {
|
|
130
|
+
node.setStyle(`color: ${payload}`);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}, _lexical.COMMAND_PRIORITY_NORMAL);
|
|
101
134
|
(0, React.useEffect)(() => (0, _utils.mergeRegister)(editor.registerUpdateListener(_ref => {
|
|
102
135
|
let {
|
|
103
136
|
editorState
|
|
@@ -106,6 +139,10 @@ const Toolbar = () => {
|
|
|
106
139
|
updateToolbar();
|
|
107
140
|
});
|
|
108
141
|
})), [updateToolbar, editor]);
|
|
142
|
+
const dispatchUpdateColor = (0, React.useCallback)((e, payload) => {
|
|
143
|
+
e.stopPropagation();
|
|
144
|
+
editor.dispatchCommand(UPDATE_COLOR_COMMAND, payload);
|
|
145
|
+
}, [editor]);
|
|
109
146
|
return /*#__PURE__*/React.createElement("div", {
|
|
110
147
|
className: `${baseClassName} ${componentClassName}`
|
|
111
148
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -135,6 +172,33 @@ const Toolbar = () => {
|
|
|
135
172
|
}, /*#__PURE__*/React.createElement("span", {
|
|
136
173
|
className: "icon"
|
|
137
174
|
}, "?")), /*#__PURE__*/React.createElement("button", {
|
|
175
|
+
type: "button",
|
|
176
|
+
className: color && color !== defaultColor ? 'active color-menu-button' : 'color-menu-button',
|
|
177
|
+
onClick: () => editor.dispatchCommand(UPDATE_COLOR_COMMAND, color !== defaultColor ? defaultColor : color),
|
|
178
|
+
ref: colorMenuRef,
|
|
179
|
+
style: {
|
|
180
|
+
position: 'relative'
|
|
181
|
+
}
|
|
182
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
183
|
+
className: "icon",
|
|
184
|
+
style: {
|
|
185
|
+
color
|
|
186
|
+
}
|
|
187
|
+
}, "Q"), /*#__PURE__*/React.createElement(_.Popover, {
|
|
188
|
+
parentRef: colorMenuRef
|
|
189
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
190
|
+
className: "color-menu"
|
|
191
|
+
}, colorOptions.map(option => /*#__PURE__*/React.createElement("span", {
|
|
192
|
+
role: "button",
|
|
193
|
+
className: "icon color-option",
|
|
194
|
+
style: {
|
|
195
|
+
color: option
|
|
196
|
+
},
|
|
197
|
+
onClick: e => dispatchUpdateColor(e, option),
|
|
198
|
+
onKeyDown: e => dispatchUpdateColor(e, option),
|
|
199
|
+
tabIndex: 0,
|
|
200
|
+
key: option
|
|
201
|
+
}, "o"))))), /*#__PURE__*/React.createElement("button", {
|
|
138
202
|
type: "button",
|
|
139
203
|
className: isLink ? 'active' : undefined,
|
|
140
204
|
onClick: () => formatLink()
|
|
@@ -15,6 +15,7 @@ $active-background: var(--hard-background-inputs);
|
|
|
15
15
|
$default-background: var(--background-inputs);
|
|
16
16
|
$default-icon-color: var(--on-background-inputs);
|
|
17
17
|
$disabled-background: var(--background-inputs-30);
|
|
18
|
+
$default-color-menu-padding: .5em .25em;
|
|
18
19
|
|
|
19
20
|
.#{bem.$base}.editor-input {
|
|
20
21
|
&.#{bem.$base}.input-wrapper {
|
|
@@ -62,6 +63,31 @@ $disabled-background: var(--background-inputs-30);
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
.color-menu-button {
|
|
67
|
+
&:hover {
|
|
68
|
+
> .#{bem.$base}.popover {
|
|
69
|
+
display: block;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
> .#{bem.$base}.popover {
|
|
74
|
+
padding: $default-color-menu-padding;
|
|
75
|
+
|
|
76
|
+
.color-menu {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-wrap: wrap;
|
|
79
|
+
gap: calc($default-gap / 2);
|
|
80
|
+
justify-content: center;
|
|
81
|
+
max-width: 10em;
|
|
82
|
+
min-width: 5em;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.color-option:hover {
|
|
86
|
+
opacity: .5;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
65
91
|
> .content-editable {
|
|
66
92
|
background: $default-background;
|
|
67
93
|
border: $default-border;
|
|
@@ -41,8 +41,8 @@ const TextInput = _ref => {
|
|
|
41
41
|
desktopLabelSpan,
|
|
42
42
|
inputSpan,
|
|
43
43
|
desktopInputSpan,
|
|
44
|
-
symbol
|
|
45
|
-
|
|
44
|
+
symbol,
|
|
45
|
+
...otherProps
|
|
46
46
|
} = _ref;
|
|
47
47
|
(0, React.useInsertionEffect)(() => {
|
|
48
48
|
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
@@ -77,7 +77,7 @@ const TextInput = _ref => {
|
|
|
77
77
|
disabled: disabled,
|
|
78
78
|
placeholder: placeholder,
|
|
79
79
|
autoComplete: autoComplete
|
|
80
|
-
}, field)), /*#__PURE__*/React.createElement(_common.FormDescription, {
|
|
80
|
+
}, field, otherProps)), /*#__PURE__*/React.createElement(_common.FormDescription, {
|
|
81
81
|
className: "s-1",
|
|
82
82
|
description: description,
|
|
83
83
|
name: name
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.1 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useInsertionEffect } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
6
|
+
|
|
7
|
+
// Local Definitions
|
|
8
|
+
|
|
9
|
+
const baseClassName = styleNames.base;
|
|
10
|
+
const componentClassName = 'removable';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This is a wrapper component that adds a close button to its children.
|
|
14
|
+
*/
|
|
15
|
+
const Removable = ({
|
|
16
|
+
id,
|
|
17
|
+
className: userClassName,
|
|
18
|
+
style,
|
|
19
|
+
handleClose,
|
|
20
|
+
children
|
|
21
|
+
// ...otherProps
|
|
22
|
+
}) => {
|
|
23
|
+
useInsertionEffect(() => {
|
|
24
|
+
import("./styles.scss");
|
|
25
|
+
}, []);
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
id: id,
|
|
28
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
29
|
+
style: style
|
|
30
|
+
// {...otherProps}
|
|
31
|
+
}, children, /*#__PURE__*/React.createElement("button", {
|
|
32
|
+
type: "button",
|
|
33
|
+
className: "close-button",
|
|
34
|
+
onClick: handleClose || (() => null)
|
|
35
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
36
|
+
className: "icon"
|
|
37
|
+
}, "Y")));
|
|
38
|
+
};
|
|
39
|
+
Removable.propTypes = {
|
|
40
|
+
/**
|
|
41
|
+
* The HTML id for this element
|
|
42
|
+
*/
|
|
43
|
+
id: PropTypes.string,
|
|
44
|
+
/**
|
|
45
|
+
* The HTML class names for this element
|
|
46
|
+
*/
|
|
47
|
+
className: PropTypes.string,
|
|
48
|
+
/**
|
|
49
|
+
* The React-written, css properties for this element.
|
|
50
|
+
*/
|
|
51
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
52
|
+
/**
|
|
53
|
+
* The function to call when the close button is clicked
|
|
54
|
+
*/
|
|
55
|
+
handleClose: PropTypes.func,
|
|
56
|
+
/**
|
|
57
|
+
* The children JSX
|
|
58
|
+
*/
|
|
59
|
+
children: PropTypes.node
|
|
60
|
+
};
|
|
61
|
+
Removable.defaultProps = {
|
|
62
|
+
// someProp:false
|
|
63
|
+
};
|
|
64
|
+
export default Removable;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.1 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-padding: .5rem;
|
|
6
|
+
|
|
7
|
+
.#{bem.$base}.removable {
|
|
8
|
+
align-items: center;
|
|
9
|
+
background-color: var(--background-inputs);
|
|
10
|
+
border: var(--theme-default-border-style) var(--main2);
|
|
11
|
+
border-radius: $default-padding;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
padding: $default-padding;
|
|
15
|
+
|
|
16
|
+
> :first-child {
|
|
17
|
+
flex-grow: 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.close-button {
|
|
21
|
+
background-color: transparent;
|
|
22
|
+
border: none;
|
|
23
|
+
color: var(--metadata);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
margin-left: var(--gap);
|
|
26
|
+
|
|
27
|
+
&:hover {
|
|
28
|
+
color: var(--hard-metadata);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
package/dist/es/a/index.js
CHANGED
|
@@ -20,4 +20,5 @@ export { MetaCard } from "./MetaCard";
|
|
|
20
20
|
export { AnimatedBlobs } from "./AnimatedBlobs";
|
|
21
21
|
export { Tip } from "./Tip";
|
|
22
22
|
export { AnimatedGradient } from "./AnimatedGradient";
|
|
23
|
-
export { TextSteps } from "./TextSteps";
|
|
23
|
+
export { TextSteps } from "./TextSteps";
|
|
24
|
+
export { Removable } from "./Removable";
|
|
@@ -20,6 +20,7 @@ const Button = ({
|
|
|
20
20
|
children,
|
|
21
21
|
isLoading,
|
|
22
22
|
color,
|
|
23
|
+
textColor,
|
|
23
24
|
isCompact,
|
|
24
25
|
isGhost,
|
|
25
26
|
isSimple,
|
|
@@ -36,7 +37,7 @@ const Button = ({
|
|
|
36
37
|
}, children) : children;
|
|
37
38
|
return /*#__PURE__*/React.createElement("button", _extends({
|
|
38
39
|
id: id,
|
|
39
|
-
className: [baseClassName, componentClassName, userClassName, `x-${color}`, isGhost && styleNames.modifierGhost, isCompact && styleNames.modifierCompact, isSimple && styleNames.modifierSimple, isGradient && styleNames.modifierGradient, isSpaced && styleNames.modifierSpaced, !isLoading && arrowDirection && `arrow-${arrowDirection}`].filter(e => e).join(' '),
|
|
40
|
+
className: [baseClassName, componentClassName, userClassName, `x-${color}`, textColor && `y-${textColor}`, isGhost && styleNames.modifierGhost, isCompact && styleNames.modifierCompact, isSimple && styleNames.modifierSimple, isGradient && styleNames.modifierGradient, isSpaced && styleNames.modifierSpaced, !isLoading && arrowDirection && `arrow-${arrowDirection}`].filter(e => e).join(' '),
|
|
40
41
|
style: style,
|
|
41
42
|
type: "button"
|
|
42
43
|
}, otherProps), isLoading ? /*#__PURE__*/React.createElement(LoadingCircle, {
|
|
@@ -92,7 +92,7 @@ $default-animation-time: .31s;
|
|
|
92
92
|
&.#{bem.$modifier-ghost} {
|
|
93
93
|
background: transparent;
|
|
94
94
|
border: 1px solid var(--x, var(--#{$default-color}));
|
|
95
|
-
color: var(--x, var(--#{$default-color}));
|
|
95
|
+
color: var(--y, var(--x, var(--#{$default-color})));
|
|
96
96
|
|
|
97
97
|
&:hover,
|
|
98
98
|
&:focus,
|
|
@@ -103,12 +103,12 @@ $default-animation-time: .31s;
|
|
|
103
103
|
&:not(:disabled) {
|
|
104
104
|
&:hover {
|
|
105
105
|
border: 1px solid var(--soft-x, var(--soft-#{$default-color}));
|
|
106
|
-
color: var(--soft-x, var(--soft-#{$default-color}));
|
|
106
|
+
color: var(--soft-y, var(--soft-x, var(--soft-#{$default-color})));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
&:focus {
|
|
110
110
|
border: 1px solid var(--hard-x, var(--hard-#{$default-color}));
|
|
111
|
-
color: var(--hard-x, var(--hard-#{$default-color}));
|
|
111
|
+
color: var(--hard-y, var(--hard-x, var(--hard-#{$default-color})));
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -25,13 +25,14 @@ const Description = ({
|
|
|
25
25
|
useInsertionEffect(() => {
|
|
26
26
|
import("./styles.scss");
|
|
27
27
|
}, []);
|
|
28
|
-
const [
|
|
29
|
-
|
|
28
|
+
const [, meta] = useField(name);
|
|
29
|
+
const hasError = meta.touched && meta.error;
|
|
30
|
+
if (hasError || description) {
|
|
30
31
|
return /*#__PURE__*/React.createElement("div", {
|
|
31
32
|
id: id,
|
|
32
|
-
className: [baseClassName, componentClassName, userClassName,
|
|
33
|
+
className: [baseClassName, componentClassName, userClassName, hasError ? 'x-error' : `x-${color}`].filter(e => e).join(' '),
|
|
33
34
|
style: style
|
|
34
|
-
}, meta.error
|
|
35
|
+
}, hasError ? meta.error : description);
|
|
35
36
|
}
|
|
36
37
|
return null;
|
|
37
38
|
};
|