5htp-core 0.6.0-95 → 0.6.0-97

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.
@@ -20,13 +20,16 @@ export type Props = JSX.HTMLAttributes<HTMLDivElement> & {
20
20
  id?: string,
21
21
 
22
22
  // Display
23
+ mode: 'hide' | 'remove',
23
24
  content?: ComponentChild | JSX.Element
24
25
  state?: [boolean, StateUpdater<boolean>],
25
26
  width?: number | string,
26
27
  disable?: boolean
28
+
27
29
  // Position
28
30
  frame?: HTMLElement,
29
31
  side?: TSide,
32
+
30
33
  // Tag
31
34
  children: JSX.Element | [JSX.Element],
32
35
  tag?: string,
@@ -45,7 +48,7 @@ export default (props: Props) => {
45
48
  let {
46
49
  id,
47
50
 
48
- content, state, width, disable,
51
+ mode = 'remove', content, state, width, disable,
49
52
 
50
53
  frame, side = 'bottom',
51
54
 
@@ -108,7 +111,7 @@ export default (props: Props) => {
108
111
  const Tag = tag || 'div';
109
112
 
110
113
  let renderedContent: ComponentChild;
111
- if (active) {
114
+ if (active || mode === 'hide') {
112
115
  //content = typeof content === 'function' ? React.createElement(content) : content;
113
116
  renderedContent = React.cloneElement(
114
117
  content,
@@ -124,13 +127,24 @@ export default (props: Props) => {
124
127
 
125
128
  style: {
126
129
  ...(content.props.style || {}),
130
+
131
+ ...(!active && mode === 'hide' ? {
132
+ display: 'none'
133
+ } : {}),
134
+
135
+ // Positionning
127
136
  ...(position ? {
128
137
  top: position.css.top,
129
138
  left: position.css.left,
130
139
  right: position.css.right,
131
140
  bottom: position.css.bottom,
132
- } : {}),
133
- ...(width !== undefined ? { width: typeof width === 'number' ? width + 'rem' : width } : {})
141
+ } : {}),
142
+
143
+ ...(width !== undefined ? {
144
+ width: typeof width === 'number'
145
+ ? width + 'rem'
146
+ : width
147
+ } : {})
134
148
  }
135
149
  }
136
150
  )
@@ -157,6 +171,7 @@ export default (props: Props) => {
157
171
  onClick: (e) => {
158
172
  show(isShown => !isShown);
159
173
  e.stopPropagation();
174
+ e.preventDefault();
160
175
  return false;
161
176
  }
162
177
  })}
@@ -161,6 +161,21 @@ export class AuthRequired extends CoreError {
161
161
  public http = 401;
162
162
  public title = "Authentication Required";
163
163
  public static msgDefaut = "Please Login to Continue.";
164
+
165
+ public constructor(
166
+ message: string,
167
+ public motivation?: string,
168
+ details?: TErrorDetails
169
+ ) {
170
+ super(message, details);
171
+ }
172
+
173
+ public json(): TJsonError & { motivation?: string } {
174
+ return {
175
+ ...super.json(),
176
+ motivation: this.motivation,
177
+ }
178
+ }
164
179
  }
165
180
 
166
181
  export class UpgradeRequired extends CoreError {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.6.0-95",
4
+ "version": "0.6.0-97",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -189,13 +189,30 @@ export default abstract class AuthService<
189
189
  request.res.clearCookie('authorization');
190
190
  }
191
191
 
192
- public check( request: TRequest, role: TUserRole): TUser;
193
- public check( request: TRequest, role: false): null;
194
- public check( request: TRequest, role: TUserRole | false = 'USER'): TUser | null {
192
+ public check(
193
+ request: TRequest,
194
+ role: TUserRole,
195
+ motivation?: string,
196
+ dataForDebug?: { [key: string]: any }
197
+ ): TUser;
198
+
199
+ public check(
200
+ request: TRequest,
201
+ role: false,
202
+ motivation?: string,
203
+ dataForDebug?: { [key: string]: any }
204
+ ): null;
205
+
206
+ public check(
207
+ request: TRequest,
208
+ role: TUserRole | false = 'USER',
209
+ motivation?: string,
210
+ dataForDebug?: { [key: string]: any }
211
+ ): TUser | null {
195
212
 
196
213
  const user = request.user;
197
214
 
198
- this.config.debug && console.warn(LogPrefix, `Check auth, role = ${role}. Current user =`, user?.name);
215
+ this.config.debug && console.warn(LogPrefix, `Check auth, role = ${role}. Current user =`, user?.name, motivation);
199
216
 
200
217
  if (user === undefined) {
201
218
 
@@ -210,7 +227,7 @@ export default abstract class AuthService<
210
227
  } else if (user === null) {
211
228
 
212
229
  this.config.debug && console.warn(LogPrefix, "Refusé pour anonyme (" + request.ip + ")");
213
- throw new AuthRequired('Please login to continue');
230
+ throw new AuthRequired('Please login to continue', motivation, dataForDebug);
214
231
 
215
232
  // Insufficient permissions
216
233
  } else if (!user.roles.includes(role)) {
@@ -45,9 +45,9 @@ export default class UsersRequestService<
45
45
  }
46
46
 
47
47
  // TODO: return user type according to entity
48
- public check(role: TUserRole, motivation?: string): TUser;
49
- public check(role: false, motivation?: string): null;
50
- public check(role: TUserRole | boolean = 'USER', motivation?: string): TUser | null {
51
- return this.users.check( this.request, role, motivation );
48
+ public check(role: TUserRole, motivation?: string, dataForDebug?: {}): TUser;
49
+ public check(role: false, motivation?: string, dataForDebug?: {}): null;
50
+ public check(role: TUserRole | boolean = 'USER', motivation?: string, dataForDebug?: {}): TUser | null {
51
+ return this.users.check( this.request, role, motivation, dataForDebug );
52
52
  }
53
53
  }
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
1
- export type TIcones = "long-arrow-right"|"times"|"solid/spinner-third"|"check-circle"|"coins"|"building"|"at"|"phone"|"bolt"|"brands/linkedin"|"rocket"|"chart-bar"|"user-circle"|"plane-departure"|"plus-circle"|"comments-alt"|"arrow-right"|"crosshairs"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"star"|"link"|"file-alt"|"long-arrow-left"|"calendar-alt"|"paper-plane"|"user-plus"|"magnet"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"user"|"sun"|"brands/whatsapp"|"search"|"lightbulb"|"angle-up"|"angle-down"|"solid/crown"|"eye"|"pen"|"plus"|"file"|"envelope"|"clock"|"cog"|"trash"|"ellipsis-h"|"check"|"pencil"|"regular/shield-check"|"binoculars"|"download"|"exclamation-circle"|"times-circle"|"arrow-left"|"meh-rolling-eyes"|"bars"|"solid/star"|"solid/star-half-alt"|"regular/star"|"chevron-left"|"power-off"|"external-link"|"question-circle"|"play"|"minus-circle"|"wind"|"users"|"bug"|"map-marker-alt"|"arrow-to-bottom"|"broom"|"brands/google"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"exclamation-triangle"|"minus"|"plug"|"comment-alt"|"coin"|"briefcase"|"map-marker"|"fire"|"solid/magic"|"industry"|"calendar"|"globe"|"magic"|"graduation-cap"|"code"|"bold"|"italic"|"underline"|"font"|"strikethrough"|"subscript"|"superscript"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"unlink"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
1
+ export type TIcones = "solid/spinner-third"|"long-arrow-right"|"times-circle"|"brands/whatsapp"|"times"|"search"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"exclamation"|"exclamation-circle"|"solid/download"|"angle-down"|"info-circle"|"check-circle"|"home"|"user-circle"|"newspaper"|"plus-circle"|"brands/linkedin"|"brands/twitter"|"brands/facebook"|"books"|"box-full"|"planet-ringed"|"chart-bar"|"power-off"|"comment-alt"|"heart"|"chart-line"|"lock"|"eye"|"credit-card"|"at"|"key"|"bars"|"font"|"tag"|"compress"|"bolt"|"puzzle-piece"|"hourglass-half"|"hourglass-end"|"rocket"|"seedling"|"palette"|"car"|"plane"|"university"|"briefcase"|"hard-hat"|"graduation-cap"|"cogs"|"film"|"leaf"|"tshirt"|"utensils"|"globe"|"map-marked-alt"|"dumbbell"|"stethoscope"|"concierge-bell"|"book"|"shield-alt"|"gavel"|"industry"|"square-root-alt"|"pills"|"medal"|"capsules"|"balance-scale"|"praying-hands"|"shopping-cart"|"flask"|"futbol"|"microchip"|"satellite-dish"|"shipping-fast"|"passport"|"tools"|"database"|"brain"|"download"|"code"|"money-bill"|"angle-left"|"angle-right"|"paper-plane"|"brands/google"|"check"|"trash"|"meh-rolling-eyes"|"arrow-left"|"arrow-right"|"link"|"file"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"unlink"|"pen"|"plus"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"