@genexus/mercury 0.13.1 → 0.13.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 (53) hide show
  1. package/README.md +201 -72
  2. package/dist/assets/MERCURY_ASSETS.d.ts +933 -51
  3. package/dist/assets/MERCURY_ASSETS.js +1 -1
  4. package/dist/assets/MERCURY_ASSETS.ts +1482 -600
  5. package/dist/assets/icons/system/dark/accessibility-new.svg +1 -0
  6. package/dist/assets/icons/system/dark/arrow-drop-down.svg +1 -0
  7. package/dist/assets/icons/system/dark/arrow-drop-left.svg +1 -0
  8. package/dist/assets/icons/system/dark/arrow-drop-right.svg +1 -0
  9. package/dist/assets/icons/system/dark/arrow-drop-up.svg +1 -0
  10. package/dist/assets/icons/system/dark/chevron-down.svg +1 -1
  11. package/dist/assets/icons/system/dark/chevron-pag-left.svg +1 -0
  12. package/dist/assets/icons/system/dark/chevron-pag-right.svg +1 -0
  13. package/dist/assets/icons/system/dark/chevron-small-down.svg +1 -0
  14. package/dist/assets/icons/system/dark/chevron-small-up.svg +1 -0
  15. package/dist/assets/icons/system/dark/chevron-up.svg +1 -1
  16. package/dist/assets/icons/system/dark/help-variant.svg +1 -1
  17. package/dist/assets/icons/system/dark/link-off.svg +1 -0
  18. package/dist/assets/icons/system/dark/mic-off.svg +1 -1
  19. package/dist/assets/icons/system/dark/text-compare.svg +1 -0
  20. package/dist/assets/icons/system/light/accessibility-new.svg +1 -0
  21. package/dist/assets/icons/system/light/arrow-drop-down.svg +1 -0
  22. package/dist/assets/icons/system/light/arrow-drop-left.svg +1 -0
  23. package/dist/assets/icons/system/light/arrow-drop-right.svg +1 -0
  24. package/dist/assets/icons/system/light/arrow-drop-up.svg +1 -0
  25. package/dist/assets/icons/system/light/chevron-down.svg +1 -1
  26. package/dist/assets/icons/system/light/chevron-pag-left.svg +1 -0
  27. package/dist/assets/icons/system/light/chevron-pag-right.svg +1 -0
  28. package/dist/assets/icons/system/light/chevron-small-down.svg +1 -0
  29. package/dist/assets/icons/system/light/chevron-small-up.svg +1 -0
  30. package/dist/assets/icons/system/light/chevron-up.svg +1 -1
  31. package/dist/assets/icons/system/light/help-variant.svg +1 -1
  32. package/dist/assets/icons/system/light/link-off.svg +1 -0
  33. package/dist/assets/icons/system/light/mic-off.svg +1 -1
  34. package/dist/assets/icons/system/light/text-compare.svg +1 -0
  35. package/dist/bundles/css/all.css +1 -1
  36. package/dist/bundles/css/base/base-globant.css +1 -0
  37. package/dist/bundles/css/base/icons.css +1 -1
  38. package/dist/bundles/js/all.js +1 -1
  39. package/dist/bundles/js/base/base-globant.js +1 -0
  40. package/dist/bundles/js/base/icons.js +1 -1
  41. package/dist/bundles/js/bundle-mappings.js +6 -0
  42. package/dist/cli/internal/transpile-bundle-and-create-mappings.js +2 -1
  43. package/dist/mercury.scss +624 -192
  44. package/package.json +3 -3
  45. package/LICENSE +0 -21
  46. package/dist/assets/icons/system/dark/chevron-close-treeview.svg +0 -1
  47. package/dist/assets/icons/system/dark/chevron-open-treeview.svg +0 -1
  48. package/dist/assets/icons/system/light/chevron-close-treeview.svg +0 -1
  49. package/dist/assets/icons/system/light/chevron-open-treeview.svg +0 -1
  50. /package/dist/assets/icons/system/dark/{keyboard-arrow-left.svg → chevron-small-left.svg} +0 -0
  51. /package/dist/assets/icons/system/dark/{keyboard-arrow-right.svg → chevron-small-right.svg} +0 -0
  52. /package/dist/assets/icons/system/light/{keyboard-arrow-left.svg → chevron-small-left.svg} +0 -0
  53. /package/dist/assets/icons/system/light/{keyboard-arrow-right.svg → chevron-small-right.svg} +0 -0
