5htp-core 0.4.2 → 0.4.3

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.
Files changed (48) hide show
  1. package/package.json +4 -12
  2. package/src/client/app/component.tsx +11 -2
  3. package/src/client/assets/css/components/button.less +10 -10
  4. package/src/client/assets/css/components/other.less +0 -1
  5. package/src/client/assets/css/core.less +0 -4
  6. package/src/client/assets/css/text/text.less +1 -2
  7. package/src/client/assets/css/text/titres.less +0 -5
  8. package/src/client/assets/css/utils/layouts.less +5 -5
  9. package/src/client/assets/css/utils/sizing.less +6 -6
  10. package/src/client/components/Dialog/card.tsx +1 -1
  11. package/src/client/components/button.tsx +1 -1
  12. package/src/client/components/containers/Popover/index.tsx +2 -2
  13. package/src/client/components/index.ts +5 -16
  14. package/src/client/components/inputv3/index.tsx +2 -5
  15. package/src/client/services/router/components/Page.tsx +1 -2
  16. package/src/client/services/router/components/router.tsx +4 -8
  17. package/src/client/services/router/request/api.ts +31 -52
  18. package/src/client/services/router/response/index.tsx +2 -0
  19. package/src/common/data/dates.ts +50 -6
  20. package/src/common/router/layouts.ts +14 -5
  21. package/src/common/router/response/page.ts +12 -6
  22. package/src/common/validation/validators.ts +0 -4
  23. package/src/server/app/container/config.ts +2 -1
  24. package/src/server/services/router/http/index.ts +16 -22
  25. package/src/server/services/router/response/page/index.tsx +0 -0
  26. package/src/client/assets/fonts/Inter/index.less +0 -77
  27. package/src/client/assets/fonts/Inter/latin-500.woff2 +0 -0
  28. package/src/client/assets/fonts/Inter/latin-600.woff2 +0 -0
  29. package/src/client/assets/fonts/Inter/latin-800.woff2 +0 -0
  30. package/src/client/assets/fonts/Inter/latin-ext-500.woff2 +0 -0
  31. package/src/client/assets/fonts/Inter/latin-ext-600.woff2 +0 -0
  32. package/src/client/assets/fonts/Inter/latin-ext-800.woff2 +0 -0
  33. package/src/client/assets/fonts/Rubik/cyrillic-ext.woff2 +0 -0
  34. package/src/client/assets/fonts/Rubik/cyrillic.woff2 +0 -0
  35. package/src/client/assets/fonts/Rubik/hebrew.woff2 +0 -0
  36. package/src/client/assets/fonts/Rubik/index.less +0 -30
  37. package/src/client/assets/fonts/Rubik/latin-ext.woff2 +0 -0
  38. package/src/client/assets/fonts/Rubik/latin.woff2 +0 -0
  39. package/src/client/components/Amount.tsx +0 -38
  40. package/src/client/components/Form_old/index.tsx +0 -450
  41. package/src/client/components/Form_old/index.tsx.old +0 -436
  42. package/src/client/components/dropdown.old/Manager.tsx +0 -164
  43. package/src/client/components/dropdown.old/getPosition.ts +0 -137
  44. package/src/client/components/dropdown.old/index.tsx +0 -99
  45. package/src/client/components/dropdown.old/popover.less +0 -56
  46. package/src/client/components/input/Base/Choix.ts +0 -48
  47. package/src/client/components/input/Base/index.tsx +0 -432
  48. package/src/client/components/input/BaseV2/index.tsx +0 -72
@@ -4,13 +4,16 @@
4
4
 
5
5
  // Npm
6
6
  import type { ComponentChild } from 'preact';
7
+
7
8
  // Core
8
9
  import type { ClientContext } from '@/client/context';
9
10
  import type { TRouteOptions } from '.';
11
+ import type { TDataProvider } from './response/page';
12
+
10
13
  // App
11
14
  import internalLayout from '@client/pages/_layout';
12
15
 
13
- import layouts from '@/client/pages/**/_layout/index.tsx';
16
+ import * as layouts from '@/client/pages/**/_layout/index.tsx';
14
17
 
