5htp-core 0.2.6 → 0.2.7-10
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/package.json +5 -4
- package/src/client/app/index.ts +2 -2
- package/src/client/assets/css/text/icons.less +8 -2
- package/src/client/assets/css/utils/layouts.less +3 -0
- package/src/client/components/Dialog/Manager.tsx +28 -11
- package/src/client/components/Dialog/card.tsx +0 -2
- package/src/client/components/Dialog/index.less +44 -35
- package/src/client/components/Form.ts +7 -4
- package/src/client/components/Select/ChoiceSelector.tsx +29 -29
- package/src/client/components/Select/index.tsx +5 -5
- package/src/client/components/containers/Popover/getPosition.ts +2 -2
- package/src/client/components/containers/Popover/index.tsx +11 -7
- package/src/client/components/dropdown/index.tsx +11 -5
- package/src/client/components/dropdown.old/index.tsx +2 -2
- package/src/client/components/index.ts +2 -0
- package/src/client/components/input/Checkbox/index.less +0 -0
- package/src/client/components/input/Checkbox/index.tsx +58 -50
- package/src/client/components/input/Checkbox/old.tsx +74 -0
- package/src/client/components/inputv3/base.less +1 -0
- package/src/client/components/inputv3/base.tsx +13 -1
- package/src/client/components/inputv3/date/index.tsx +49 -0
- package/src/client/components/inputv3/date/react-calendar.less +143 -0
- package/src/client/components/inputv3/date/react-daterange-picker.less +112 -0
- package/src/client/components/inputv3/index.tsx +32 -10
- package/src/client/pages/useHeader.tsx +3 -2
- package/src/client/services/router/components/router.tsx +3 -2
- package/src/client/services/router/request/api.ts +0 -5
- package/src/client/services/router/request/index.ts +10 -0
- package/src/client/services/router/request/multipart.ts +120 -9
- package/src/client/utils/dom.ts +1 -3
- package/src/common/validation/validators.ts +2 -1
- package/src/server/app/config.ts +2 -0
- package/src/server/app/index.ts +4 -2
- package/src/server/services/console/index.ts +6 -4
- package/src/server/services/disks/driver.ts +77 -0
- package/src/server/services/disks/index.ts +63 -0
- package/src/server/services/fetch/index.ts +1 -1
- package/src/server/services/router/http/index.ts +7 -3
- package/src/server/services/router/index.ts +10 -2
- package/src/server/services/router/response/index.ts +3 -1
- package/src/server/services/router/response/page/document.tsx +7 -19
- package/src/server/services/router/response/page/index.tsx +17 -1
- package/src/server/services/router/service.ts +1 -1
- package/src/server/services/security/encrypt/aes.ts +22 -6
- package/src/types/global/modules.d.ts +1 -1
- package/src/client/components/input/Date/index.less +0 -167
- package/src/client/components/input/Date/index.tsx +0 -90
- package/src/client/services/metrics/index.ts +0 -37
- package/src/server/services/metrics/detect.ts +0 -109
- package/src/server/services/metrics/index.ts +0 -272
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.2.
|
|
4
|
+
"version": "0.2.7-10",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"framework"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"@wojtekmaj/react-daterange-picker": "^4.2.0",
|
|
16
17
|
"accepts": "^1.3.7",
|
|
17
18
|
"activity-detector": "^3.0.0",
|
|
18
19
|
"ansi-to-html": "^0.7.1",
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
"@types/yargs-parser": "^21.0.0",
|
|
94
95
|
"babel-plugin-glob-import": "^0.0.6-2"
|
|
95
96
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
"peerDependencies": {
|
|
98
|
+
"5htp": "0.2.3"
|
|
99
|
+
}
|
|
99
100
|
}
|
package/src/client/app/index.ts
CHANGED
|
@@ -24,8 +24,8 @@ export { default as Service } from './service';
|
|
|
24
24
|
declare global {
|
|
25
25
|
interface Window {
|
|
26
26
|
dev: boolean,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/*context: ClientContext,
|
|
28
|
+
user: User,*/
|
|
29
29
|
/*context: ClientContext,
|
|
30
30
|
user: User,*/
|
|
31
31
|
}
|
|
@@ -64,6 +64,7 @@ img.icon {
|
|
|
64
64
|
object-position: center;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
img.logo,
|
|
67
68
|
i.logo {
|
|
68
69
|
/*width: 3.2em;
|
|
69
70
|
height: 3.2em;
|
|
@@ -75,11 +76,16 @@ i.logo {
|
|
|
75
76
|
line-height: 2em;
|
|
76
77
|
flex: 0 0 2em;
|
|
77
78
|
|
|
79
|
+
background-color: var(--cBg2);
|
|
80
|
+
border-radius: @radius;
|
|
81
|
+
border: none; // For img
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
i.logo {
|
|
85
|
+
|
|
78
86
|
background-repeat: no-repeat;
|
|
79
87
|
background-position: center;
|
|
80
88
|
background-size: cover;
|
|
81
|
-
background-color: var(--cBg2);
|
|
82
|
-
border-radius: 50%;
|
|
83
89
|
|
|
84
90
|
&.contain {
|
|
85
91
|
background-color: transparent;
|
|
@@ -118,6 +118,7 @@
|
|
|
118
118
|
&.al-bottom { align-items: flex-end; }
|
|
119
119
|
&.al-fill { align-items: stretch; }
|
|
120
120
|
|
|
121
|
+
> .row-1 { align-self: stretch; }
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
.col {
|
|
@@ -134,6 +135,8 @@
|
|
|
134
135
|
&, &.al-fill { align-items: stretch; }
|
|
135
136
|
|
|
136
137
|
&.sep-1 > * + * { border-top: solid 1px var(--cLine); }
|
|
138
|
+
|
|
139
|
+
> .col-1 { align-self: stretch; }
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
.row,
|
|
@@ -46,6 +46,7 @@ export type TDialogControls = {
|
|
|
46
46
|
type DialogActions = {
|
|
47
47
|
|
|
48
48
|
setToasts: ( setter: (old: ComponentChild[]) => ComponentChild[]) => void,
|
|
49
|
+
setModals: ( setter: (old: ComponentChild[]) => ComponentChild[]) => void,
|
|
49
50
|
|
|
50
51
|
show: (
|
|
51
52
|
// On utilise une fonction pour pouvoir accéder aux fonctions (close, ...) lors de la déclaration des infos de la toast
|
|
@@ -81,9 +82,13 @@ export const createDialog = (app: Application, isToast: boolean): DialogActions
|
|
|
81
82
|
let onClose: TOnCloseCallback<TReturnType>;
|
|
82
83
|
const id = idA++;
|
|
83
84
|
|
|
85
|
+
const setDialog = isToast
|
|
86
|
+
? instance.setToasts
|
|
87
|
+
: instance.setModals;
|
|
88
|
+
|
|
84
89
|
const close = (retour: TReturnType) => {
|
|
85
90
|
|
|
86
|
-
|
|
91
|
+
setDialog(q => q.filter(m => m.id !== id))
|
|
87
92
|
|
|
88
93
|
if (onClose !== undefined)
|
|
89
94
|
onClose(retour);
|
|
@@ -145,7 +150,7 @@ export const createDialog = (app: Application, isToast: boolean): DialogActions
|
|
|
145
150
|
|
|
146
151
|
render["id"] = id;
|
|
147
152
|
|
|
148
|
-
|
|
153
|
+
setDialog(q => [...q, render]);
|
|
149
154
|
});
|
|
150
155
|
|
|
151
156
|
return {
|
|
@@ -159,6 +164,7 @@ export const createDialog = (app: Application, isToast: boolean): DialogActions
|
|
|
159
164
|
show: show,
|
|
160
165
|
|
|
161
166
|
setToasts: undefined as unknown as DialogActions["setToasts"],
|
|
167
|
+
setModals: undefined as unknown as DialogActions["setModals"],
|
|
162
168
|
|
|
163
169
|
confirm: (title: string, content: string | ComponentChild, defaultBtn: 'Yes'|'No' = 'No') => show<boolean>(({ close }) => (
|
|
164
170
|
<div class="card col">
|
|
@@ -228,16 +234,19 @@ export default () => {
|
|
|
228
234
|
|
|
229
235
|
const app = useContext();
|
|
230
236
|
|
|
231
|
-
const [
|
|
237
|
+
const [modals, setModals] = React.useState<ComponentChild[]>([]);
|
|
238
|
+
const [toasts, setToasts] = React.useState<ComponentChild[]>([]);
|
|
232
239
|
|
|
233
|
-
if (app.side === 'client')
|
|
234
|
-
app.modal.
|
|
240
|
+
if (app.side === 'client') {
|
|
241
|
+
app.modal.setModals = setModals;
|
|
242
|
+
app.toast.setToasts = setToasts;
|
|
243
|
+
}
|
|
235
244
|
|
|
236
245
|
React.useEffect(() => {
|
|
237
246
|
|
|
238
247
|
console.log('Updated toast list');
|
|
239
248
|
|
|
240
|
-
const modals = document.querySelectorAll("#
|
|
249
|
+
const modals = document.querySelectorAll("#modals > .modal");
|
|
241
250
|
if (modals.length === 0)
|
|
242
251
|
return;
|
|
243
252
|
|
|
@@ -259,10 +268,18 @@ export default () => {
|
|
|
259
268
|
|
|
260
269
|
});
|
|
261
270
|
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
271
|
+
return <>
|
|
272
|
+
{modals.length !== 0 ? (
|
|
273
|
+
<div id="modals">
|
|
274
|
+
{modals}
|
|
275
|
+
</div>
|
|
276
|
+
) : null}
|
|
277
|
+
|
|
278
|
+
{toasts.length !== 0 ? (
|
|
279
|
+
<div id="toasts">
|
|
280
|
+
{toasts}
|
|
281
|
+
</div>
|
|
282
|
+
) : null}
|
|
283
|
+
</>
|
|
267
284
|
|
|
268
285
|
}
|
|
@@ -169,7 +169,6 @@ export default ({
|
|
|
169
169
|
) : title}
|
|
170
170
|
|
|
171
171
|
{(!prison && close) && (
|
|
172
|
-
|
|
173
172
|
<Button class="close" icon="solid/times" size="s" shape="pill" onClick={async () => {
|
|
174
173
|
if (typeof close === "function") {
|
|
175
174
|
|
|
@@ -179,7 +178,6 @@ export default ({
|
|
|
179
178
|
close(false);
|
|
180
179
|
}
|
|
181
180
|
}} />
|
|
182
|
-
|
|
183
181
|
)}
|
|
184
182
|
|
|
185
183
|
</header>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@toast-zindex: 999;
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
#modals, #toasts {
|
|
4
4
|
|
|
5
5
|
z-index: @toast-zindex;
|
|
6
6
|
|
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
justify-content: flex-end;
|
|
11
11
|
gap: @spacing;
|
|
12
12
|
padding: @spacing;
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
&,
|
|
15
15
|
> .modal {
|
|
16
16
|
position: fixed;
|
|
17
|
-
top: 0px;
|
|
18
17
|
left: 0px;
|
|
19
18
|
right: 0px;
|
|
20
19
|
bottom: 0px;
|
|
@@ -35,40 +34,13 @@
|
|
|
35
34
|
margin-top: 0;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
> .card {
|
|
41
|
-
|
|
42
|
-
text-align: left;
|
|
43
|
-
max-width: 450px;
|
|
44
|
-
z-index: 999;
|
|
45
|
-
cursor: pointer;
|
|
46
|
-
padding-right: @spacing * 1.5;
|
|
47
|
-
|
|
48
|
-
animation: aff-toast 0.1s ease;
|
|
49
|
-
@keyframes aff-toast {
|
|
50
|
-
0% {
|
|
51
|
-
opacity: 0.5;
|
|
52
|
-
transform: scale(0.5);
|
|
53
|
-
}
|
|
54
|
-
100% {
|
|
55
|
-
opacity: 1;
|
|
56
|
-
transform: scale(1);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
> i {
|
|
61
|
-
color: @c1;
|
|
62
|
-
flex: 0 0 1em;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
h2 {
|
|
66
|
-
font-size: 1em;
|
|
67
|
-
}
|
|
39
|
+
#modals {
|
|
68
40
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
41
|
+
&,
|
|
42
|
+
> .modal {
|
|
43
|
+
top: 0px;
|
|
72
44
|
}
|
|
73
45
|
|
|
74
46
|
> .modal {
|
|
@@ -136,6 +108,43 @@
|
|
|
136
108
|
}
|
|
137
109
|
}
|
|
138
110
|
|
|
111
|
+
#toasts {
|
|
112
|
+
// Toast
|
|
113
|
+
> .card {
|
|
114
|
+
|
|
115
|
+
text-align: left;
|
|
116
|
+
max-width: 450px;
|
|
117
|
+
z-index: 999;
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
padding-right: @spacing * 1.5;
|
|
120
|
+
|
|
121
|
+
animation: aff-toast 0.1s ease;
|
|
122
|
+
@keyframes aff-toast {
|
|
123
|
+
0% {
|
|
124
|
+
opacity: 0.5;
|
|
125
|
+
transform: scale(0.5);
|
|
126
|
+
}
|
|
127
|
+
100% {
|
|
128
|
+
opacity: 1;
|
|
129
|
+
transform: scale(1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
> i {
|
|
134
|
+
color: @c1;
|
|
135
|
+
flex: 0 0 1em;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
h2 {
|
|
139
|
+
font-size: 1em;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
p {
|
|
143
|
+
text-align: left;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
139
148
|
// Selecteur moins profond pour que les clases utilitaires (w-a-x) soient prioritaires
|
|
140
149
|
.modal > .card {
|
|
141
150
|
max-width: 500px;
|
|
@@ -86,7 +86,7 @@ export default function useForm<TFormData extends {}>(
|
|
|
86
86
|
|
|
87
87
|
// Autosave
|
|
88
88
|
if (options.autoSave !== undefined)
|
|
89
|
-
saveLocally(data, options.autoSave);
|
|
89
|
+
saveLocally(data, options.autoSave.id);
|
|
90
90
|
|
|
91
91
|
}, [data]);
|
|
92
92
|
|
|
@@ -134,7 +134,7 @@ export default function useForm<TFormData extends {}>(
|
|
|
134
134
|
|
|
135
135
|
// Reset autosaved data
|
|
136
136
|
if (options.autoSave)
|
|
137
|
-
localStorage.removeItem(options.autoSave.id);
|
|
137
|
+
localStorage.removeItem('form.' + options.autoSave.id);
|
|
138
138
|
|
|
139
139
|
return submitResult;
|
|
140
140
|
}
|
|
@@ -158,6 +158,9 @@ export default function useForm<TFormData extends {}>(
|
|
|
158
158
|
if (fields.current === null || Object.keys(schema).join(',') !== Object.keys(fields.current).join(',')) {
|
|
159
159
|
fields.current = {}
|
|
160
160
|
for (const fieldName in schema.fields) {
|
|
161
|
+
|
|
162
|
+
const validator = schema.fields[fieldName];
|
|
163
|
+
|
|
161
164
|
fields.current[fieldName] = {
|
|
162
165
|
|
|
163
166
|
// Value control
|
|
@@ -182,8 +185,8 @@ export default function useForm<TFormData extends {}>(
|
|
|
182
185
|
|
|
183
186
|
// Error
|
|
184
187
|
errors: state.errors[fieldName],
|
|
185
|
-
required:
|
|
186
|
-
validator:
|
|
188
|
+
required: validator.options?.opt !== true,
|
|
189
|
+
validator: validator,
|
|
187
190
|
}
|
|
188
191
|
}
|
|
189
192
|
}
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
// Npm
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import type { ComponentChild, RefObject } from 'preact';
|
|
7
|
+
import type { JSX, ComponentChild, RefObject } from 'preact';
|
|
8
8
|
import type { StateUpdater } from 'preact/hooks';
|
|
9
9
|
|
|
10
10
|
// Core
|
|
11
11
|
import Button from '@client/components/button';
|
|
12
12
|
import Input from '@client/components/inputv3';
|
|
13
|
+
import type { TDialogControls } from '@client/components/dropdown';
|
|
13
14
|
|
|
14
15
|
/*----------------------------------
|
|
15
16
|
- TYPES
|
|
@@ -42,7 +43,7 @@ export type Props = (
|
|
|
42
43
|
required?: boolean,
|
|
43
44
|
noneSelection?: false | string,
|
|
44
45
|
currentList: Choice[],
|
|
45
|
-
|
|
46
|
+
refDropdown?: RefObject<TDialogControls>
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
/*----------------------------------
|
|
@@ -53,7 +54,7 @@ export type Props = (
|
|
|
53
54
|
- we don't want the selector to be rendered before the dropdown content is dhown
|
|
54
55
|
- this component is called multiple time
|
|
55
56
|
*/
|
|
56
|
-
export default ({
|
|
57
|
+
export default React.forwardRef<HTMLDivElement, Props>(({
|
|
57
58
|
choices: initChoices,
|
|
58
59
|
validator,
|
|
59
60
|
required,
|
|
@@ -64,8 +65,9 @@ export default ({
|
|
|
64
65
|
inline,
|
|
65
66
|
multiple,
|
|
66
67
|
currentList,
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
refDropdown,
|
|
69
|
+
...otherProps
|
|
70
|
+
}: Props, ref) => {
|
|
69
71
|
|
|
70
72
|
/*----------------------------------
|
|
71
73
|
- INIT
|
|
@@ -102,7 +104,7 @@ export default ({
|
|
|
102
104
|
- RENDER
|
|
103
105
|
----------------------------------*/
|
|
104
106
|
return (
|
|
105
|
-
<div
|
|
107
|
+
<div {...otherProps} className={(inline ? '' : 'card ') + "col al-top " + (otherProps.className || '')} ref={ref}>
|
|
106
108
|
|
|
107
109
|
{enableSearch && (
|
|
108
110
|
<Input icon="search"
|
|
@@ -113,21 +115,6 @@ export default ({
|
|
|
113
115
|
/>
|
|
114
116
|
)}
|
|
115
117
|
|
|
116
|
-
{currentList.length !== 0 && (
|
|
117
|
-
<ul class="col menu">
|
|
118
|
-
{currentList.map(choice => (
|
|
119
|
-
<Button size="s" onClick={() => {
|
|
120
|
-
onChange( current => multiple
|
|
121
|
-
? current.filter(c => c.value !== choice.value)
|
|
122
|
-
: undefined
|
|
123
|
-
);
|
|
124
|
-
}} suffix={<i src="check" class="fg primary" />}>
|
|
125
|
-
{choice.label}
|
|
126
|
-
</Button>
|
|
127
|
-
))}
|
|
128
|
-
</ul>
|
|
129
|
-
)}
|
|
130
|
-
|
|
131
118
|
{choices === null ? (
|
|
132
119
|
<div class="row h-3 al-center">
|
|
133
120
|
<i src="spin" />
|
|
@@ -136,15 +123,28 @@ export default ({
|
|
|
136
123
|
<ul class="col menu">
|
|
137
124
|
{choices.map( choice => {
|
|
138
125
|
const isCurrent = currentList.some(c => c.value === choice.value);
|
|
139
|
-
return
|
|
126
|
+
return (
|
|
140
127
|
<li>
|
|
141
128
|
<Button size="s" onClick={() => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
onChange( current => {
|
|
130
|
+
|
|
131
|
+
console.log("click select", current, multiple, choice);
|
|
132
|
+
|
|
133
|
+
return multiple
|
|
134
|
+
? (isCurrent
|
|
135
|
+
? current.filter(c => c.value !== choice.value)
|
|
136
|
+
: [...(current || []), choice]
|
|
137
|
+
)
|
|
138
|
+
: (isCurrent
|
|
139
|
+
? undefined
|
|
140
|
+
: [choice]
|
|
141
|
+
)
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (!multiple)
|
|
145
|
+
refDropdown?.current?.close(true);
|
|
146
|
+
|
|
147
|
+
}} suffix={ isCurrent && <i src="check" class="fg primary" /> }>
|
|
148
148
|
{/*search.keywords ? (
|
|
149
149
|
<span>
|
|
150
150
|
|
|
@@ -169,4 +169,4 @@ export default ({
|
|
|
169
169
|
)}
|
|
170
170
|
</div>
|
|
171
171
|
)
|
|
172
|
-
}
|
|
172
|
+
})
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
// Core
|
|
9
|
-
import Dropdown, {
|
|
9
|
+
import Dropdown, { TDropdownControl, Props as DropdownProps } from '@client/components/dropdown';
|
|
10
10
|
|
|
11
11
|
// Specific
|
|
12
12
|
import ChoiceSelector, {
|
|
@@ -36,7 +36,7 @@ export default ({
|
|
|
36
36
|
- INIT
|
|
37
37
|
----------------------------------*/
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const refDropdown = React.useRef<TDropdownControl>(null);
|
|
40
40
|
|
|
41
41
|
/*----------------------------------
|
|
42
42
|
- ACTIONS
|
|
@@ -56,9 +56,9 @@ export default ({
|
|
|
56
56
|
{props.inline ? (
|
|
57
57
|
<ChoiceSelector {...props} currentList={currentList} />
|
|
58
58
|
) : (
|
|
59
|
-
<Dropdown {...props} content={(
|
|
60
|
-
<ChoiceSelector {...props} currentList={currentList} />
|
|
61
|
-
)} iconR="chevron-down"
|
|
59
|
+
<Dropdown {...props} content={(
|
|
60
|
+
<ChoiceSelector {...props} currentList={currentList} refDropdown={refDropdown} />
|
|
61
|
+
)} iconR="chevron-down" refDropdown={refDropdown}>
|
|
62
62
|
|
|
63
63
|
{currentList.length === 0
|
|
64
64
|
? title
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type TSide = "left"|"top"|"right"|"bottom";
|
|
2
2
|
|
|
3
|
-
const debug =
|
|
3
|
+
const debug = false;
|
|
4
4
|
|
|
5
5
|
export type TPosition = ReturnType<typeof corrigerPosition>
|
|
6
6
|
|
|
@@ -129,7 +129,7 @@ export default function corrigerPosition(
|
|
|
129
129
|
debug && console.log(`[popover] Left: Conservation`, posFinale.left);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
console.log({ posInit, dimsPop, frontieres }, { posFinale });
|
|
132
|
+
debug && console.log({ posInit, dimsPop, frontieres }, { posFinale });
|
|
133
133
|
|
|
134
134
|
return {
|
|
135
135
|
css: posFinale,
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
----------------------------------*/
|
|
4
4
|
|
|
5
5
|
// Npm
|
|
6
|
-
import React
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { JSX, ComponentChild } from 'preact';
|
|
7
8
|
import type { StateUpdater } from 'preact/hooks';
|
|
8
9
|
|
|
9
10
|
// Libs
|
|
@@ -15,11 +16,11 @@ import useContexte from '@/client/context';
|
|
|
15
16
|
- TYPES
|
|
16
17
|
----------------------------------*/
|
|
17
18
|
|
|
18
|
-
export type Props = {
|
|
19
|
+
export type Props = JSX.HTMLAttributes<HTMLDivElement> & {
|
|
19
20
|
id?: string,
|
|
20
21
|
|
|
21
22
|
// Display
|
|
22
|
-
content?: JSX.Element
|
|
23
|
+
content?: JSX.Element,
|
|
23
24
|
state: [boolean, StateUpdater<boolean>],
|
|
24
25
|
width?: number | string,
|
|
25
26
|
disable?: boolean
|
|
@@ -53,7 +54,7 @@ export default (props: Props) => {
|
|
|
53
54
|
...autresProps
|
|
54
55
|
} = props;
|
|
55
56
|
|
|
56
|
-
const [position, setPosition] = React.useState<TPosition>(undefined);
|
|
57
|
+
const [position, setPosition] = React.useState<TPosition | undefined>(undefined);
|
|
57
58
|
const refCont = React.useRef<HTMLElement>(null);
|
|
58
59
|
const refContent = React.useRef<HTMLElement>(null);
|
|
59
60
|
|
|
@@ -61,7 +62,7 @@ export default (props: Props) => {
|
|
|
61
62
|
|
|
62
63
|
// Màj visibilite
|
|
63
64
|
React.useEffect(() => {
|
|
64
|
-
if (shown === true) {
|
|
65
|
+
if (shown === true && refContent.current !== null && refCont.current !== null) {
|
|
65
66
|
|
|
66
67
|
// Positionnement si affichage
|
|
67
68
|
setPosition(
|
|
@@ -70,7 +71,7 @@ export default (props: Props) => {
|
|
|
70
71
|
refContent.current,
|
|
71
72
|
false,
|
|
72
73
|
side,
|
|
73
|
-
frame || document.getElementById('page')
|
|
74
|
+
frame || document.getElementById('page') || undefined
|
|
74
75
|
)
|
|
75
76
|
);
|
|
76
77
|
|
|
@@ -100,17 +101,20 @@ export default (props: Props) => {
|
|
|
100
101
|
|
|
101
102
|
let renderedContent: ComponentChild;
|
|
102
103
|
if (active) {
|
|
103
|
-
content = typeof content === 'function' ? React.createElement(content) : content;
|
|
104
|
+
//content = typeof content === 'function' ? React.createElement(content) : content;
|
|
105
|
+
console.log("render content", content);
|
|
104
106
|
renderedContent = React.cloneElement(
|
|
105
107
|
content,
|
|
106
108
|
{
|
|
107
109
|
className: (content.props.className || '')
|
|
108
110
|
+ ' card white popover pd-1'
|
|
109
111
|
+ (position ? ' pos_' + position.cote : ''),
|
|
112
|
+
|
|
110
113
|
ref: (ref: any) => {
|
|
111
114
|
if (ref !== null)
|
|
112
115
|
refContent.current = ref
|
|
113
116
|
},
|
|
117
|
+
|
|
114
118
|
style: {
|
|
115
119
|
...(content.props.style || {}),
|
|
116
120
|
...(position ? {
|
|
@@ -8,18 +8,19 @@ import { ComponentChild, RefObject } from 'preact';
|
|
|
8
8
|
|
|
9
9
|
// Core
|
|
10
10
|
import Button, { Props as ButtonProps } from '../button';
|
|
11
|
-
import { TDialogControls } from '../Dialog/Manager';
|
|
12
11
|
import Popover from '../containers/Popover';
|
|
13
12
|
|
|
14
13
|
/*----------------------------------
|
|
15
14
|
- TYPES
|
|
16
15
|
----------------------------------*/
|
|
17
16
|
|
|
18
|
-
export type { TDialogControls } from '../Dialog/Manager';
|
|
19
|
-
|
|
20
17
|
export type Props = ButtonProps & {
|
|
21
18
|
content: ComponentChild | (() => ComponentChild),
|
|
22
|
-
|
|
19
|
+
refDropdown?: RefObject<TDropdownControl>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type TDropdownControl = {
|
|
23
|
+
close: () => void
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/*----------------------------------
|
|
@@ -29,7 +30,7 @@ export default (props: Props) => {
|
|
|
29
30
|
|
|
30
31
|
let {
|
|
31
32
|
content,
|
|
32
|
-
|
|
33
|
+
refDropdown,
|
|
33
34
|
...buttonProps
|
|
34
35
|
} = props;
|
|
35
36
|
|
|
@@ -37,6 +38,11 @@ export default (props: Props) => {
|
|
|
37
38
|
|
|
38
39
|
const refButton = React.useRef<HTMLElement>(null);
|
|
39
40
|
|
|
41
|
+
if (refDropdown)
|
|
42
|
+
refDropdown.current = {
|
|
43
|
+
close: () => popoverState[1]( false )
|
|
44
|
+
}
|
|
45
|
+
|
|
40
46
|
return (
|
|
41
47
|
<Popover content={content} state={popoverState}>
|
|
42
48
|
<Button {...buttonProps} refElem={refButton} />
|
|
@@ -10,7 +10,7 @@ import { ComponentChild } from 'preact';
|
|
|
10
10
|
import Button, { Props as ButtonProps } from '../button';
|
|
11
11
|
|
|
12
12
|
// Libs
|
|
13
|
-
import {
|
|
13
|
+
import { TPopover, PopoverProps } from './Manager';
|
|
14
14
|
import useContexte from '@client/context';
|
|
15
15
|
|
|
16
16
|
/*----------------------------------
|
|
@@ -77,7 +77,7 @@ export default (props: Props) => {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const refButton = React.useRef<HTMLElement>(null);
|
|
80
|
-
const refPopover = React.useRef<
|
|
80
|
+
const refPopover = React.useRef<TPopover>(null);
|
|
81
81
|
|
|
82
82
|
let classe = buttonProps.class === undefined
|
|
83
83
|
? "dropdown"
|
|
@@ -16,6 +16,7 @@ export { default as Video } from './Video';
|
|
|
16
16
|
export { default as Number } from './input/Number';
|
|
17
17
|
export { default as Slider } from './input/Slider';
|
|
18
18
|
export { default as Radio } from './input/Radio';
|
|
19
|
+
export { default as Checkbox } from './input/Checkbox';
|
|
19
20
|
|
|
20
21
|
// Data
|
|
21
22
|
export { default as Amount } from './Amount';
|
|
@@ -28,6 +29,7 @@ export { default as CircularProgressbar } from './data/progressbar/circular';
|
|
|
28
29
|
export { default as Select } from './Select';
|
|
29
30
|
export { default as Input } from './inputv3';
|
|
30
31
|
export { default as File } from './inputv3/file';
|
|
32
|
+
export { default as DateRangeInput } from './inputv3/date';
|
|
31
33
|
|
|
32
34
|
// TOD: fix popover component
|
|
33
35
|
//export { default as Date } from './input/Date';
|
|
File without changes
|