package/README.md CHANGED
@@ -1,103 +1,232 @@
1
1
  # Mercury Design System
2
2
 
3
- A design system for GeneXus generated IDE Web.
3
+ Mercury Design System is a robust and scalable solution designed to improve product development. It's implemented over [Chameleon](https://github.com/genexuslabs/chameleon-controls-library) a library of white-label, highly-customizable and reusable web components, which implements all components necessaries for the Mercury DS.
4
4
 
5
- ## Install
5
+ **Chameleon** works on every framework since it's a library of web components (the standard for creating components in the web) and provides the following features:
6
+
7
+ - It build with accessibility in mind.
8
+ - Tiny bundle size.
9
+ - Blazing fast performance.
10
+ - Full RTL and internationalization support.
11
+ - Open source.
12
+
13
+ ## 1. Installation
6
14
 
7
15
  ```bash
8
16
  npm i @genexus/mercury
9
17
  ```
10
18
 
11
- ## Using this design system
19
+ ## 2. Usage
20
+
21
+ This repository provides the following assets to implement the Mercury DS:
22
+
23
+ - Custom fonts
24
+ - Icons
25
+ - CSS to style Chameleon component.
26
+
27
+ The CSS is divided by bundles, where each bundle contains the CSS to style a component. For example, to style a `button` we have the `components/button` bundle, to style the `ch-checkbox` we have the `components/checkbox`, and so on.
28
+
29
+ ### 2.1. Copy icons and custom fonts
30
+
31
+ Custom fonts and icons are distributed under the following folders:
32
+
33
+ - `<path to node_modules>/@genexus/mercury/dist/assets/fonts`
34
+ - `<path to node_modules>/@genexus/mercury/dist/assets/icons`
12
35
 
13
- - Import the Mercury reference into a SCSS file and use the provided mixins:
36
+ To use these assets, we recommend copying them statically, that is, do not track these assets in your repository sources, only copy them to the dev server and prod builds.
14
37
 
15
- ```scss
16
- @import "<path to node_modules>/@genexus/mercury/dist/mercury.scss";
38
+ In the following sections we provide examples of how to copy the assets with different build tools.
17
39
 
18
- @include mercury(optional parameters...);
19
- ```
40
+ ### 2.1.1. Copying assets with Vite
20
41
 
21
- - Copy the assets with a copy task for your development and production build.
42
+ First, install `vite-plugin-static-copy`:
22
43
 
23
- - In a StencilJS project, it will be something like this:
44
+ ```bash
45
+ npm i vite-plugin-static-copy --save-dev
46
+ ```
24
47
 
25
- ```ts
26
- // stencil.config.ts
27
- import { Config } from "@stencil/core";
48
+ ```ts
49
+ // vite.config.ts
50
+ import { defineConfig } from "vite";
51
+ import { viteStaticCopy } from "vite-plugin-static-copy";
28
52
 