15
18
  /*----------------------------------
16
19
  - CONST
@@ -23,7 +26,11 @@ export const layoutsList = layouts as ImportedLayouts;
23
26
  ----------------------------------*/
24
27
  type LayoutComponent = (attributes: { context: ClientContext }) => ComponentChild;
25
28
 
26
- export type Layout = { path: string, Component: LayoutComponent }
29
+ export type Layout = {
30
+ path: string,
31
+ Component: LayoutComponent,
32
+ data?: TDataProvider
33
+ }
27
34
 
28
35
  export type ImportedLayouts = {
29
36
  [chunkId: string]: Layout["Component"]
@@ -51,13 +58,14 @@ export const getLayout = (routePath: string, routeOptions?: TRouteOptions): Layo
51
58
  // Layout via name
52
59
  if (routeOptions.layout !== undefined) {
53
60
 
54
- const LayoutComponent = layouts[routeOptions.layout];
61
+ const { default: LayoutComponent, data } = layouts[routeOptions.layout];
55
62
  if (LayoutComponent === undefined)
56
63
  throw new Error(`No layout found with ID: ${routeOptions.layout}. registered layouts: ${Object.keys(layouts)}`);
57
64
 
58
65
  return {
59
66
  path: routeOptions.layout,
60
- Component: layouts[routeOptions.layout]
67
+ Component: layouts[routeOptions.layout].default,
68
+ data
61
69
  }
62
70
  }
63
71
 
@@ -73,7 +81,8 @@ export const getLayout = (routePath: string, routeOptions?: TRouteOptions): Layo
73
81
  )
74
82
  return {
75
83
  path: layoutPath,
76
- Component: layouts[layoutPath]
84
+ Component: layouts[layoutPath].default,
85
+ data: layouts[layoutPath].data,
77
86
  };
78
87
 
79
88
  // Internal layout
@@ -83,16 +83,15 @@ export default abstract class PageResponse<TRouter extends ClientOrServerRouter
83
83
 
84
84
  this.chunkId = context.route.options["id"];
85
85
 
86
- this.fetchers = this.createFetchers();
86
+ this.fetchers = this.createFetchers(route.options.data);
87
87
 
88
88
  }
89
89
 
