@proteinjs/user-ui 1.0.11 → 1.0.13

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/.eslintrc.js ADDED
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'prettier'],
3
+ parser: '@typescript-eslint/parser',
4
+ plugins: ['@typescript-eslint', 'prettier'],
5
+ root: true,
6
+ ignorePatterns: ['**/dist/*', '**/node_modules/*'],
7
+
8
+ rules: {
9
+ 'prettier/prettier': ['warn'],
10
+ curly: ['warn'],
11
+ 'eol-last': ['warn', 'always'],
12
+ 'keyword-spacing': ['warn', { before: true }],
13
+ 'no-undef': 'off',
14
+ '@typescript-eslint/no-unused-vars': 'off',
15
+ '@typescript-eslint/no-var-requires': 'off',
16
+ '@typescript-eslint/no-explicit-any': 'off',
17
+ '@typescript-eslint/prefer-as-const': 'off',
18
+ '@typescript-eslint/ban-types': 'off',
19
+ },
20
+ };
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ dist/
3
+ .DS_Store
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "trailingComma": "es5",
3
+ "tabWidth": 2,
4
+ "semi": true,
5
+ "singleQuote": true,
6
+ "jsxSingleQuote": true,
7
+ "printWidth": 120
8
+ }
package/CHANGELOG.md CHANGED
@@ -3,14 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [1.0.11](https://github.com/proteinjs/user/compare/@proteinjs/user-ui@1.0.10...@proteinjs/user-ui@1.0.11) (2024-05-09)
6
+ ## [1.0.13](https://github.com/proteinjs/user/compare/@proteinjs/user-ui@1.0.12...@proteinjs/user-ui@1.0.13) (2024-05-10)
7
7
 
8
- **Note:** Version bump only for package @proteinjs/user-ui
8
+
9
+ ### Bug Fixes
10
+
11
+ * add linting and lint all files ([71defcd](https://github.com/proteinjs/user/commit/71defcd78dc479d2eef1f624c746c879f4e31daa))
9
12
 
10
13
 
11
14
 
12
15
 
13
16
 
17
+ ## [1.0.11](https://github.com/proteinjs/user/compare/@proteinjs/user-ui@1.0.10...@proteinjs/user-ui@1.0.11) (2024-05-09)
18
+
19
+ **Note:** Version bump only for package @proteinjs/user-ui
20
+
14
21
  ## 1.0.1 (2024-04-19)
15
22
 
16
23
  **Note:** Version bump only for package @proteinjs/user-ui
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticatedPageContainer.d.ts","sourceRoot":"","sources":["../../src/AuthenticatedPageContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAuB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAIxE,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAE/E,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,qBAyChF"}
1
+ {"version":3,"file":"AuthenticatedPageContainer.d.ts","sourceRoot":"","sources":["../../src/AuthenticatedPageContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAuB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAIxE,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAE/E,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,qBA6ChF"}
@@ -74,12 +74,15 @@ function AuthenticatedPageContainer(props) {
74
74
  isLoggedIn: isLoggedIn,
75
75
  canViewPage: function (page) {
76
76
  var _a, _b, _c, _d;
77
- if ((_a = page.auth) === null || _a === void 0 ? void 0 : _a.public)
77
+ if ((_a = page.auth) === null || _a === void 0 ? void 0 : _a.public) {
78
78
  return true;
79
- if ((_b = page.auth) === null || _b === void 0 ? void 0 : _b.allUsers)
79
+ }
80
+ if ((_b = page.auth) === null || _b === void 0 ? void 0 : _b.allUsers) {
80
81
  return user_1.UserAuth.isLoggedIn();
81
- if (!((_c = page.auth) === null || _c === void 0 ? void 0 : _c.roles))
82
+ }
83
+ if (!((_c = page.auth) === null || _c === void 0 ? void 0 : _c.roles)) {
82
84
  return user_1.UserAuth.hasRole('admin');
85
+ }
83
86
  return user_1.UserAuth.hasRoles((_d = page.auth) === null || _d === void 0 ? void 0 : _d.roles);
84
87
  },
85
88
  login: Login_1.loginPath,
@@ -92,19 +95,20 @@ function AuthenticatedPageContainer(props) {
92
95
  redirect: 'follow',
93
96
  credentials: 'same-origin',
94
97
  headers: {
95
- 'Content-Type': 'application/json'
96
- }
98
+ 'Content-Type': 'application/json',
99
+ },
97
100
  })];
98
101
  case 1:
99
102
  response = _a.sent();
100
- if (response.status != 200)
103
+ if (response.status != 200) {
101
104
  throw new Error("Failed to log out");
105
+ }
102
106
  new user_1.UserRepo().setUser(user_1.guestUser);
103
107
  setIsLoggedIn(false);
104
108
  return [2 /*return*/, Login_1.loginPath];
105
109
  }
106
110
  });