29
- export const config: Config = {
30
- namespace: "your-name-space",
31
- outputTargets: [
53
+ export default defineConfig({
54
+ plugins: [
55
+ viteStaticCopy({
56
+ targets: [
32
57
  {
33
- type: "dist",
34
- copy: [
35
- {
36
- src: "../node_modules/@genexus/mercury/dist/assets",
37
- dest: "assets"
38
- }
39
- ]
40
- },
58
+ src: "node_modules/@genexus/mercury/dist/assets",
59
+ dest: "./" // Path to your assets folder
60
+ }
61
+ ]
62
+ })
63
+ ]
64
+ });
65
+ ```
66
+
67
+ ### 2.1.2. Copying assets with StencilJS
68
+
69
+ When building web components with the StencilJS compiler, the assets can be copied using the copy tasks that provides StencilJS:
70
+
71
+ ```ts
72
+ // stencil.config.ts
73
+ import { Config } from "@stencil/core";
74
+
75
+ export const config: Config = {
76
+ namespace: "your-name-space",
77
+ outputTargets: [
78
+ {
79
+ type: "dist",
80
+ copy: [
81
+ {
82
+ src: "../node_modules/@genexus/mercury/dist/assets",
83
+ dest: "assets" // Path to your assets folder
84
+ }
85
+ ]
86
+ },
87
+ {
88
+ type: "www",
89
+ serviceWorker: null,
90
+ copy: [
41
91
  {
42
- type: "www",
43
- serviceWorker: null,
44
- copy: [
45
- {
46
- src: "../node_modules/@genexus/mercury/dist/assets",
47
- dest: "assets"
48
- }
49
- ]
92
+ src: "../node_modules/@genexus/mercury/dist/assets",
93
+ dest: "assets" // Path to your assets folder
50
94
  }
51
95
  ]
52
- };
96
+ }
97
+ ]
98
+ };
99
+ ```
100
+
101
+ ### 2.2. Creating the CSS bundles
102
+
103
+ After you have defined the path for the icons and custom fonts, you must create the CSS bundles with the path to those assets.
104
+
105
+ In the following sections we provide examples of how to create these bundles.
106
+
107
+ ### 2.2.1. Using the CLI to create the bundles
108
+
109
+ > [!IMPORTANT]
110
+ > This is the way we recommend to create the bundles.
111
+
112
+ Mercury exposes a CLI to automate the creation of bundles. This CLI comes with the installation of the `@genexus/mercury` dependency.
113
+
114
+ Usage:
115
+
116
+ ```bash
117
+ # Command line
118
+ npx mercury <flags>
119
+
120
+ # package.json script
121
+ "build.scss": "mercury <flags>"
122
+ ```
123
+
124
+ Consult the [CLI flags](#cli-flags) section to read the complete documentation for the CLI.
125
+
126
+ Using the CLI:
127
+
128
+ 1. Add a `"build.scss"` script in your package.json and include the paths where the icons and fonts will be copied, also include the `outDir` path where the CSS will be generated.
129
+
130
+ For example:
131
+
132
+ ```json
133
+ "build.scss": "mercury --i=/assets/icons/ --f=/assets/fonts/ --gl --outDir=src/assets/generated/"
134
+ ```
135
+
136
+ 2. Use the `"build.scss"` script before building your application (dev server and prod build).
137
+
138
+ For example:
139
+
140
+ ```json
141
+ "dev": "npm run build.scss && ...",
142
+ "start": "npm run build.scss && ...",
143
+ "build": "npm run build.scss && ..."
144
+ ```
145
+
146
+ 3. Before using any Mercury or Chameleon utility, you must register the bundle mapping. This mapping allows Mercury to map the bundle names (for example, `components/button`) with the real name of the CSS file (for example, `components/button-9f82641938b85445.css`).
147
+
148
+ **IMPORTANT**: Run this JavaScript before using any Mercury or Chameleon utilities.
149
+
150
+ ```ts
151
+ import { setBundleMapping } from "@genexus/mercury/dist/bundles";
152
+
153
+ // This path is generated in the same directory as the one specified in the CLI --outDir flag
154
+ import { bundleToHashMappings } from "<path to the file>/bundle-to-hash-mappings";
155
+
156
+ setBundleMapping(bundleToHashMappings);
157
+
158
+ // Other Mercury and Chameleon utilities...
159
+ ```
160
+
161
+ ### 2.2.2. Generating the CSS using SASS
162
+
163
+ > [!IMPORTANT]
164
+ > We don't recommend this way, because the CLI does this under the hood in a much better and faster way. Also, this way does not hash the generated CSS, which leads to cache issues when re-deploying your application after updating your version of Mercury.
165
+
166
+ 1. Install `sass` dependency to transpile the bundles.
167
+
168
+ ```bash
169
+ npm i -D sass
53
170
  ```
54
171
 
55
- - In a Vite project, it will be something like this:
56
-
57
- ```ts
58
- // vite.config.ts
59
- import { defineConfig } from "vite";
60
- import { viteStaticCopy } from "vite-plugin-static-copy";
61
-
62
- export default defineConfig({
63
- plugins: [
64
- viteStaticCopy({
65
- targets: [
66
- {
67
- src: "node_modules/@genexus/mercury/dist/assets",
68
- dest: "./"
69
- }
70
- ]
71
- })
72
- ]
73
- });
172
+ 2. Add a config file (called `config.scss`) in your project to determine the path to the assets.
173
+ Include the following configuration:
174
+
175
+ ```scss
176
+ $icons-path: "/assets/custom/path/icons/";
177
+ $font-face-path: "/assets/custom/path/fonts/";
178
+ $globant-colors: false;
74
179
  ```
75
180
 
