5htp-core 0.6.0-94 → 0.6.0-96

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.
@@ -236,9 +236,19 @@ export default ({
236
236
  if (disabled)
237
237
  return false;
238
238
 
239
+ // Custom event
240
+ if (props.onClick !== undefined) {
241
+
242
+ const returned = props.onClick(e);
243
+ if (async && returned?.then) {
244
+ setLoading(true);
245
+ returned.finally(() => setLoading(false));
246
+ }
247
+ }
248
+
239
249
  // Link
240
250
  let nativeEvent: boolean = false;
241
- if ('link' in props) {
251
+ if (('link' in props) && !e.defaultPrevented) {
242
252
 
243
253
  // Nouvelle fenetre = event par defaut
244
254
  if (props.target === '_blank') {
@@ -257,16 +267,6 @@ export default ({
257
267
  }
258
268
  }
259
269
 
260
- // Custom event
261
- if (props.onClick !== undefined) {
262
-
263
- const returned = props.onClick(e);
264
- if (async && returned?.then) {
265
- setLoading(true);
266
- returned.finally(() => setLoading(false));
267
- }
268
- }
269
-
270
270
  if (!nativeEvent) {
271
271
  e.preventDefault();
272
272
  return false;
@@ -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
  })}
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-94",
4
+ "version": "0.6.0-96",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -637,7 +637,9 @@ export default class ServerRouter
637
637
 
638
638
  // Don't exose technical errors to users
639
639
  if (this.app.env.profile === 'prod')
640
- e.message = "We encountered an internal error, and our team has just been notified. Sorry for the inconvenience.";
640
+ e = new Error(
641
+ "We encountered an internal error, and our team has just been notified. Sorry for the inconvenience."
642
+ );
641
643
 
642
644
  } else {
643
645