107
- }); }
111
+ }); },
108
112
  } }, other)));
109
113
  }
110
114
  exports.AuthenticatedPageContainer = AuthenticatedPageContainer;
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticatedPageContainer.js","sourceRoot":"","sources":["../../src/AuthenticatedPageContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oCAAwE;AACxE,wCAAwE;AACxE,uCAA0C;AAI1C,SAAgB,0BAA0B,CAAC,KAAsC;IAAjF,iBAyCC;IAxCG,IAAW,KAAK,UAAK,KAAK,EAApB,EAAY,CAAQ,CAAC;IACrB,IAAA,KAA8B,eAAK,CAAC,QAAQ,CAAC,eAAQ,CAAC,UAAU,EAAE,CAAC,EAAlE,UAAU,QAAA,EAAE,aAAa,QAAyC,CAAC;IAE1E,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AAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;6BACtC;4BAED,IAAI,eAAQ,EAAE,CAAC,OAAO,CAAC,gBAAS,CAAC,CAAC;4BAClC,aAAa,CAAC,KAAK,CAAC,CAAC;4BACrB,sBAAO,iBAAS,EAAC;;;iBAClB;SACF,IACG,KAAK,EACT,CACH,CAAC;AACJ,CAAC;AA7CD,gEA6CC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../src/pages/Login.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAA+D,MAAM,eAAe,CAAC;AAGlG,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,SAAS,EAAE,IAgBvB,CAAA"}
1
+ {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../src/pages/Login.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAA+D,MAAM,eAAe,CAAC;AAGlG,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,SAAS,EAAE,IAgBvB,CAAC"}
@@ -66,18 +66,18 @@ exports.loginPage = {
66
66
  public: true,
67
67
  },
68
68
  component: function () { return (react_1.default.createElement(ui_1.FormPage, null,
69
- react_1.default.createElement(ui_1.Form, { name: 'Login', createFields: function () { return new LoginFields(); }, fieldLayout: ['email', 'password'], buttons: buttons }))); }
69
+ react_1.default.createElement(ui_1.Form, { name: 'Login', createFields: function () { return new LoginFields(); }, fieldLayout: ['email', 'password'], buttons: buttons }))); },
70
70
  };
71
71
  var LoginFields = /** @class */ (function (_super) {
72
72
  __extends(LoginFields, _super);
73
73
  function LoginFields() {
74
74
  var _this = _super !== null && _super.apply(this, arguments) || this;
75
75
  _this.email = (0, ui_1.textField)({
76
- name: 'email'
76
+ name: 'email',
77
77
  });
78
78
  _this.password = (0, ui_1.textField)({
79
79
  name: 'password',
80
- isPassword: true
80
+ isPassword: true,
81
81
  });
82
82
  return _this;
83
83
  }
@@ -102,28 +102,30 @@ var buttons = {
102
102
  method: user_1.routes.login.method,
103
103
  body: JSON.stringify({
104
104
  email: fields.email.field.value,
105
- password: fields.password.field.value
105
+ password: fields.password.field.value,
106
106
  }),
107
107
  redirect: 'follow',
108
108
  credentials: 'same-origin',
109
109
  headers: {
110
- 'Content-Type': 'application/json'
111
- }
110
+ 'Content-Type': 'application/json',
111
+ },
112
112
  })];
113
113
  case 1:
114
114
  response = _a.sent();
115
- if (response.status != 200)
115
+ if (response.status != 200) {
116
116
  throw new Error("Failed to login, error: ".concat(response.statusText));
117
+ }
117
118
  return [4 /*yield*/, response.json()];
118
119
  case 2:
119
120
  body = _a.sent();
120
- if (body.error)
121
+ if (body.error) {
121
122
  throw new Error(body.error);
123
+ }
122
124
  window.location.href = '/';
123
125
  return [2 /*return*/];
124
126
  }
125
127
  });
126
- }); }
127
- }
128
+ }); },
129
+ },
128
130
  };
