5htp-core 0.6.0-95 → 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.
@@ -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-95",
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",