@genexus/mercury 0.11.0 → 0.12.1
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/dist/assets/MERCURY_ASSETS.js +1 -14724
- package/dist/assets-manager.d.ts +5 -56
- package/dist/assets-manager.js +1 -177
- package/dist/bundles/css/all.css +1 -1
- package/dist/bundles/css/components/dialog.css +1 -1
- package/dist/bundles/css/components/toggle.css +1 -1
- package/dist/bundles.d.ts +2 -10
- package/dist/bundles.js +1 -96
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -0
- package/dist/mercury.scss +7 -2
- package/dist/register-mercury.d.ts +1 -0
- package/dist/register-mercury.js +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.js +1 -0
- package/package.json +35 -6
package/dist/assets-manager.d.ts
CHANGED
|
@@ -1,59 +1,8 @@
|
|
|
1
|
-
import { GxImageMultiState, NavigationListItemModel, TreeViewImagePathCallback } from "@genexus/chameleon-controls-library";
|
|
2
|
-
import { RegistryGetImagePathCallback } from "@genexus/chameleon-controls-library/dist/types/index";
|
|
3
|
-
import { ActionListItemAdditionalBase } from "@genexus/chameleon-controls-library/dist/types/components/action-list/types.
|
|
4
|
-
import {
|
|
5
|
-
export
|
|
6
|
-
export { getThemeBundles, getBundles } from "./bundles.js";
|
|
7
|
-
export type AssetsMetadata = {
|
|
8
|
-
category: string;
|
|
9
|
-
name: string;
|
|
10
|
-
colorType?: string;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* For example:
|
|
14
|
-
* ```
|
|
15
|
-
* {
|
|
16
|
-
* icons: {
|
|
17
|
-
* objects: { // Category
|
|
18
|
-
* stencil: { // Icon Name
|
|
19
|
-
* enabled: { // State
|
|
20
|
-
* name: "objects_stencil--enabled"
|
|
21
|
-
* }
|
|
22
|
-
* },
|
|
23
|
-
* },
|
|
24
|
-
* windows-tools: { // Category
|
|
25
|
-
* workflow: { // Icon Name
|
|
26
|
-
* "on-surface": { // Color Type
|
|
27
|
-
* enabled: { // State
|
|
28
|
-
* name: "windows-tools_workflow_on-surface--enabled"
|
|
29
|
-
* },
|
|
30
|
-
* hover: {
|
|
31
|
-
* name: "windows-tools_workflow_on-surface--hover"
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* }
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export type Assets = {
|
|
41
|
-
icons: {
|
|
42
|
-
[key in string]: AssetsCategories;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
export type AssetsCategories = {
|
|
46
|
-
[key: string]: AssetsIconName;
|
|
47
|
-
};
|
|
48
|
-
export type AssetsIconName = {
|
|
49
|
-
[key: string]: AssetsColorType;
|
|
50
|
-
} | AssetsColorType;
|
|
51
|
-
export type AssetsColorType = {
|
|
52
|
-
[key: string]: AssetsIconMetadata;
|
|
53
|
-
};
|
|
54
|
-
export interface AssetsIconMetadata {
|
|
55
|
-
name: string;
|
|
56
|
-
}
|
|
1
|
+
import type { ComboBoxImagePathCallback, GxImageMultiState, NavigationListItemModel, TreeViewImagePathCallback } from "@genexus/chameleon-controls-library";
|
|
2
|
+
import type { RegistryGetImagePathCallback } from "@genexus/chameleon-controls-library/dist/types/index.d.ts";
|
|
3
|
+
import type { ActionListItemAdditionalBase } from "@genexus/chameleon-controls-library/dist/types/components/action-list/types.d.ts";
|
|
4
|
+
import type { Assets, AssetsColorType, AssetsMetadata } from "./types.d.ts";
|
|
5
|
+
export declare const MERCURY_ALIAS = "mer";
|
|
57
6
|
/**
|
|
58
7
|
* Given a vendor and its assets, it register the assets of the vendor. After
|
|
59
8
|
* the registration, the `getAsset` function can be used to retrieve any assets
|
package/dist/assets-manager.js
CHANGED
|
@@ -1,177 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { getThemeBundles, getBundles } from "./bundles.js";
|
|
3
|
-
const ASSETS_BY_VENDOR = {};
|
|
4
|
-
const ALIAS_TO_VENDOR_NAME = {};
|
|
5
|
-
const SEPARATOR = "/";
|
|
6
|
-
const EXPANDED_SEPARATOR = ":";
|
|
7
|
-
const MERCURY_ALIAS = "mer";
|
|
8
|
-
/**
|
|
9
|
-
* Given a vendor and its assets, it register the assets of the vendor. After
|
|
10
|
-
* the registration, the `getAsset` function can be used to retrieve any assets
|
|
11
|
-
* related to the vendor.
|
|
12
|
-
* @param vendorName The name of the vendor (for example, "Mercury"). Must be unique.
|
|
13
|
-
* @param vendorAlias The alias of the vendor (for example, "mer"). Must be unique.
|
|
14
|
-
* @param assets The assets (generated by the SVG Sass Generator) to register.
|
|
15
|
-
*/
|
|
16
|
-
export const registerAssets = (vendorName, vendorAlias, assets) => {
|
|
17
|
-
// Already registered
|
|
18
|
-
if (ASSETS_BY_VENDOR[vendorName] || ALIAS_TO_VENDOR_NAME[vendorAlias]) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
ASSETS_BY_VENDOR[vendorName] = assets;
|
|
22
|
-
ALIAS_TO_VENDOR_NAME[vendorAlias] = vendorName;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* @param vendorAlias The name or alias of the vendor.
|
|
26
|
-
* @param assetMetadata The metadata required to retrieve the icon
|
|
27
|
-
* @return The required asset or undefined if not found.
|
|
28
|
-
*/
|
|
29
|
-
export const getAsset = (vendorAliasOrName, assetMetadata) => {
|
|
30
|
-
const vendorName = ALIAS_TO_VENDOR_NAME[vendorAliasOrName] ?? vendorAliasOrName;
|
|
31
|
-
const vendorAssets = ASSETS_BY_VENDOR[vendorName];
|
|
32
|
-
if (!vendorAssets) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
const iconCategoryObject = vendorAssets.icons[assetMetadata.category];
|
|
36
|
-
// The category does not exists
|
|
37
|
-
if (!iconCategoryObject) {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
const iconNameObject = iconCategoryObject[assetMetadata.name];
|
|
41
|
-
// The name in the category does not exists
|
|
42
|
-
if (!iconNameObject) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
return assetMetadata.colorType
|
|
46
|
-
? iconNameObject[assetMetadata.colorType]
|
|
47
|
-
: iconNameObject;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Given the metadata of the icon, it transforms the metadata into a string
|
|
51
|
-
* that contains the given information.
|
|
52
|
-
*/
|
|
53
|
-
export const getIconPath = (iconMetadata, vendorAlias = MERCURY_ALIAS) => {
|
|
54
|
-
const additionalInfo = iconMetadata.colorType
|
|
55
|
-
? `${SEPARATOR}${iconMetadata.colorType}`
|
|
56
|
-
: "";
|
|
57
|
-
return `${vendorAlias}${SEPARATOR}${iconMetadata.category}${SEPARATOR}${iconMetadata.name}${additionalInfo}`;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Given the metadata of the icon and the metadata of its expanded version, it
|
|
61
|
-
* transforms both metadata into a string that contains the given information.
|
|
62
|
-
*/
|
|
63
|
-
export const getIconPathExpanded = (iconMetadata, iconMetadataExpanded, vendorAlias = MERCURY_ALIAS) => `${getIconPath(iconMetadata, vendorAlias)}${EXPANDED_SEPARATOR}${getIconPath(iconMetadataExpanded, vendorAlias)}`;
|
|
64
|
-
const getCustomFullValue = (iconName, vendorAliasOrName, suffix) => {
|
|
65
|
-
const vendorPrefix = vendorAliasOrName === MERCURY_ALIAS
|
|
66
|
-
? ""
|
|
67
|
-
: `-${vendorAliasOrName}`;
|
|
68
|
-
return suffix
|
|
69
|
-
? `var(--icon${vendorPrefix}__${iconName}--${suffix})`
|
|
70
|
-
: `var(--icon${vendorPrefix}__${iconName})`;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Parses the incoming iconMetadata, assuming Mercury as the default vendor if
|
|
74
|
-
* the vendor is not specified (it is not found in the register)
|
|
75
|
-
*/
|
|
76
|
-
const parseIconMetadata = (iconPath) => {
|
|
77
|
-
const iconMetadata = iconPath.split(SEPARATOR);
|
|
78
|
-
const vendorAliasOrName = iconMetadata[0];
|
|
79
|
-
const vendorName = ALIAS_TO_VENDOR_NAME[vendorAliasOrName] ?? vendorAliasOrName;
|
|
80
|
-
const vendorAssets = ASSETS_BY_VENDOR[vendorName];
|
|
81
|
-
// The vendor is not contained in the path, assume by default Mercury.
|
|
82
|
-
if (!vendorAssets) {
|
|
83
|
-
const category = iconMetadata[0]; // Assume that the first value is the category
|
|
84
|
-
const name = iconMetadata[1];
|
|
85
|
-
const colorType = iconMetadata[2];
|
|
86
|
-
return {
|
|
87
|
-
vendor: MERCURY_ALIAS,
|
|
88
|
-
category,
|
|
89
|
-
name,
|
|
90
|
-
colorType: colorType
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
const category = iconMetadata[1];
|
|
94
|
-
const name = iconMetadata[2];
|
|
95
|
-
const colorType = iconMetadata[3];
|
|
96
|
-
return {
|
|
97
|
-
vendor: vendorAliasOrName,
|
|
98
|
-
category,
|
|
99
|
-
name,
|
|
100
|
-
colorType: colorType
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
export const getImagePathCallback = (iconPath) => {
|
|
104
|
-
const { vendor, category, name, colorType } = parseIconMetadata(iconPath);
|
|
105
|
-
const assetStates = getAsset(vendor, colorType ? { category, name, colorType } : { category, name });
|
|
106
|
-
if (!assetStates) {
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
const result = {
|
|
110
|
-
base: getCustomFullValue(assetStates.enabled.name, vendor)
|
|
111
|
-
};
|
|
112
|
-
if (assetStates.hover) {
|
|
113
|
-
result.hover = getCustomFullValue(assetStates.hover.name, vendor);
|
|
114
|
-
}
|
|
115
|
-
if (assetStates.active) {
|
|
116
|
-
result.active = getCustomFullValue(assetStates.active.name, vendor);
|
|
117
|
-
}
|
|
118
|
-
if (assetStates.disabled) {
|
|
119
|
-
result.disabled = getCustomFullValue(assetStates.disabled.name, vendor);
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
};
|
|
123
|
-
export const getActionListImagePathCallback = (additionalItem) => additionalItem.imgSrc
|
|
124
|
-
? getImagePathCallback(additionalItem.imgSrc)
|
|
125
|
-
: undefined;
|
|
126
|
-
export const getNavigationListImagePathCallback = (itemModel) => itemModel.startImgSrc
|
|
127
|
-
? getImagePathCallback(itemModel.startImgSrc)
|
|
128
|
-
: undefined;
|
|
129
|
-
export const getTreeViewImagePathCallback = (item, iconDirection) => {
|
|
130
|
-
if ((!item.startImgSrc && iconDirection === "start") ||
|
|
131
|
-
(!item.endImgSrc && iconDirection === "end")) {
|
|
132
|
-
return undefined;
|
|
133
|
-
}
|
|
134
|
-
const imgSrc = iconDirection === "start" ? item.startImgSrc : item.endImgSrc;
|
|
135
|
-
// Split the path into the collapsed (default) and expanded
|
|
136
|
-
const collapsedAndExpandedSrc = imgSrc.split(EXPANDED_SEPARATOR);
|
|
137
|
-
const defaultPath = getImagePathCallback(collapsedAndExpandedSrc[0]);
|
|
138
|
-
if (!defaultPath) {
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
// If the icon has expanded state, process the expanded state
|
|
142
|
-
return collapsedAndExpandedSrc[1]
|
|
143
|
-
? {
|
|
144
|
-
default: defaultPath,
|
|
145
|
-
expanded: getImagePathCallback(collapsedAndExpandedSrc[1])
|
|
146
|
-
}
|
|
147
|
-
: { default: defaultPath };
|
|
148
|
-
};
|
|
149
|
-
export const getComboBoxImagePathCallback = (item, iconDirection) => {
|
|
150
|
-
if ((!item.startImgSrc && iconDirection === "start") ||
|
|
151
|
-
(!item.endImgSrc && iconDirection === "end")) {
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
const imgSrc = iconDirection === "start" ? item.startImgSrc : item.endImgSrc;
|
|
155
|
-
return getImagePathCallback(imgSrc);
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* This object is used to register the getImagePathCallback definitions for all
|
|
159
|
-
* controls in Chameleon.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```ts
|
|
163
|
-
* registryProperty("getImagePathCallback", getImagePathCallbackDefinitions);
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
export const getImagePathCallbackDefinitions = {
|
|
167
|
-
"ch-accordion-render": getImagePathCallback,
|
|
168
|
-
"ch-action-list-render": getActionListImagePathCallback,
|
|
169
|
-
"ch-combo-box-render": getComboBoxImagePathCallback,
|
|
170
|
-
"ch-navigation-list-render": getNavigationListImagePathCallback,
|
|
171
|
-
"ch-checkbox": getImagePathCallback,
|
|
172
|
-
"ch-edit": getImagePathCallback,
|
|
173
|
-
"ch-image": getImagePathCallback,
|
|
174
|
-
"ch-tree-view-render": getTreeViewImagePathCallback
|
|
175
|
-
};
|
|
176
|
-
// Initialize Mercury at the start
|
|
177
|
-
registerAssets("Mercury", MERCURY_ALIAS, MERCURY_ASSETS);
|
|
1
|
+
"use strict";const a={},d={},g="/",i=":";export const MERCURY_ALIAS="mer",registerAssets=(e,t,n)=>{a[e]||d[t]||(a[e]=n,d[t]=e)},getAsset=(e,t)=>{const n=d[e]??e,r=a[n];if(!r)return;const c=r.icons[t.category];if(!c)return;const o=c[t.name];if(o)return t.colorType?o[t.colorType]:o},getIconPath=(e,t=MERCURY_ALIAS)=>{const n=e.colorType?`${g}${e.colorType}`:"";return`${t}${g}${e.category}${g}${e.name}${n}`},getIconPathExpanded=(e,t,n=MERCURY_ALIAS)=>`${getIconPath(e,n)}${i}${getIconPath(t,n)}`;const l=(e,t,n)=>{const r=t===MERCURY_ALIAS?"":`-${t}`;return n?`var(--icon${r}__${e}--${n})`:`var(--icon${r}__${e})`},S=e=>{const t=e.split(g),n=t[0],r=d[n]??n;if(!a[r]){const p=t[0],m=t[1],f=t[2];return{vendor:MERCURY_ALIAS,category:p,name:m,colorType:f}}const o=t[1],s=t[2],u=t[3];return{vendor:n,category:o,name:s,colorType:u}};export const getImagePathCallback=e=>{const{vendor:t,category:n,name:r,colorType:c}=S(e),o=getAsset(t,c?{category:n,name:r,colorType:c}:{category:n,name:r});if(!o)return;const s={base:l(o.enabled.name,t)};return o.hover&&(s.hover=l(o.hover.name,t)),o.active&&(s.active=l(o.active.name,t)),o.disabled&&(s.disabled=l(o.disabled.name,t)),s},getActionListImagePathCallback=e=>e.imgSrc?getImagePathCallback(e.imgSrc):void 0,getNavigationListImagePathCallback=e=>e.startImgSrc?getImagePathCallback(e.startImgSrc):void 0,getTreeViewImagePathCallback=(e,t)=>{if(!e.startImgSrc&&t==="start"||!e.endImgSrc&&t==="end")return;const r=(t==="start"?e.startImgSrc:e.endImgSrc).split(i),c=getImagePathCallback(r[0]);if(c)return r[1]?{default:c,expanded:getImagePathCallback(r[1])}:{default:c}},getComboBoxImagePathCallback=(e,t)=>{if(!e.startImgSrc&&t==="start"||!e.endImgSrc&&t==="end")return;const n=t==="start"?e.startImgSrc:e.endImgSrc;return getImagePathCallback(n)},getImagePathCallbackDefinitions={"ch-accordion-render":getImagePathCallback,"ch-action-list-render":getActionListImagePathCallback,"ch-combo-box-render":getComboBoxImagePathCallback,"ch-navigation-list-render":getNavigationListImagePathCallback,"ch-checkbox":getImagePathCallback,"ch-edit":getImagePathCallback,"ch-image":getImagePathCallback,"ch-tree-view-render":getTreeViewImagePathCallback};
|