129
131
  //# sourceMappingURL=Login.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Login.js","sourceRoot":"","sources":["../../../src/pages/Login.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oCAAkG;AAClG,wCAAwC;AAE3B,QAAA,SAAS,GAAG,OAAO,CAAC;AACpB,QAAA,SAAS,GAAS;IAC3B,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE;QACF,MAAM,EAAE,IAAI;KACf;IACD,SAAS,EAAE,cAAM,OAAA,CACb,8BAAC,aAAQ;QACL,8BAAC,SAAI,IACD,IAAI,EAAC,OAAO,EACZ,YAAY,EAAE,cAAM,OAAA,IAAI,WAAW,EAAE,EAAjB,CAAiB,EACrC,WAAW,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAClC,OAAO,EAAE,OAAO,GAClB,CACK,CACd,EATgB,CAShB;CACJ,CAAA;AAED;IAA0B,+BAAM;IAAhC;QAAA,qEAa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D,OAAO,EAAE,UAAO,MAAmB,EAAE,OAAiC;;;;4BACnD,qBAAM,KAAK,CAAC,aAAM,CAAC,KAAK,CAAC,IAAI,EAAE;4BAC9C,MAAM,EAAE,aAAM,CAAC,KAAK,CAAC,MAAM;4BAC3B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gCACnB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK;gCAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK;6BACtC,CAAC;4BACF,QAAQ,EAAE,QAAQ;4BAClB,WAAW,EAAE,aAAa;4BAC1B,OAAO,EAAE;gCACP,cAAc,EAAE,kBAAkB;6BACnC;yBACF,CAAC,EAAA;;wBAXI,QAAQ,GAAG,SAWf;wBACF,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;4BAC1B,MAAM,IAAI,KAAK,CAAC,kCAA2B,QAAQ,CAAC,UAAU,CAAE,CAAC,CAAC;yBACnE;wBAEY,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAA5B,IAAI,GAAG,SAAqB;wBAClC,IAAI,IAAI,CAAC,KAAK,EAAE;4BACd,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBAC7B;wBAED,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC;;;;aAC5B;KACF;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Signup.d.ts","sourceRoot":"","sources":["../../../src/pages/Signup.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAA+D,MAAM,eAAe,CAAC;AAGlG,eAAO,MAAM,UAAU,EAAE,IAgBxB,CAAA"}
1
+ {"version":3,"file":"Signup.d.ts","sourceRoot":"","sources":["../../../src/pages/Signup.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAA+D,MAAM,eAAe,CAAC;AAGlG,eAAO,MAAM,UAAU,EAAE,IAgBxB,CAAC"}
@@ -65,25 +65,25 @@ exports.signupPage = {
65
65
  public: true,
66
66
  },
67
67
  component: function () { return (react_1.default.createElement(ui_1.FormPage, null,
68
- react_1.default.createElement(ui_1.Form, { name: 'Sign Up', createFields: function () { return new SignupFields(); }, fieldLayout: ['name', 'email', 'password', 'confirmPassword'], buttons: buttons }))); }
68
+ react_1.default.createElement(ui_1.Form, { name: 'Sign Up', createFields: function () { return new SignupFields(); }, fieldLayout: ['name', 'email', 'password', 'confirmPassword'], buttons: buttons }))); },
69
69
  };
70
70
  var SignupFields = /** @class */ (function (_super) {
71
71
  __extends(SignupFields, _super);
72
72
  function SignupFields() {
73
73
  var _this = _super !== null && _super.apply(this, arguments) || this;
74
74
  _this.name = (0, ui_1.textField)({
75
- name: 'name'
75
+ name: 'name',
76
76
  });
77
77
  _this.email = (0, ui_1.textField)({
78
- name: 'email'
78
+ name: 'email',
79
79
  });
80
80
  _this.password = (0, ui_1.textField)({
81
81
  name: 'password',
82
- isPassword: true
82
+ isPassword: true,
83
83
  });
84
84
  _this.confirmPassword = (0, ui_1.textField)({
85
85
  name: 'confirmPassword',
86
- isPassword: true
86
+ isPassword: true,
87
87
  });
88
88
  return _this;
89
89
  }
@@ -109,27 +109,29 @@ var buttons = {
109
109
  body: JSON.stringify({
110
110
  name: fields.name.field.value,
111
111
  email: fields.email.field.value,
112
- password: fields.password.field.value
112
+ password: fields.password.field.value,
113
113
  }),
114
114
  redirect: 'follow',
115
115
  credentials: 'same-origin',
116
116
  headers: {
117
- 'Content-Type': 'application/json'
118
- }
117
+ 'Content-Type': 'application/json',
118
+ },
119
119
  })];
120
120
  case 1:
121
121
  response = _a.sent();
122
- if (response.status != 200)
122
+ if (response.status != 200) {
123
123
  throw new Error("Failed to signup, error: ".concat(response.statusText));
124
+ }
124
125
  return [4 /*yield*/, response.json()];