76
- - Using the bundles from this repository.
181
+ 3. Run the following command to transpile the bundles with the new path for the assets:
182
+
183
+ ```bash
184
+ npx sass --load-path=<path to config.scss directory> --no-source-map --style compressed node_modules/@genexus/mercury/dist/bundles/scss:untracked-folder/bundles
185
+ ```
77
186
 
78
- 1. Install `sass` dependency to transpile the bundles.
187
+ For example:
79
188
 
80
- ```bash
81
- npm i -D sass
82
- ```
189
+ ```bash
190
+ npx sass --load-path=src --no-source-map --style compressed node_modules/@genexus/mercury/dist/bundles/scss:src/assets/generated
191
+ ```
83
192
 
84
- 2. Add a config file (called `config.scss`) in your project to determine the path to the assets.
85
- Include the following configuration:
193
+ ### 2.2.3. Using already generated CSS
86
194
 
87
- ```scss
88
- $icons-path: "assets/custom/path/icons/";
89
- $font-face-path: "assets/custom/path/fonts/";
90
- $globant-colors: false;
91
- ```
195
+ > [!IMPORTANT]
196
+ > We don't recommend this way, because the generated CSS contains fixed paths for the assets and the CSS names don't contain a hash, which leads to cache issues when re-deploying your application after updating your version of Mercury.
197
+ > We only include this case, because in some scenarios it can facilitate the initialization with Mercury.
198
+
199
+ 1. Copy the `<path to node_modules>/@genexus/mercury/dist/bundles/css` content to the `outDir` where the CSS will be.
200
+
201
+ ### 2.3. Register Mercury and Chameleon utilities
202
+
203
+ Chameleon and Mercury export utilities to facilitate the usage of icons. If you are using Mercury icons, do the following:
204
+
205
+ ```ts
206
+ import { registryProperty } from "@genexus/chameleon-controls-library/dist/collection";
207
+ import { getImagePathCallbackDefinitions } from "@genexus/mercury/assets-manager.js";
208
+ import { registerMercury } from "@genexus/mercury/register-mercury.js";
209
+
210
+ // Register the default value for the getImagePathCallback property in all Chameleon
211
+ // components. This implementation allows us to remove the need for binding the
212
+ // getImagePathCallback property in all Chameleon controls that must render icons.
213
+ registryProperty("getImagePathCallback", getImagePathCallbackDefinitions);
214
+
215
+ // It registers a mapping between the icons metadata and its path.
216
+ registerMercury();
217
+ ```
92
218
 
93
- 3. Run the following command to transpile the bundles with the new path for the assets:
219
+ ### 2.4. Style the base application
94
220
 
95
- ```bash
96
- npx sass --load-path=path/to/config/file/directory --no-source-map --style compressed node_modules/@genexus/mercury/dist/bundles/scss:untracked-folder/bundles
97
- ```
221
+ ### 2.5. Style the components with the CSS bundles
98
222
 
99
- For example:
223
+ ## 3. CLI flags
100
224
 
101
- ```bash
102
- npx sass --load-path=src --no-source-map --style compressed node_modules/@genexus/mercury/dist/bundles/scss:untracked-folder/bundles
103
- ```
225
+ Flags:
226
+ | Flag | Description |
227
+ | -- | -- |
228
+ | `--globant` <br/><br/> `--gl` <br/><br/> `-gl` | If specified, the generated CSS will use the tokens for the Mercury Globant variant. |
229
+ | `--icons-path=path` <br/><br/>`--icons=path` <br/><br/>`--i=path` <br/><br/>`-i=path` | Allows you to customize the base path for the icons. If not specified, `./assets/icons/` will be used. |
230
+ | `--font-face-path=path` <br/><br/>`--font-face=path` <br/><br/>`--f=path` <br/><br/>`-f=path` | Allows you to customize the base path for the custom fonts. If not specified, `./assets/fonts/` will be used. |
231
+ | `--avoid-hash=bundle1,bundle2,...` <br/><br/>`--ah=bundle1,bundle2,...` <br/><br/>`-ah=bundle1,bundle2,...` | Receives a set of comma-separated values, where each value is a bundle. Allows you to avoid the creating the hash for the provided bundles. |
232
+ | `--outDir=path` <br/><br/>`--outdir=path` <br/><br/>`--o=path` <br/><br/>`-o=path` | Allows you to customize the path where the CSS files will be created. If not specified, `./mercury/` will be used. |