@appquality/unguess-design-system 2.10.62 → 2.10.65

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 CHANGED
@@ -1,3 +1,41 @@
1
+ # v2.10.65 (Fri Jul 29 2022)
2
+
3
+ #### ⚠️ Pushed to `master`
4
+
5
+ - Merge branch 'master' of github.com:AppQuality/unguess-design-system ([@cannarocks](https://github.com/cannarocks))
6
+ - feat(editor): Add validation support ([@cannarocks](https://github.com/cannarocks))
7
+
8
+ #### Authors: 1
9
+
10
+ - Luca Cannarozzo ([@cannarocks](https://github.com/cannarocks))
11
+
12
+ ---
13
+
14
+ # v2.10.64 (Wed Jul 27 2022)
15
+
16
+ #### ⚠️ Pushed to `master`
17
+
18
+ - Merge branch 'master' of github.com:AppQuality/unguess-design-system ([@cannarocks](https://github.com/cannarocks))
19
+ - fix(editor): remove min height when editable is false ([@cannarocks](https://github.com/cannarocks))
20
+
21
+ #### Authors: 1
22
+
23
+ - Luca Cannarozzo ([@cannarocks](https://github.com/cannarocks))
24
+
25
+ ---
26
+
27
+ # v2.10.63 (Wed Jul 27 2022)
28
+
29
+ #### ⚠️ Pushed to `master`
30
+
31
+ - feat(editor): add read only style ([@cannarocks](https://github.com/cannarocks))
32
+
33
+ #### Authors: 1
34
+
35
+ - Luca Cannarozzo ([@cannarocks](https://github.com/cannarocks))
36
+
37
+ ---
38
+
1
39
  # v2.10.62 (Fri Jul 22 2022)
2
40
 
3
41
  #### ⚠️ Pushed to `master`
package/build/index.js CHANGED
@@ -1244,13 +1244,24 @@ var Header$1 = styled__default["default"].div(templateObject_1$T || (templateObj
1244
1244
  var theme = _a.theme;
1245
1245
  return theme.palette.grey[300];
1246
1246
  });
1247
- var Title$2 = styled__default["default"](MD)(templateObject_2$n || (templateObject_2$n = __makeTemplateObject(["\n color: ", ";\n"], ["\n color: ", ";\n"])), function (_a) {
1248
- var theme = _a.theme;
1249
- return theme.colors.primaryHue;
1247
+ var Title$2 = styled__default["default"](MD)(templateObject_2$n || (templateObject_2$n = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
1248
+ var validation = _a.validation, theme = _a.theme;
1249
+ if (validation === "success") {
1250
+ return "color: ".concat(theme.colors.successHue, ";");
1251
+ }
1252
+ else if (validation === "warning") {
1253
+ return "color: ".concat(theme.colors.warningHue, ";");
1254
+ }
1255
+ else if (validation === "error") {
1256
+ return "color: ".concat(theme.palette.dangerHue, ";");
1257
+ }
1258
+ else {
1259
+ return "color: ".concat(theme.colors.primaryHue, ";");
1260
+ }
1250
1261
  });
1251
- var EditorHeader = function (_a) {
1252
- var title = _a.title;
1253
- return (jsxRuntime.jsx(Header$1, { children: jsxRuntime.jsx(Title$2, __assign({ isBold: true }, { children: title || "Write" })) }));
1262
+ var EditorHeader = function (props) {
1263
+ var title = props.title, validation = props.validation;
1264
+ return (jsxRuntime.jsx(Header$1, { children: jsxRuntime.jsx(Title$2, __assign({ isBold: true, validation: validation }, { children: title || "Write" })) }));
1254
1265
  };
1255
1266
  var templateObject_1$T, templateObject_2$n;
1256
1267
 
@@ -1268,19 +1279,38 @@ var EditorFooter = function (_a) {
1268
1279
  };
1269
1280
  var templateObject_1$S, templateObject_2$m;
1270
1281
 
1271
- var EditorContainer = styled__default["default"].div(templateObject_1$R || (templateObject_1$R = __makeTemplateObject(["\n border: 2px solid ", ";\n border-radius: ", ";\n &:focus-within {\n outline: ", ";\n outline-style: solid;\n }\n\n .ProseMirror {\n padding: ", ";\n background-color: #fff;\n min-height: 100px;\n outline: none;\n\n ", "\n }\n"], ["\n border: 2px solid ", ";\n border-radius: ", ";\n &:focus-within {\n outline: ", ";\n outline-style: solid;\n }\n\n .ProseMirror {\n padding: ", ";\n background-color: #fff;\n min-height: 100px;\n outline: none;\n\n ", "\n }\n"])), function (_a) {
1272
- var theme = _a.theme;
1273
- return theme.colors.primaryHue;
1274
- }, function (_a) {
1282
+ var EditorContainer = styled__default["default"].div(templateObject_1$R || (templateObject_1$R = __makeTemplateObject(["\n border: 2px solid;\n border-radius: ", ";\n &:focus-within {\n outline: ", ";\n outline-style: solid;\n }\n\n ", "\n\n ", "\n\n .ProseMirror {\n padding: ", ";\n background-color: #fff;\n min-height: 100px;\n outline: none;\n\n ", "\n\n ", "\n }\n"], ["\n border: 2px solid;\n border-radius: ", ";\n &:focus-within {\n outline: ", ";\n outline-style: solid;\n }\n\n ", "\n\n ", "\n\n .ProseMirror {\n padding: ", ";\n background-color: #fff;\n min-height: 100px;\n outline: none;\n\n ", "\n\n ", "\n }\n"])), function (_a) {
1275
1283
  var theme = _a.theme;
1276
1284
  return theme.borderRadii.md;
1277
1285
  }, function (_a) {
1278
1286
  var theme = _a.theme;
1279
1287
  return theme.palette.blue["300"];
1288
+ }, function (_a) {
1289
+ var validation = _a.validation, theme = _a.theme;
1290
+ if (validation === "success") {
1291
+ return "border-color: ".concat(theme.colors.successHue, ";");
1292
+ }
1293
+ else if (validation === "warning") {
1294
+ return "border-color: ".concat(theme.colors.warningHue, ";");
1295
+ }
1296
+ else if (validation === "error") {
1297
+ return "border-color: ".concat(theme.colors.dangerHue, ";");
1298
+ }
1299
+ else {
1300
+ return "border-color: ".concat(theme.colors.primaryHue, ";");
1301
+ }
1302
+ }, function (_a) {
1303
+ var editable = _a.editable;
1304
+ return !editable &&
1305
+ "\n border: none;\n outline: none;\n \n ";
1280
1306
  }, function (_a) {
1281
1307
  var theme = _a.theme;
1282
1308
  return theme.space.md;
1283
- }, editorStyle);
1309
+ }, editorStyle, function (_a) {
1310
+ var editable = _a.editable;
1311
+ return !editable &&
1312
+ "\n background: transparent;\n border: none;\n outline: none;\n padding: 0;\n min-height: 0;\n ";
1313
+ });
1284
1314
  /**
1285
1315
  * Editor is a wrapper around TipTap/ProseMirror
1286
1316
  * <br>
@@ -1295,7 +1325,8 @@ var EditorContainer = styled__default["default"].div(templateObject_1$R || (temp
1295
1325
  */
1296
1326
  var Editor = function (_a) {
1297
1327
  var onSave = _a.onSave, headerTitle = _a.headerTitle, footerSaveText = _a.footerSaveText, placeholderOptions = _a.placeholderOptions, props = __rest(_a, ["onSave", "headerTitle", "footerSaveText", "placeholderOptions"]);
1298
- var children = props.children, hasInlineMenu = props.hasInlineMenu, bubbleOptions = props.bubbleOptions;
1328
+ var children = props.children, hasInlineMenu = props.hasInlineMenu, bubbleOptions = props.bubbleOptions, editable = props.editable;
1329
+ var isEditable = editable !== undefined ? editable : true;
1299
1330
  var _b = React.useState(), activeEditor = _b[0], setActiveEditor = _b[1];
1300
1331
  var onKeyDown = function (event) {
1301
1332
  if ((event.ctrlKey || event.metaKey) && event.key === "Enter") {
@@ -1329,7 +1360,7 @@ var Editor = function (_a) {
1329
1360
  var editor = _a.editor;
1330
1361
  return setActiveEditor(editor);
1331
1362
  });
1332
- return (jsxRuntime.jsxs(EditorContainer, { children: [jsxRuntime.jsx(EditorHeader, { title: headerTitle }), hasInlineMenu && (jsxRuntime.jsx(FloatingMenu, { editor: ed, tippyOptions: __assign({}, bubbleOptions) })), jsxRuntime.jsx(react.EditorContent, { editor: ed, onKeyDown: onKeyDown }), jsxRuntime.jsx(EditorFooter, { saveText: footerSaveText })] }));
1363
+ return (jsxRuntime.jsxs(EditorContainer, __assign({ editable: isEditable, validation: props.validation }, { children: [isEditable && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(EditorHeader, { title: headerTitle, validation: props.validation }), hasInlineMenu && (jsxRuntime.jsx(FloatingMenu, { editor: ed, tippyOptions: __assign({}, bubbleOptions) }))] })), jsxRuntime.jsx(react.EditorContent, { editor: ed, onKeyDown: onKeyDown }), isEditable && jsxRuntime.jsx(EditorFooter, { saveText: footerSaveText })] })));
1333
1364
  };
1334
1365
  var templateObject_1$R;
1335
1366
 
@@ -1,12 +1,20 @@
1
1
  import { PlaceholderOptions } from "@tiptap/extension-placeholder";
2
2
  import { BubbleMenuProps, Editor, EditorOptions } from "@tiptap/react";
3
+ declare type validationStatus = "success" | "warning" | "error";
3
4
  export interface EditorArgs extends Partial<EditorOptions> {
4
5
  placeholderOptions?: Partial<PlaceholderOptions>;
5
6
  hasInlineMenu?: boolean;
6
7
  bubbleOptions?: any;
7
8
  headerTitle?: string;
8
9
  footerSaveText?: string;
10
+ /** Applies validation state styling */
11
+ validation?: validationStatus;
9
12
  onSave?: (editor: Editor) => void;
10
13
  }
14
+ export interface EditorHeaderArgs {
15
+ title?: string;
16
+ validation?: validationStatus;
17
+ }
11
18
  export interface FloatingMenuArgs extends Partial<BubbleMenuProps> {
12
19
  }
20
+ export {};
@@ -1,3 +1,2 @@
1
- export declare const EditorHeader: ({ title }: {
2
- title?: string | undefined;
3
- }) => JSX.Element;
1
+ import { EditorHeaderArgs } from "./_types";
2
+ export declare const EditorHeader: (props: EditorHeaderArgs) => JSX.Element;
@@ -7,5 +7,7 @@ interface EditorStoryArgs extends EditorArgs {
7
7
  export declare const Default: Story<EditorStoryArgs>;
8
8
  export declare const Placeholder: Story<EditorStoryArgs>;
9
9
  export declare const BubbleMenu: Story<EditorStoryArgs>;
10
+ export declare const ReadOnly: Story<EditorStoryArgs>;
11
+ export declare const Validation: Story<EditorStoryArgs>;
10
12
  declare const _default: ComponentMeta<({ onSave, headerTitle, footerSaveText, placeholderOptions, ...props }: import("react").PropsWithChildren<EditorArgs>) => JSX.Element | null>;
11
13
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appquality/unguess-design-system",
3
- "version": "2.10.62",
3
+ "version": "2.10.65",
4
4
  "dependencies": {
5
5
  "@tiptap/extension-bubble-menu": "^2.0.0-beta.61",
6
6
  "@tiptap/extension-placeholder": "^2.0.0-beta.53",