125
126
  case 2:
126
127
  body = _a.sent();
127
- if (body.error)
128
+ if (body.error) {
128
129
  throw new Error(body.error);
130
+ }
129
131
  return [2 /*return*/, "Successfully created your account! Please check your email for an email confirmation."];
130
132
  }
131
133
  });
132
- }); }
133
- }
134
+ }); },
135
+ },
134
136
  };
135
137
  //# sourceMappingURL=Signup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Signup.js","sourceRoot":"","sources":["../../../src/pages/Signup.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oCAAkG;AAClG,wCAAwC;AAE3B,QAAA,UAAU,GAAS;IAC5B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE;QACF,MAAM,EAAE,IAAI;KACf;IACD,SAAS,EAAE,cAAM,OAAA,CACb,8BAAC,aAAQ;QACL,8BAAC,SAAI,IACD,IAAI,EAAC,SAAS,EACd,YAAY,EAAE,cAAM,OAAA,IAAI,YAAY,EAAE,EAAlB,CAAkB,EACtC,WAAW,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,iBAAiB,CAAC,EAC7D,OAAO,EAAE,OAAO,GAClB,CACK,CACd,EATgB,CAShB;CACJ,CAAA;AAED;IAA2B,gCAAM;IAAjC;QAAA,qEAsBC;QAjBG,UAAI,GAAG,IAAA,cAAS,EAAe;YAC3B,IAAI,EAAE,MAAM;SACf,CAAC,CAAC;QAEH,WAAK,GAAG,IAAA,cAAS,EAAe;YAC5B,IAAI,EAAE,OAAO;SAChB,CAAC,CAAC;QAEH,cAAQ,GAAG,IAAA,cAAS,EAAe;YAC/B,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;QAEH,qBAAe,GAAG,IAAA,cAAS,EAAe;YACtC,IAAI,EAAE,iBAAiB;YACvB,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;;IACP,CAAC;IArBU,mBAAM,GAAb;QACI,OAAO,IAAI,YAAY,EAAE,CAAC;IAC9B,CAAC;IAmBL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D,qBAAM,KAAK,CAAC,aAAM,CAAC,UAAU,CAAC,IAAI,EAAE;4BACnD,MAAM,EAAE,aAAM,CAAC,UAAU,CAAC,MAAM;4BAChC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gCACnB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK;gCAC7B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK;gCAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK;6BACtC,CAAC;4BACF,QAAQ,EAAE,QAAQ;4BAClB,WAAW,EAAE,aAAa;4BAC1B,OAAO,EAAE;gCACP,cAAc,EAAE,kBAAkB;6BACnC;yBACF,CAAC,EAAA;;wBAZI,QAAQ,GAAG,SAYf;wBACF,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;4BAC1B,MAAM,IAAI,KAAK,CAAC,mCAA4B,QAAQ,CAAC,UAAU,CAAE,CAAC,CAAC;yBACpE;wBAEY,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAA5B,IAAI,GAAG,SAAqB;wBAClC,IAAI,IAAI,CAAC,KAAK,EAAE;4BACd,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBAC7B;wBAED,sBAAO,uFAAuF,EAAC;;;aAChG;KACF;CACF,CAAC"}
@@ -8,11 +8,10 @@ import 'moment';
8
8
  import 'react';
9
9
  import 'react-dom';
10
10
 
11
-
12
11
  /** Generate Source Graph */
13
12
 
14
- const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"/Omit\"},{\"v\":\"@proteinjs/user-ui/loginPage\",\"value\":{\"packageName\":\"@proteinjs/user-ui\",\"name\":\"loginPage\",\"filePath\":\"/home/runner/work/user/user/packages/ui/src/pages/Login.tsx\",\"qualifiedName\":\"@proteinjs/user-ui/loginPage\",\"type\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"Page\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/ui/Page\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/ui\",\"name\":\"Page\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/ui/Page\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/ui/Page\"},{\"v\":\"@proteinjs/user-ui/signupPage\",\"value\":{\"packageName\":\"@proteinjs/user-ui\",\"name\":\"signupPage\",\"filePath\":\"/home/runner/work/user/user/packages/ui/src/pages/Signup.tsx\",\"qualifiedName\":\"@proteinjs/user-ui/signupPage\",\"type\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"Page\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/ui/Page\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/ui\",\"name\":\"Page\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/ui/Page\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}}],\"edges\":[{\"v\":\"@proteinjs/user-ui/loginPage\",\"w\":\"@proteinjs/ui/Page\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-ui/signupPage\",\"w\":\"@proteinjs/ui/Page\",\"value\":\"has type\"}]}";
15
-
13
+ const sourceGraph =
14
+ '{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"/Omit"},{"v":"@proteinjs/user-ui/loginPage","value":{"packageName":"@proteinjs/user-ui","name":"loginPage","filePath":"/home/runner/work/user/user/packages/ui/src/pages/Login.tsx","qualifiedName":"@proteinjs/user-ui/loginPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/ui/Page"},{"v":"@proteinjs/user-ui/signupPage","value":{"packageName":"@proteinjs/user-ui","name":"signupPage","filePath":"/home/runner/work/user/user/packages/ui/src/pages/Signup.tsx","qualifiedName":"@proteinjs/user-ui/signupPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}}],"edges":[{"v":"@proteinjs/user-ui/loginPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/user-ui/signupPage","w":"@proteinjs/ui/Page","value":"has type"}]}';
16
15
 
