easy-mat-ui 0.0.6 → 1.0.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/LICENSE +21 -0
- package/README.md +361 -63
- package/fesm2022/easy-mat-ui.mjs +2874 -0
- package/fesm2022/easy-mat-ui.mjs.map +1 -0
- package/index.d.ts +1136 -0
- package/package.json +68 -22
- package/page-generator/blocks.js +155 -0
- package/page-generator/catalog.js +132 -0
- package/page-generator/cli/main.js +314 -0
- package/page-generator/cli/project.js +252 -0
- package/page-generator/context.js +108 -0
- package/page-generator/generate.js +182 -0
- package/page-generator/index.js +33 -0
- package/page-generator/naming.js +53 -0
- package/page-generator/table.js +310 -0
- package/page-generator/types.js +6 -0
- package/styles/styles/_backgrounds.scss +39 -0
- package/{src/lib → styles}/styles/_buttons.scss +90 -90
- package/styles/styles/_colors.scss +197 -0
- package/{src/lib → styles}/styles/_effects.scss +44 -44
- package/{src/lib → styles}/styles/_material-overrides.scss +106 -87
- package/{src/lib → styles}/styles/_spacing.scss +68 -68
- package/styles/styles/_tables.scss +569 -0
- package/{src/lib → styles}/styles/_typography.scss +100 -105
- package/{src/lib → styles}/styles.scss +29 -30
- package/ng-package.json +0 -19
- package/src/lib/easy-mat-ui.component.spec.ts +0 -23
- package/src/lib/easy-mat-ui.component.ts +0 -16
- package/src/lib/easy-mat-ui.service.spec.ts +0 -16
- package/src/lib/easy-mat-ui.service.ts +0 -9
- package/src/lib/easy-multi-select/easy-multi-select.css +0 -102
- package/src/lib/easy-multi-select/easy-multi-select.html +0 -51
- package/src/lib/easy-multi-select/easy-multi-select.spec.ts +0 -23
- package/src/lib/easy-multi-select/easy-multi-select.ts +0 -181
- package/src/lib/easy-table/easy-table.component.css +0 -117
- package/src/lib/easy-table/easy-table.component.html +0 -221
- package/src/lib/easy-table/easy-table.component.spec.ts +0 -23
- package/src/lib/easy-table/easy-table.component.ts +0 -568
- package/src/lib/model/dictionary.model.ts +0 -4
- package/src/lib/model/mat-column-typed.model.ts +0 -41
- package/src/lib/model/mat-column.model.ts +0 -35
- package/src/lib/model/tuple.model.ts +0 -8
- package/src/lib/shared/table-toolbar/table-toolbar.css +0 -26
- package/src/lib/shared/table-toolbar/table-toolbar.html +0 -80
- package/src/lib/shared/table-toolbar/table-toolbar.ts +0 -130
- package/src/lib/styles/_backgrounds.scss +0 -39
- package/src/lib/styles/_colors.scss +0 -67
- package/src/lib/styles/_tables.scss +0 -71
- package/src/lib/utils/enums.ts +0 -49
- package/src/lib/utils/matTabCommon.ts +0 -59
- package/src/lib/utils/utils.ts +0 -68
- package/src/public-api.ts +0 -8
- package/tsconfig.lib.json +0 -18
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
package/package.json
CHANGED
|
@@ -1,41 +1,87 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-mat-ui",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "ng build easy-mat-ui"
|
|
7
|
-
},
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Angular 20, 21 and 22 data table and reusable UI components on Angular Material: filters, pagination, CRUD dialog, child tables, themes, page generator CLI",
|
|
8
5
|
"keywords": [
|
|
9
6
|
"angular",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
7
|
+
"angular-20",
|
|
8
|
+
"angular-21",
|
|
9
|
+
"angular-22",
|
|
10
|
+
"angular-material",
|
|
11
|
+
"angular-table",
|
|
12
|
+
"angular-data-table",
|
|
13
|
+
"angular-components",
|
|
14
|
+
"angular-ui-library",
|
|
15
|
+
"mat-table",
|
|
16
|
+
"data-table",
|
|
17
|
+
"datatable",
|
|
18
|
+
"table-filter",
|
|
19
|
+
"pagination",
|
|
20
|
+
"crud",
|
|
21
|
+
"dialog",
|
|
22
|
+
"standalone-components",
|
|
23
|
+
"signals",
|
|
24
|
+
"material-design",
|
|
13
25
|
"i18n",
|
|
14
|
-
"
|
|
26
|
+
"rtl",
|
|
27
|
+
"page-generator",
|
|
15
28
|
"easy-mat-ui"
|
|
16
29
|
],
|
|
17
|
-
"author": "
|
|
30
|
+
"author": "Redouane Chaibi (https://github.com/chaibiredouane)",
|
|
18
31
|
"license": "MIT",
|
|
19
32
|
"peerDependencies": {
|
|
20
|
-
"@angular/
|
|
21
|
-
"@angular/
|
|
22
|
-
"@angular/
|
|
23
|
-
"@angular/
|
|
33
|
+
"@angular/cdk": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
34
|
+
"@angular/common": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
35
|
+
"@angular/core": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
36
|
+
"@angular/forms": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
37
|
+
"@angular/material": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
38
|
+
"@angular/platform-browser": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
24
39
|
"@ngx-translate/core": "^16.0.0",
|
|
25
40
|
"@ngx-translate/http-loader": "^16.0.0",
|
|
26
|
-
"bootstrap": "^5.
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
41
|
+
"bootstrap": "^5.0.0",
|
|
42
|
+
"rxjs": "^7.0.0",
|
|
43
|
+
"flag-icons": "^7.0.0",
|
|
44
|
+
"typescript": ">=5.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"@ngx-translate/http-loader": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"flag-icons": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"typescript": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"bin": {
|
|
58
|
+
"easy-mat-ui": "page-generator/cli/main.js"
|
|
31
59
|
},
|
|
32
60
|
"dependencies": {
|
|
33
|
-
"tslib": "^2.
|
|
61
|
+
"tslib": "^2.8.1"
|
|
34
62
|
},
|
|
35
63
|
"module": "fesm2022/easy-mat-ui.mjs",
|
|
36
64
|
"typings": "index.d.ts",
|
|
37
65
|
"sideEffects": false,
|
|
38
66
|
"publishConfig": {
|
|
39
|
-
"access": "public"
|
|
67
|
+
"access": "public",
|
|
68
|
+
"registry": "https://registry.npmjs.org/"
|
|
69
|
+
},
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "git+https://github.com/chaibiredouane/easy-mat-ui.git"
|
|
73
|
+
},
|
|
74
|
+
"bugs": {
|
|
75
|
+
"url": "https://github.com/chaibiredouane/easy-mat-ui/issues"
|
|
76
|
+
},
|
|
77
|
+
"homepage": "https://easy-mat-ui.web.app/",
|
|
78
|
+
"exports": {
|
|
79
|
+
"./package.json": {
|
|
80
|
+
"default": "./package.json"
|
|
81
|
+
},
|
|
82
|
+
".": {
|
|
83
|
+
"types": "./index.d.ts",
|
|
84
|
+
"default": "./fesm2022/easy-mat-ui.mjs"
|
|
85
|
+
}
|
|
40
86
|
}
|
|
41
|
-
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderPageHeader = renderPageHeader;
|
|
4
|
+
exports.renderStat = renderStat;
|
|
5
|
+
exports.renderChipNav = renderChipNav;
|
|
6
|
+
exports.renderSegmented = renderSegmented;
|
|
7
|
+
exports.renderLanguageSwitch = renderLanguageSwitch;
|
|
8
|
+
exports.renderCardGrid = renderCardGrid;
|
|
9
|
+
const context_1 = require("./context");
|
|
10
|
+
const naming_1 = require("./naming");
|
|
11
|
+
/*
|
|
12
|
+
* Every block returns its HTML and adds what it needs to the context: imports, members of the component, styles.
|
|
13
|
+
* Members are written without a base indentation: the assembler indents them once, inside the class.
|
|
14
|
+
*/
|
|
15
|
+
/** Properties of an object literal, written on one line; the ones without a value are left out. */
|
|
16
|
+
const object = (properties) => `{ ${properties.filter(Boolean).join(', ')} }`;
|
|
17
|
+
const value = (v) => (typeof v === 'number' ? String(v) : (0, naming_1.quote)(v));
|
|
18
|
+
const capitalized = (name) => name.charAt(0).toUpperCase() + name.slice(1);
|
|
19
|
+
const indent = (rows, spaces) => rows.map((row) => ' '.repeat(spaces) + row).join(',\n');
|
|
20
|
+
/**
|
|
21
|
+
* A list of objects as a member. With translations the labels are read by the `TranslateService`, so the list is a
|
|
22
|
+
* `computed` that reads the language and is evaluated again when it changes. Without, it is a plain array.
|
|
23
|
+
*/
|
|
24
|
+
function listMember(ctx, name, type, rows) {
|
|
25
|
+
ctx.useLib(type);
|
|
26
|
+
if (ctx.i18n) {
|
|
27
|
+
ctx.usesInstant = true;
|
|
28
|
+
ctx.needsTranslateService = true;
|
|
29
|
+
ctx.imports.add('@angular/core', 'computed');
|
|
30
|
+
return { member: `readonly ${name} = computed<${type}[]>(() => {\n this.lang();\n return [\n${indent(rows, 4)}\n ];\n});`, call: '()' };
|
|
31
|
+
}
|
|
32
|
+
return { member: `readonly ${name}: ${type}[] = [\n${indent(rows, 2)}\n];`, call: '' };
|
|
33
|
+
}
|
|
34
|
+
function renderPageHeader(ctx, block) {
|
|
35
|
+
const v = (0, context_1.keyOf)(ctx.varName('header'));
|
|
36
|
+
ctx.useComponent('EasyPageHeader');
|
|
37
|
+
const properties = [
|
|
38
|
+
block.icon ? `icon: ${(0, naming_1.quote)(block.icon)}` : undefined,
|
|
39
|
+
`title: ${ctx.tpl(`${v}_TITLE`, block.title)}`,
|
|
40
|
+
block.subtitle ? `subtitle: ${ctx.tpl(`${v}_SUBTITLE`, block.subtitle)}` : undefined
|
|
41
|
+
];
|
|
42
|
+
return `<lib-easy-page-header [config]="${object(properties)}" />`;
|
|
43
|
+
}
|
|
44
|
+
function renderStat(ctx, block) {
|
|
45
|
+
const v = (0, context_1.keyOf)(ctx.varName('stats'));
|
|
46
|
+
ctx.useComponent('EasyStat');
|
|
47
|
+
ctx.styles.add('.stats { display: flex; flex-wrap: wrap; gap: 12px; }');
|
|
48
|
+
const stats = block.stats.map((stat, i) => {
|
|
49
|
+
const properties = [
|
|
50
|
+
`label: ${ctx.tpl(`${v}_${i + 1}_LABEL`, stat.label)}`,
|
|
51
|
+
`value: ${value(stat.value)}`,
|
|
52
|
+
stat.icon ? `icon: ${(0, naming_1.quote)(stat.icon)}` : undefined,
|
|
53
|
+
stat.tone ? `tone: ${(0, naming_1.quote)(stat.tone)}` : undefined,
|
|
54
|
+
stat.hint ? `hint: ${ctx.tpl(`${v}_${i + 1}_HINT`, stat.hint)}` : undefined
|
|
55
|
+
];
|
|
56
|
+
return ` <lib-easy-stat [config]="${object(properties)}" />`;
|
|
57
|
+
});
|
|
58
|
+
return `<div class="stats">\n${stats.join('\n')}\n</div>`;
|
|
59
|
+
}
|
|
60
|
+
function renderChipNav(ctx, block) {
|
|
61
|
+
const name = ctx.varName('nav');
|
|
62
|
+
const v = (0, context_1.keyOf)(name);
|
|
63
|
+
ctx.useComponent('EasyChipNav');
|
|
64
|
+
ctx.imports.add('@angular/core', 'signal');
|
|
65
|
+
const rows = block.items.map((item) => object([
|
|
66
|
+
`id: ${(0, naming_1.quote)(item.id)}`,
|
|
67
|
+
`label: ${ctx.ts(`${v}_ITEM_${(0, context_1.keyOf)(item.id)}`, item.label)}`,
|
|
68
|
+
item.icon ? `icon: ${(0, naming_1.quote)(item.icon)}` : undefined,
|
|
69
|
+
item.color ? `color: ${(0, naming_1.quote)(item.color)}` : undefined,
|
|
70
|
+
item.count !== undefined ? `count: ${item.count}` : undefined
|
|
71
|
+
]));
|
|
72
|
+
const list = listMember(ctx, `${name}Items`, 'EasyChipNavItem', rows);
|
|
73
|
+
ctx.members.push(list.member, `readonly ${name}Selected = signal(${(0, naming_1.quote)(block.selected ?? block.items[0]?.id ?? '')});`);
|
|
74
|
+
return `<lib-easy-chip-nav
|
|
75
|
+
[items]="${name}Items${list.call}"
|
|
76
|
+
[selected]="${name}Selected()"
|
|
77
|
+
${ctx.attr('ariaLabel', `${v}_ARIA`, block.ariaLabel)}
|
|
78
|
+
(selectedChange)="${name}Selected.set($event)" />`;
|
|
79
|
+
}
|
|
80
|
+
function renderSegmented(ctx, block) {
|
|
81
|
+
const name = ctx.varName('segmented');
|
|
82
|
+
const v = (0, context_1.keyOf)(name);
|
|
83
|
+
ctx.useComponent('EasySegmented');
|
|
84
|
+
ctx.imports.add('@angular/core', 'signal');
|
|
85
|
+
const rows = block.options.map((option) => object([
|
|
86
|
+
`id: ${(0, naming_1.quote)(option.id)}`,
|
|
87
|
+
option.label ? `label: ${ctx.ts(`${v}_OPTION_${(0, context_1.keyOf)(option.id)}`, option.label)}` : undefined,
|
|
88
|
+
option.icon ? `icon: ${(0, naming_1.quote)(option.icon)}` : undefined,
|
|
89
|
+
option.hint ? `hint: ${ctx.ts(`${v}_HINT_${(0, context_1.keyOf)(option.id)}`, option.hint)}` : undefined
|
|
90
|
+
]));
|
|
91
|
+
const list = listMember(ctx, `${name}Options`, 'EasySegmentedOption', rows);
|
|
92
|
+
ctx.members.push(list.member, `readonly ${name}Selected = signal(${(0, naming_1.quote)(block.selected ?? block.options[0]?.id ?? '')});`);
|
|
93
|
+
const extra = [block.iconOnly ? '[iconOnly]="true"' : '', block.size && block.size !== 'md' ? `size="${block.size}"` : ''].filter(Boolean);
|
|
94
|
+
return `<lib-easy-segmented
|
|
95
|
+
[options]="${name}Options${list.call}"
|
|
96
|
+
[selected]="${name}Selected()"
|
|
97
|
+
${ctx.attr('ariaLabel', `${v}_ARIA`, block.ariaLabel)}${extra.map((e) => `\n ${e}`).join('')}
|
|
98
|
+
(selectedChange)="${name}Selected.set($event)" />`;
|
|
99
|
+
}
|
|
100
|
+
function renderLanguageSwitch(ctx, block) {
|
|
101
|
+
const name = ctx.varName('languages');
|
|
102
|
+
const v = (0, context_1.keyOf)(name);
|
|
103
|
+
const handler = `on${capitalized(name)}`;
|
|
104
|
+
ctx.useComponent('EasyLanguageSwitch');
|
|
105
|
+
ctx.useLib('EasyLanguage');
|
|
106
|
+
ctx.imports.add('@angular/core', 'signal');
|
|
107
|
+
// The names of the languages are written in their own language: they are never translated.
|
|
108
|
+
const rows = block.languages.map((language) => object([`code: ${(0, naming_1.quote)(language.code)}`, `name: ${(0, naming_1.quote)(language.name)}`, language.flag ? `flag: ${(0, naming_1.quote)(language.flag)}` : undefined]));
|
|
109
|
+
const first = block.selected ?? block.languages[0]?.code ?? 'en';
|
|
110
|
+
if (ctx.i18n)
|
|
111
|
+
ctx.needsTranslateService = true;
|
|
112
|
+
const initial = ctx.i18n ? `this.translate.currentLang || ${(0, naming_1.quote)(first)}` : (0, naming_1.quote)(first);
|
|
113
|
+
const change = ctx.i18n ? 'this.translate.use(code);' : '// Change the language of your application here.';
|
|
114
|
+
ctx.members.push(`readonly ${name}: EasyLanguage[] = [\n${indent(rows, 2)}\n];`, `readonly ${name}Selected = signal(${initial});`, `${handler}(code: string): void {\n this.${name}Selected.set(code);\n ${change}\n}`);
|
|
115
|
+
const extra = [
|
|
116
|
+
block.layout && block.layout !== 'menu' ? `layout="${block.layout}"` : '',
|
|
117
|
+
block.display && block.display !== 'flag-name' ? `display="${block.display}"` : ''
|
|
118
|
+
].filter(Boolean);
|
|
119
|
+
return `<lib-easy-language-switch
|
|
120
|
+
[languages]="${name}"
|
|
121
|
+
[selected]="${name}Selected()"
|
|
122
|
+
${ctx.attr('ariaLabel', `${v}_ARIA`, block.ariaLabel)}${extra.map((e) => `\n ${e}`).join('')}
|
|
123
|
+
(selectedChange)="${handler}($event)" />`;
|
|
124
|
+
}
|
|
125
|
+
function renderCardGrid(ctx, block) {
|
|
126
|
+
const name = ctx.varName('cards');
|
|
127
|
+
const v = (0, context_1.keyOf)(name);
|
|
128
|
+
const handler = `on${capitalized(name)}Click`;
|
|
129
|
+
ctx.useComponent('EasyCardGrid');
|
|
130
|
+
const rows = block.cards.map((card, i) => {
|
|
131
|
+
const id = card.id && (0, naming_1.isIdentifier)(card.id) ? card.id : `card${i + 1}`;
|
|
132
|
+
return object([
|
|
133
|
+
`id: ${(0, naming_1.quote)(id)}`,
|
|
134
|
+
card.icon ? `icon: ${(0, naming_1.quote)(card.icon)}` : undefined,
|
|
135
|
+
`title: ${ctx.ts(`${v}_${(0, context_1.keyOf)(id)}_TITLE`, card.title)}`,
|
|
136
|
+
card.description ? `description: ${ctx.ts(`${v}_${(0, context_1.keyOf)(id)}_DESCRIPTION`, card.description)}` : undefined,
|
|
137
|
+
card.color ? `color: ${(0, naming_1.quote)(card.color)}` : undefined,
|
|
138
|
+
card.clickable ? 'clickable: true' : undefined,
|
|
139
|
+
card.clickable && card.cta ? `cta: ${ctx.ts(`${v}_${(0, context_1.keyOf)(id)}_CTA`, card.cta)}` : undefined
|
|
140
|
+
]);
|
|
141
|
+
});
|
|
142
|
+
const list = listMember(ctx, name, 'EasyCardConfig', rows);
|
|
143
|
+
ctx.members.push(list.member);
|
|
144
|
+
const clickable = block.cards.some((card) => card.clickable);
|
|
145
|
+
if (clickable) {
|
|
146
|
+
ctx.members.push(`${handler}(card: EasyCardConfig): void {\n // card.id tells which card was used.\n}`);
|
|
147
|
+
}
|
|
148
|
+
const attributes = [
|
|
149
|
+
`[items]="${name}${list.call}"`,
|
|
150
|
+
block.columns ? `[columns]="${block.columns}"` : '',
|
|
151
|
+
block.minWidth ? `[minWidth]="${block.minWidth}"` : '',
|
|
152
|
+
clickable ? `(cardClick)="${handler}($event)"` : ''
|
|
153
|
+
].filter(Boolean);
|
|
154
|
+
return `<lib-easy-card-grid\n ${attributes.join('\n ')} />`;
|
|
155
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STANDARD_TRANSLATIONS = exports.BLOCK_CATEGORIES = exports.BLOCK_CATALOG = void 0;
|
|
4
|
+
exports.genericModel = genericModel;
|
|
5
|
+
exports.genericChildModel = genericChildModel;
|
|
6
|
+
exports.defaultBlock = defaultBlock;
|
|
7
|
+
const naming_1 = require("./naming");
|
|
8
|
+
/** The components a page can be made of, by category. The CLI menu and the Builder of the demo both read this list. */
|
|
9
|
+
exports.BLOCK_CATALOG = [
|
|
10
|
+
{ type: 'page-header', category: 'Page', label: 'Page header', description: 'Icon, title and subtitle at the top of the page.', icon: 'title' },
|
|
11
|
+
{ type: 'table', category: 'Data', label: 'Data table', description: 'Table with filters, pagination and an add / edit / delete dialog. It can open a second table under a row.', icon: 'table_chart' },
|
|
12
|
+
{ type: 'stat', category: 'Data', label: 'Key figures', description: 'A few numbers with a label, an icon and a tone.', icon: 'analytics' },
|
|
13
|
+
{ type: 'chip-nav', category: 'Navigation', label: 'Category buttons', description: 'Buttons with an icon, a colour and a count, to browse by category.', icon: 'category' },
|
|
14
|
+
{ type: 'segmented', category: 'Navigation', label: 'Segmented control', description: 'A small group of buttons of which one is chosen: a setting, a view, a page.', icon: 'toggle_on' },
|
|
15
|
+
{ type: 'card-grid', category: 'Content', label: 'Card grid', description: 'Cards with an icon, a title, a description and optional actions, in a responsive grid.', icon: 'grid_view' },
|
|
16
|
+
{ type: 'language-switch', category: 'Settings', label: 'Language picker', description: 'A menu or a row of buttons to choose the language.', icon: 'translate' }
|
|
17
|
+
];
|
|
18
|
+
exports.BLOCK_CATEGORIES = ['Page', 'Data', 'Navigation', 'Content', 'Settings'];
|
|
19
|
+
const field = (name, type) => ({ name, type });
|
|
20
|
+
/** A model made of placeholders (`item1`, `item2`, `item3`...), to rename. */
|
|
21
|
+
function genericModel() {
|
|
22
|
+
return {
|
|
23
|
+
className: 'Item',
|
|
24
|
+
fileBase: 'item',
|
|
25
|
+
generate: true,
|
|
26
|
+
fields: [field('id', 'number'), field('item1', 'string'), field('item2', 'string'), field('item3', 'string'), field('active', 'boolean')]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The model of the rows of a child table: it points to its parent with `parentId`. */
|
|
30
|
+
function genericChildModel() {
|
|
31
|
+
return {
|
|
32
|
+
className: 'SubItem',
|
|
33
|
+
fileBase: 'sub-item',
|
|
34
|
+
generate: true,
|
|
35
|
+
fields: [field('id', 'number'), field('parentId', 'number'), field('subItem1', 'string'), field('subItem2', 'string'), field('active', 'boolean')]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** A block with sensible example values, to start from. */
|
|
39
|
+
function defaultBlock(type, pageName) {
|
|
40
|
+
switch (type) {
|
|
41
|
+
case 'page-header':
|
|
42
|
+
return { type, icon: 'dashboard', title: (0, naming_1.title)(pageName), subtitle: 'Say in one sentence what this page is for.' };
|
|
43
|
+
case 'stat':
|
|
44
|
+
return {
|
|
45
|
+
type,
|
|
46
|
+
stats: [
|
|
47
|
+
{ label: 'Total', value: 128, icon: 'inventory_2', tone: 'accent' },
|
|
48
|
+
{ label: 'Active', value: 96, tone: 'success' },
|
|
49
|
+
{ label: 'Archived', value: 32, tone: 'neutral' }
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
case 'chip-nav':
|
|
53
|
+
return {
|
|
54
|
+
type,
|
|
55
|
+
ariaLabel: 'Browse by category',
|
|
56
|
+
selected: 'all',
|
|
57
|
+
items: [
|
|
58
|
+
{ id: 'all', label: 'All', icon: 'apps', count: 12 },
|
|
59
|
+
{ id: 'categoryA', label: 'Category A', icon: 'folder', color: '#1d4ed8', count: 5 },
|
|
60
|
+
{ id: 'categoryB', label: 'Category B', icon: 'folder', color: '#15803d', count: 4 },
|
|
61
|
+
{ id: 'categoryC', label: 'Category C', icon: 'folder', color: '#b45309', count: 3 }
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
case 'segmented':
|
|
65
|
+
return {
|
|
66
|
+
type,
|
|
67
|
+
ariaLabel: 'View',
|
|
68
|
+
selected: 'list',
|
|
69
|
+
options: [
|
|
70
|
+
{ id: 'list', label: 'List', icon: 'view_list' },
|
|
71
|
+
{ id: 'grid', label: 'Grid', icon: 'grid_view' }
|
|
72
|
+
]
|
|
73
|
+
};
|
|
74
|
+
case 'language-switch':
|
|
75
|
+
return {
|
|
76
|
+
type,
|
|
77
|
+
ariaLabel: 'Choose the language',
|
|
78
|
+
selected: 'en',
|
|
79
|
+
layout: 'menu',
|
|
80
|
+
display: 'flag-name',
|
|
81
|
+
languages: [
|
|
82
|
+
{ code: 'en', name: 'English', flag: 'gb' },
|
|
83
|
+
{ code: 'fr', name: 'Français', flag: 'fr' },
|
|
84
|
+
{ code: 'de', name: 'Deutsch', flag: 'de' }
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
case 'card-grid':
|
|
88
|
+
return {
|
|
89
|
+
type,
|
|
90
|
+
columns: 3,
|
|
91
|
+
minWidth: 240,
|
|
92
|
+
cards: [
|
|
93
|
+
{ id: 'card1', icon: 'rocket_launch', title: 'First card', description: 'Say what it is about.', clickable: true, cta: 'Open' },
|
|
94
|
+
{ id: 'card2', icon: 'tune', title: 'Second card', description: 'Another short description.', clickable: true, cta: 'Open' },
|
|
95
|
+
{ id: 'card3', icon: 'insights', title: 'Third card', description: 'And one more.' }
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
case 'table':
|
|
99
|
+
return { type, title: (0, naming_1.title)(pageName), icon: 'grid_view', model: genericModel(), canCreate: true, canUpdate: true, canDelete: true, filters: true, pageSize: 10 };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The labels the table and its dialog read from the translation file (they belong to the library, not to a page).
|
|
104
|
+
* They are added at the root of the file, only when missing.
|
|
105
|
+
*/
|
|
106
|
+
exports.STANDARD_TRANSLATIONS = {
|
|
107
|
+
SEARCH: 'Search',
|
|
108
|
+
FILTER: 'Filter',
|
|
109
|
+
FILTERS: 'Filters',
|
|
110
|
+
CLEAR: 'Clear',
|
|
111
|
+
ADD: 'Add',
|
|
112
|
+
CLOSE: 'Close',
|
|
113
|
+
SAVE: 'Save',
|
|
114
|
+
NO_OPTIONS: 'No options',
|
|
115
|
+
NO_RESULTS_FOUND: 'No results found',
|
|
116
|
+
details: 'Details',
|
|
117
|
+
edit: 'Edit',
|
|
118
|
+
Delete: 'Delete',
|
|
119
|
+
Cancel: 'Cancel',
|
|
120
|
+
DETECT_CHANGES: 'Unsaved changes',
|
|
121
|
+
ASK_SAVE_CHANGES: 'Do you want to save your changes?',
|
|
122
|
+
CONFIRMATION_SAVE: 'Save',
|
|
123
|
+
CONFIRMATION_SAVE_CANCEL: 'Discard',
|
|
124
|
+
UNCOMPLETED_FORM: 'Incomplete form',
|
|
125
|
+
FILL_MISSING_FIELDS: 'Please fill in the required fields.',
|
|
126
|
+
'PAGINATOR.ITEMS_PER_PAGE': 'Items per page:',
|
|
127
|
+
'PAGINATOR.NEXT_PAGE': 'Next page',
|
|
128
|
+
'PAGINATOR.PREVIOUS_PAGE': 'Previous page',
|
|
129
|
+
'PAGINATOR.FIRST_PAGE': 'First page',
|
|
130
|
+
'PAGINATOR.LAST_PAGE': 'Last page',
|
|
131
|
+
'PAGINATOR.RANGE': '{{start}} – {{end}} of {{length}}'
|
|
132
|
+
};
|