90
- private createFetchers() {
90
+ private createFetchers( dataProvider?: TDataProvider ) {
91
91
 
92
92
  // Load the fetchers list to load data if needed
93
- const dataFetcher = this.route.options.data;
94
- if (dataFetcher)
95
- return dataFetcher({
93
+ if (dataProvider)
94
+ return dataProvider({
96
95
  ...this.context,
97
96
  data: this.context.request.data
98
97
  });
@@ -103,9 +102,16 @@ export default abstract class PageResponse<TRouter extends ClientOrServerRouter
103
102
 
104
103
  public async fetchData() {
105
104
 
106
- // Execute the fetchers for missing data
105
+ // Fetch layout data
106
+ if (this.layout?.data) {
107
+ const fetchers = this.createFetchers(this.layout.data);
108
+ this.fetchers = { ...this.fetchers, ...fetchers };
109
+ }
110
+
111
+ // Fetch page data
107
112
  debug && console.log(`[router][page] Fetching api data:` + Object.keys(this.fetchers));
108
113
  this.data = await this.context.request.api.fetchSync( this.fetchers, this.data );
114
+
109
115
  return this.data;
110
116
  }
111
117
  }
@@ -19,9 +19,6 @@ import FileToUpload from '@client/components/inputv3/file/FileToUpload';
19
19
  import Schema, { TSchemaFields } from './schema'
20
20
  import Validator, { TValidator } from './validator'
21
21
 
22
- // Components
23
- import NumberInput from '@client/components/input/Number';
24
-
25
22
  /*----------------------------------
26
23
  - TYPES
27
24
  ----------------------------------*/
@@ -281,7 +278,6 @@ export default class SchemaValidators {
281
278
  }, {
282
279
  // Force une valeur par défaut si requis
283
280
  defaut: opts.opt ? undefined : (opts.min || 0),
284
- rendu: NumberInput,
285
281
  ...opts,
286
282
  })
287
283
 
@@ -50,6 +50,7 @@ type AppIdentityConfig = {
50
50
 
51
51
  language: string
52
52
  maincolor: string,
53
+ iconsPack?: string,
53
54
 
54
55
  web: {
55
56
  title: string,
@@ -57,7 +58,7 @@ type AppIdentityConfig = {
57
58
  fullTitle: string,
58
59
  description: string,
59
60
  version: string
60
- }
61
+ }
61
62
  }
62
63
 
63
64
  export type AppConfig = {
@@ -17,7 +17,6 @@ import hpp from 'hpp'; // Protection contre la pollution des reuqtees http
17
17
  import helmet from 'helmet'; // Diverses protections
18
18
  import compression from 'compression';
19
19
  import fileUpload from 'express-fileupload';
20
- import expressStaticGzip from 'express-static-gzip';
21
20
  import cookieParser from 'cookie-parser';
22
21
  import * as csp from 'express-csp-header';
23
22
 
@@ -114,39 +113,34 @@ export default class HttpServer {
114
113
  // Normalement, seulement utile pour le mode production,
115
114
  // Quand mode debug, les ressources client semblent servies par le dev middlewae
116
115
  // Sauf que les ressources serveur ne semblent pas trouvées par le dev-middleware
116
+ routes.use(compression());
117
117
  routes.use('/public', cors());
118
118
  routes.use(
119
119
  '/public',
120
- expressStaticGzip( Container.path.root + '/bin/public', {
121
- enableBrotli: true,
122
- serveStatic: {
123
- dotfiles: 'deny',
124
- setHeaders: function setCustomCacheControl(res, path) {
120
+ express.static( Container.path.root + '/bin/public', {
121
+ dotfiles: 'deny',
122
+ setHeaders: function setCustomCacheControl(res, path) {
125
123
 
126
- const dontCache = [
127
- '/public/icons',
128
- '/public/client'
129
- ]
124
+ const dontCache = [
125
+ '/public/icons',
126
+ '/public/client'
127
+ ]
130
128
 
131
- res.setHeader('Cache-Control', 'public, max-age=0');
129
+ res.setHeader('Cache-Control', 'public, max-age=0');
132
130
 
133
- // Set long term cache, except for non-hashed filenames
134
- /*if (dontCache.some( p => path.startsWith( p ))) {
135
- res.setHeader('Cache-Control', 'public, max-age=0');
136
- } else {
137
- res.setHeader('Cache-Control', 'public, max-age=604800000'); // 7 Days
138
- }*/
139
-
140
- }
131
+ // Set long term cache, except for non-hashed filenames
132
+ /*if (dontCache.some( p => path.startsWith( p ))) {
133
+ res.setHeader('Cache-Control', 'public, max-age=0');
134
+ } else {
135
+ res.setHeader('Cache-Control', 'public, max-age=604800000'); // 7 Days
136
+ }*/
137
+
141
138
  }
142
139
  }),
143
140
  (req, res) => {
144
141
  res.status(404).send();
145
142
  }
146
143
  );
147
-
148
- // Activation Gzip
149
- routes.use(compression());
150
144
 
151
145
  routes.use('/robots.txt', express.static( path.resolve(__dirname, 'public/robots.txt')) );
152
146
 
@@ -1,77 +0,0 @@
1
- //
2
- /*
3
- The use of Unicode range subsets and separate files for each stylistic variant of
4
- the font allows you to define a composite font family that is both faster and more
5
- efficient to download. Visitors only download the variants and subsets they need,
6
- and they aren't forced to download subsets that they may never see or use on the page.
7
-
8
- https://web.dev/reduce-webfont-size/#unicode-range-subsetting
9
-
10
- Original stylesheet: https://fonts.googleapis.com/css2?family=Inter:wght@500;600;800&display=swap
11
- */
12
-
13
-
14
- /* latin-ext */
15
- @font-face {
16
- font-family: 'Inter';
17
- font-style: normal;
18
- font-weight: 500;
19
- font-display: swap;
20
- src: url(./latin-ext-500.woff2) format('woff2');
21
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
22
- }
23
- /* latin */
24
- @font-face {
25
- font-family: 'Inter';
26
- font-style: normal;
27
- font-weight: 500;
28
- font-display: swap;
29
- src: url(./latin-500.woff2) format('woff2');
30
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
31
- }
32
-
33
-
34
-
35
-
36
-
37
- /* latin-ext */
38
- @font-face {
39
- font-family: 'Inter';
40
- font-style: normal;
41
- font-weight: 600;
42
- font-display: swap;
43
- src: url(./latin-ext-600.woff2) format('woff2');
44
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
45
- }
46
- /* latin */
47
- @font-face {
48
- font-family: 'Inter';
49
- font-style: normal;
50
- font-weight: 600;
51
- font-display: swap;
52
- src: url(./latin-600.woff2) format('woff2');
53
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
54
- }
55
-
56
-
57
-
58
-
59
-
60
- /* latin-ext */
61
- @font-face {
62
- font-family: 'Inter';
63
- font-style: normal;
64
- font-weight: 800;
65
- font-display: swap;
66
- src: url(./latin-ext-800.woff2) format('woff2');
67
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
68
- }
69
- /* latin */
70
- @font-face {
71
- font-family: 'Inter';
72
- font-style: normal;
73
- font-weight: 800;
74
- font-display: swap;
75
- src: url(./latin-800.woff2) format('woff2');
76
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
77
- }
@@ -1,30 +0,0 @@
1
- //
2
- /*
3
- The use of Unicode range subsets and separate files for each stylistic variant of
4
- the font allows you to define a composite font family that is both faster and more
5
- efficient to download. Visitors only download the variants and subsets they need,
6
- and they aren't forced to download subsets that they may never see or use on the page.
7
-
8
- https://web.dev/reduce-webfont-size/#unicode-range-subsetting
9
-
10
- Original stylesheet: https://fonts.googleapis.com/css2?family=Rubik:wght@600&display=swap
11
- */
12
-
13
- /* latin-ext */
14
- @font-face {
15
- font-family: 'Rubik';
16
- font-style: normal;
17
- font-weight: 600;
18
- font-display: swap;
19
- src: url(./latin-ext.woff2) format('woff2');
20
- unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
21
- }
22
- /* latin */
23
- @font-face {
24
- font-family: 'Rubik';
25
- font-style: normal;
26
- font-weight: 600;
27
- font-display: swap;
28
- src: url(./latin.woff2) format('woff2');
29
- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
30
- }
@@ -1,38 +0,0 @@
1
- /*----------------------------------
2
- - DEPENDANCES
3
- ----------------------------------*/
4
-
5
- // Npm
6
- import React, { JSX } from 'react';
7
-
8
- // Core libs
9
- import Format from '@common/data/number/format';
10
-
11
- /*----------------------------------
12
- - TYPES
13
- ----------------------------------*/
14
-
15
- export type Unit= 'satoshi' | 'bitcoin' | 'dollars' | 'credits'
16
-
17
- /*----------------------------------
18
- - COMPONENTS
19
- ----------------------------------*/
20
- export default ({ amount, unit, sign, decimals, ...props }: {
21
- amount: number,
22
- unit: Unit,
23
- decimals?: number,
24
- sign?: '+' | '-'
25
- } & JSX.HTMLAttributes<HTMLDivElement>) => {
26
-
27
- const className = 'number row sp-05 ' + (props.class ? props.class + ' ' : '');//sign === undefined ? 'txtPrimary' : (sign === '+' ? 'fg success' : 'fg error');
28
- if (unit === 'credits')
29
- return <strong {...props} class={className}>{sign} {Format.credits(amount, decimals)} Credits</strong>;
30
- else if (unit === 'dollars')
31
- return <strong {...props} class={className}>{sign} {Format.dollars(amount, decimals)} $</strong>;
32
- else if (unit === 'satoshi')
33
- return <strong {...props} class={className}>{sign} {Format.satoshi(amount)} sat.</strong>;
34
- else if (unit === 'bitcoin')
35
- return <strong {...props} class={className}>{sign} {Format.bitcoin(amount)} BTC</strong>;
36
- else
37
- return <>-</>
38
- }