17
16
  /** Generate Source Links */
18
17
 
@@ -20,15 +19,13 @@ import { loginPage } from '../src/pages/Login';
20
19
  import { signupPage } from '../src/pages/Signup';
21
20
 
22
21
  const sourceLinks = {
23
- '@proteinjs/user-ui/loginPage': loginPage,
24
- '@proteinjs/user-ui/signupPage': signupPage,
22
+ '@proteinjs/user-ui/loginPage': loginPage,
23
+ '@proteinjs/user-ui/signupPage': signupPage,
25
24
  };
26
25
 
27
-
28
26
  /** Load Source Graph and Links */
29
27
 
30
28
  import { SourceRepository } from '@proteinjs/reflection';
31
29
  SourceRepository.merge(sourceGraph, sourceLinks);
32
30
 
33
-
34
- export * from '../index';
31
+ export * from '../index';
package/index.ts CHANGED
@@ -1 +1 @@
1
- export * from './src/AuthenticatedPageContainer';
1
+ export * from './src/AuthenticatedPageContainer';
package/jest.config.js CHANGED
@@ -1,18 +1,9 @@
1
1
  module.exports = {
2
- "roots": [
3
- "<rootDir>/test"
4
- ],
5
- "transform": {
6
- "^.+\\.tsx?$": "ts-jest"
7
- },
8
- "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
9
- "moduleFileExtensions": [
10
- "ts",
11
- "tsx",
12
- "js",
13
- "jsx",
14
- "json",
15
- "node"
16
- ],
17
- "testEnvironment": "node"
18
- }
2
+ roots: ['<rootDir>/test'],
3
+ transform: {
4
+ '^.+\\.tsx?$': 'ts-jest',
5
+ },
6
+ testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
7
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
8
+ testEnvironment: 'node',
9
+ };
package/package.json CHANGED
@@ -1,42 +1,47 @@
1
1
  {
2
- "name": "@proteinjs/user-ui",
3
- "version": "1.0.11",
4
- "description": "User ui components",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/proteinjs/user.git"
11
- },
12
- "bugs": {
13
- "url": "https://github.com/proteinjs/user/issues"
14
- },
15
- "homepage": "https://github.com/proteinjs/user#readme",
16
- "author": "Brent Bahry",
17
- "license": "MIT",
18
- "scripts": {
19
- "clean": "rm -rf dist/ generated/ node_modules/",
20
- "build": "reflection-build && tsc",
21
- "watch": "reflection-watch"
22
- },
23
- "dependencies": {
24
- "@proteinjs/reflection": "1.1.1",
25
- "@proteinjs/server-api": "1.1.1",
26
- "@proteinjs/ui": "2.0.2",
27
- "@proteinjs/user": "^1.0.11",
28
- "moment": "2.29.4",
29
- "react": "18.2.0",
30
- "react-dom": "18.2.0"
31
- },
32
- "devDependencies": {
33
- "@proteinjs/reflection-build": "1.0.16",
34
- "@types/node": "14.0.13",
35
- "@types/react": "18.2.23",
36
- "@types/react-dom": "18.2.8",
37
- "typescript": "5.2.2"
38
- },
39
- "main": "./dist/generated/index.js",
40
- "types": "./dist/generated/index.d.ts",
41
- "gitHead": "bbd5f6349a82d7d5fa7b5c9261ba6495ebcf5749"
2
+ "name": "@proteinjs/user-ui",
3
+ "version": "1.0.13",
4
+ "description": "User ui components",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/proteinjs/user.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/proteinjs/user/issues"
14
+ },
15
+ "homepage": "https://github.com/proteinjs/user#readme",
16
+ "author": "Brent Bahry",
17
+ "license": "MIT",
18
+ "scripts": {
19
+ "clean": "rm -rf dist/ generated/ node_modules/",
20
+ "build": "reflection-build && tsc",
21
+ "watch": "reflection-watch"
22
+ },
23
+ "dependencies": {
24
+ "@proteinjs/reflection": "1.1.1",
25
+ "@proteinjs/server-api": "1.1.1",
26
+ "@proteinjs/ui": "2.0.2",
27
+ "@proteinjs/user": "^1.0.13",
28
+ "moment": "2.29.4",
29
+ "react": "18.2.0",
30
+ "react-dom": "18.2.0"
31
+ },
32
+ "devDependencies": {
33
+ "@proteinjs/reflection-build": "1.0.16",
34
+ "@types/node": "14.0.13",
35
+ "@types/react": "18.2.23",
36
+ "@types/react-dom": "18.2.8",
37
+ "@typescript-eslint/eslint-plugin": "7.8.0",
38
+ "@typescript-eslint/parser": "7.8.0",
39
+ "eslint": "8.57.0",
40
+ "eslint-config-prettier": "9.1.0",
41
+ "eslint-plugin-prettier": "5.1.3",
42
+ "typescript": "5.2.2"
43
+ },
44
+ "main": "./dist/generated/index.js",
45
+ "types": "./dist/generated/index.d.ts",
46
+ "gitHead": "2fd5a5ee7f68e33bf8b6ba045fd5bbd043b36e3b"
42
47
  }
@@ -6,44 +6,48 @@ import { loginPath } from './pages/Login';
6
6
  export type AuthenticatedPageContainerProps = Omit<PageContainerProps, 'auth'>;
7
7
 
8
8
  export function AuthenticatedPageContainer(props: AuthenticatedPageContainerProps) {
9
- const { ...other } = props;
10
- const [isLoggedIn, setIsLoggedIn] = React.useState(UserAuth.isLoggedIn());
9
+ const { ...other } = props;
10
+ const [isLoggedIn, setIsLoggedIn] = React.useState(UserAuth.isLoggedIn());
11
11
 
12
- return (
13
- <PageContainer
14
- auth={{
15
- isLoggedIn,
16
- canViewPage: (page: Page) => {
17
- if (page.auth?.public)
18
- return true;
12
+ return (
13
+ <PageContainer
14
+ auth={{
15
+ isLoggedIn,
16
+ canViewPage: (page: Page) => {
17
+ if (page.auth?.public) {
18
+ return true;
19
+ }
19
20
 
20
- if (page.auth?.allUsers)
21
- return UserAuth.isLoggedIn();
21
+ if (page.auth?.allUsers) {
22
+ return UserAuth.isLoggedIn();
23
+ }
22
24
 
23
- if (!page.auth?.roles)
24
- return UserAuth.hasRole('admin');
25
+ if (!page.auth?.roles) {
26
+ return UserAuth.hasRole('admin');
27
+ }
25
28
 
26
- return UserAuth.hasRoles(page.auth?.roles);
27
- },
28
- login: loginPath,
29
- logout: async () => {
30
- const response = await fetch(routes.logout.path, {
31
- method: routes.logout.method,
32
- redirect: 'follow',
33
- credentials: 'same-origin',
34
- headers: {
35
- 'Content-Type': 'application/json'
36
- }
37
- });
38
- if (response.status != 200)
39
- throw new Error(`Failed to log out`);
29
+ return UserAuth.hasRoles(page.auth?.roles);
30
+ },
31
+ login: loginPath,
32
+ logout: async () => {
33
+ const response = await fetch(routes.logout.path, {
34
+ method: routes.logout.method,
35
+ redirect: 'follow',
36
+ credentials: 'same-origin',
37
+ headers: {
38
+ 'Content-Type': 'application/json',
39
+ },
40
+ });
41
+ if (response.status != 200) {
42
+ throw new Error(`Failed to log out`);
43
+ }
40
44
 
41
- new UserRepo().setUser(guestUser);
42
- setIsLoggedIn(false);
43
- return loginPath;
44
- }
45
- }}
46
- {...other}
47
- />
48
- );
49
- }
45
+ new UserRepo().setUser(guestUser);
46
+ setIsLoggedIn(false);
47
+ return loginPath;
48
+ },
49
+ }}
50
+ {...other}
51
+ />
52
+ );
53
+ }
@@ -1,70 +1,72 @@
1
1
  import React from 'react';
2
2
  import { Page, Form, Fields, textField, FormButtons, clearButton, FormPage } from '@proteinjs/ui';
3
- import { routes } from '@proteinjs/user'
3
+ import { routes } from '@proteinjs/user';
4
4
 
5
5
  export const loginPath = 'login';
6
6
  export const loginPage: Page = {
7
- name: 'Login',
8
- path: loginPath,
9
- auth: {
10
- public: true,
11
- },
12
- component: () => (
13
- <FormPage>
14
- <Form<LoginFields, typeof buttons>
15
- name='Login'
16
- createFields={() => new LoginFields()}
17
- fieldLayout={['email', 'password']}
18
- buttons={buttons}
19
- />
20
- </FormPage>
21
- )
22
- }
7
+ name: 'Login',
8
+ path: loginPath,
9
+ auth: {
10
+ public: true,
11
+ },
12
+ component: () => (
13
+ <FormPage>
14
+ <Form<LoginFields, typeof buttons>
15
+ name='Login'
16
+ createFields={() => new LoginFields()}
17
+ fieldLayout={['email', 'password']}
18
+ buttons={buttons}
19
+ />
20
+ </FormPage>
21
+ ),
22
+ };
23
23
 
24
24
  class LoginFields extends Fields {
25
- static create() {
26
- return new LoginFields();
27
- }
25
+ static create() {
26
+ return new LoginFields();
27
+ }
28
28
 
29
- email = textField<LoginFields>({
30
- name: 'email'
31
- });
29
+ email = textField<LoginFields>({
30
+ name: 'email',
31
+ });
32
32
 
33
- password = textField<LoginFields>({
34
- name: 'password',
35
- isPassword: true
36
- });
33
+ password = textField<LoginFields>({
34
+ name: 'password',
35
+ isPassword: true,
36
+ });
37
37
  }
38
38
 
39
39
  const buttons: FormButtons<LoginFields> = {
40
- clear: clearButton,
41
- login: {
42
- name: 'Login',
43
- style: {
44
- color: 'primary',
45
- variant: 'contained',
46
- },
47
- onClick: async (fields: LoginFields, buttons: FormButtons<LoginFields>) => {
48
- const response = await fetch(routes.login.path, {
49
- method: routes.login.method,
50
- body: JSON.stringify({
51
- email: fields.email.field.value,
52
- password: fields.password.field.value
53
- }),
54
- redirect: 'follow',
55
- credentials: 'same-origin',
56
- headers: {
57
- 'Content-Type': 'application/json'
58
- }
59
- });
60
- if (response.status != 200)
61
- throw new Error(`Failed to login, error: ${response.statusText}`);
40
+ clear: clearButton,
41
+ login: {
42
+ name: 'Login',
43
+ style: {
44
+ color: 'primary',
45
+ variant: 'contained',
46
+ },
47
+ onClick: async (fields: LoginFields, buttons: FormButtons<LoginFields>) => {
48
+ const response = await fetch(routes.login.path, {
49
+ method: routes.login.method,
50
+ body: JSON.stringify({
51
+ email: fields.email.field.value,
52
+ password: fields.password.field.value,
53
+ }),
54
+ redirect: 'follow',
55
+ credentials: 'same-origin',
56
+ headers: {
57
+ 'Content-Type': 'application/json',
58
+ },
59
+ });
60
+ if (response.status != 200) {
61
+ throw new Error(`Failed to login, error: ${response.statusText}`);
62
+ }
62
63
 
63
- const body = await response.json();
64
- if (body.error)
65
- throw new Error(body.error);
64
+ const body = await response.json();
65
+ if (body.error) {
66
+ throw new Error(body.error);
67
+ }
66
68
 
67
- window.location.href = '/';
68
- }
69
- }
70
- };
69
+ window.location.href = '/';
70
+ },
71
+ },
72
+ };
@@ -1,79 +1,81 @@
1
1
  import React from 'react';
2
2
  import { Page, Form, Fields, textField, FormButtons, clearButton, FormPage } from '@proteinjs/ui';
3
- import { routes } from '@proteinjs/user'
3
+ import { routes } from '@proteinjs/user';
4
4
 
5
5
  export const signupPage: Page = {
6
- name: 'Sign Up',
7
- path: 'signup',
8
- auth: {
9
- public: true,
10
- },
11
- component: () => (
12
- <FormPage>
13
- <Form<SignupFields, typeof buttons>
14
- name='Sign Up'
15
- createFields={() => new SignupFields()}
16
- fieldLayout={['name', 'email', 'password', 'confirmPassword']}
17
- buttons={buttons}
18
- />
19
- </FormPage>
20
- )
21
- }
6
+ name: 'Sign Up',
7
+ path: 'signup',
8
+ auth: {
9
+ public: true,
10
+ },
11
+ component: () => (
12
+ <FormPage>
13
+ <Form<SignupFields, typeof buttons>
14
+ name='Sign Up'
15
+ createFields={() => new SignupFields()}
16
+ fieldLayout={['name', 'email', 'password', 'confirmPassword']}
17
+ buttons={buttons}
18
+ />
19
+ </FormPage>
20
+ ),
21
+ };
22
22
 
23
23
  class SignupFields extends Fields {
24
- static create() {
25
- return new SignupFields();
26
- }
24
+ static create() {
25
+ return new SignupFields();
26
+ }
27
27
 
28
- name = textField<SignupFields>({
29
- name: 'name'
30
- });
28
+ name = textField<SignupFields>({
29
+ name: 'name',
30
+ });
31
31
 
32
- email = textField<SignupFields>({
33
- name: 'email'
34
- });
32
+ email = textField<SignupFields>({
33
+ name: 'email',
34
+ });
35
35
 
36
- password = textField<SignupFields>({
37
- name: 'password',
38
- isPassword: true
39
- });
36
+ password = textField<SignupFields>({
37
+ name: 'password',
38
+ isPassword: true,
39
+ });
40
40
 
41
- confirmPassword = textField<SignupFields>({
42
- name: 'confirmPassword',
43
- isPassword: true
44
- });
41
+ confirmPassword = textField<SignupFields>({
42
+ name: 'confirmPassword',
43
+ isPassword: true,
44
+ });
45
45
  }
46
46
 
47
47
  const buttons: FormButtons<SignupFields> = {
48
- clear: clearButton,
49
- signup: {
50
- name: 'Sign up',
51
- style: {
52
- color: 'primary',
53
- variant: 'contained',
54
- },
55
- onClick: async (fields: SignupFields, buttons: FormButtons<SignupFields>) => {
56
- const response = await fetch(routes.createUser.path, {
57
- method: routes.createUser.method,
58
- body: JSON.stringify({
59
- name: fields.name.field.value,
60
- email: fields.email.field.value,
61
- password: fields.password.field.value
62
- }),
63
- redirect: 'follow',
64
- credentials: 'same-origin',
65
- headers: {
66
- 'Content-Type': 'application/json'
67
- }
68
- });
69
- if (response.status != 200)
70
- throw new Error(`Failed to signup, error: ${response.statusText}`);
48
+ clear: clearButton,
49
+ signup: {
50
+ name: 'Sign up',
51
+ style: {
52
+ color: 'primary',
53
+ variant: 'contained',
54
+ },
55
+ onClick: async (fields: SignupFields, buttons: FormButtons<SignupFields>) => {
56
+ const response = await fetch(routes.createUser.path, {
57
+ method: routes.createUser.method,
58
+ body: JSON.stringify({
59
+ name: fields.name.field.value,
60
+ email: fields.email.field.value,
61
+ password: fields.password.field.value,
62
+ }),
63
+ redirect: 'follow',
64
+ credentials: 'same-origin',
65
+ headers: {
66
+ 'Content-Type': 'application/json',
67
+ },
68
+ });
69
+ if (response.status != 200) {
70
+ throw new Error(`Failed to signup, error: ${response.statusText}`);
71
+ }
71
72
 
72
- const body = await response.json();
73
- if (body.error)
74
- throw new Error(body.error);
73
+ const body = await response.json();
74
+ if (body.error) {
75
+ throw new Error(body.error);
76
+ }
75
77
 
76
- return `Successfully created your account! Please check your email for an email confirmation.`;
77
- }
78
- }
79
- };
78
+ return `Successfully created your account! Please check your email for an email confirmation.`;
79
+ },
80
+ },
81
+ };
package/tsconfig.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
- "compilerOptions": {
3
- "rootDir": "./",
4
- "target": "es5",
5
- "module": "commonjs",
6
- "declaration": true,
7
- "declarationMap": true,
8
- "sourceMap": true,
9
- "outDir": "./dist/",
10
- "strict": true,
11
- "noImplicitAny": true,
12
- "esModuleInterop": true,
13
- "skipLibCheck": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "resolveJsonModule": true,
16
- "jsx": "react"
17
- }
18
- }
2
+ "compilerOptions": {
3
+ "rootDir": "./",
4
+ "target": "es5",
5
+ "module": "commonjs",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "./dist/",
10
+ "strict": true,
11
+ "noImplicitAny": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "jsx": "react"
17
+ }
18
+ }