@retalia/pos-components 0.0.4 → 0.0.5
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/fesm2022/retalia-pos-components.mjs +1089 -0
- package/fesm2022/retalia-pos-components.mjs.map +1 -0
- package/package.json +39 -17
- package/types/retalia-pos-components.d.ts +300 -0
- package/eslint.config.js +0 -32
- package/ng-package.json +0 -14
- package/src/lib/basket/pos-basket.html +0 -124
- package/src/lib/basket/pos-basket.scss +0 -285
- package/src/lib/basket/pos-basket.spec.ts +0 -198
- package/src/lib/basket/pos-basket.stories.ts +0 -114
- package/src/lib/basket/pos-basket.ts +0 -142
- package/src/lib/item-entry/pos-item-entry.html +0 -41
- package/src/lib/item-entry/pos-item-entry.scss +0 -145
- package/src/lib/item-entry/pos-item-entry.spec.ts +0 -123
- package/src/lib/item-entry/pos-item-entry.stories.ts +0 -31
- package/src/lib/item-entry/pos-item-entry.ts +0 -81
- package/src/lib/login/pos-login.html +0 -82
- package/src/lib/login/pos-login.scss +0 -238
- package/src/lib/login/pos-login.spec.ts +0 -89
- package/src/lib/login/pos-login.stories.ts +0 -36
- package/src/lib/login/pos-login.ts +0 -150
- package/src/lib/receipt/pos-receipt.html +0 -116
- package/src/lib/receipt/pos-receipt.scss +0 -367
- package/src/lib/receipt/pos-receipt.spec.ts +0 -188
- package/src/lib/receipt/pos-receipt.stories.ts +0 -163
- package/src/lib/receipt/pos-receipt.ts +0 -129
- package/src/lib/tender/pos-tender.html +0 -79
- package/src/lib/tender/pos-tender.scss +0 -318
- package/src/lib/tender/pos-tender.spec.ts +0 -150
- package/src/lib/tender/pos-tender.stories.ts +0 -47
- package/src/lib/tender/pos-tender.ts +0 -154
- package/src/lib/tokens/pos-theme-css.spec.ts +0 -75
- package/src/lib/tokens/pos-theme-css.ts +0 -123
- package/src/lib/tokens/pos-token-catalog.ts +0 -514
- package/src/lib/tokens/pos-tokens.html +0 -351
- package/src/lib/tokens/pos-tokens.scss +0 -437
- package/src/lib/tokens/pos-tokens.spec.ts +0 -164
- package/src/lib/tokens/pos-tokens.stories.ts +0 -22
- package/src/lib/tokens/pos-tokens.ts +0 -208
- package/src/public-api.ts +0 -37
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -11
- /package/{src/styles → styles}/styles.css +0 -0
- /package/{src/styles → styles}/tokens.css +0 -0
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
computed,
|
|
5
|
-
signal,
|
|
6
|
-
} from '@angular/core';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
POS_TOKEN_BY_VARIABLE,
|
|
10
|
-
POS_TOKEN_SAMPLES,
|
|
11
|
-
type PosTokenDefinition,
|
|
12
|
-
type PosTokenSwatch,
|
|
13
|
-
lookupPosTokens,
|
|
14
|
-
tokensInGroup,
|
|
15
|
-
} from './pos-token-catalog';
|
|
16
|
-
import {
|
|
17
|
-
POS_THEME_CSS_FILENAME,
|
|
18
|
-
downloadTextFile,
|
|
19
|
-
normalizePosTokenValue,
|
|
20
|
-
overridesFromThemeValues,
|
|
21
|
-
parseCssHex,
|
|
22
|
-
parsePosThemeCss,
|
|
23
|
-
resolvedPosTheme,
|
|
24
|
-
serializePosThemeCss,
|
|
25
|
-
} from './pos-theme-css';
|
|
26
|
-
|
|
27
|
-
export type { PosTokenSwatch };
|
|
28
|
-
|
|
29
|
-
interface PosTokenSelection {
|
|
30
|
-
readonly id: string;
|
|
31
|
-
readonly title: string;
|
|
32
|
-
readonly variables: readonly string[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@Component({
|
|
36
|
-
selector: 'pos-tokens',
|
|
37
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
38
|
-
templateUrl: './pos-tokens.html',
|
|
39
|
-
styleUrl: './pos-tokens.scss',
|
|
40
|
-
host: {
|
|
41
|
-
class: 'pos-tokens',
|
|
42
|
-
'[style]': 'themeStyle()',
|
|
43
|
-
'(keydown.escape)': 'clearSelection()',
|
|
44
|
-
},
|
|
45
|
-
})
|
|
46
|
-
export class PosTokens {
|
|
47
|
-
protected readonly colorTokens = tokensInGroup('color');
|
|
48
|
-
protected readonly radiusTokens = tokensInGroup('radius');
|
|
49
|
-
protected readonly spaceTokens = tokensInGroup('space');
|
|
50
|
-
protected readonly typeTokens = tokensInGroup('type');
|
|
51
|
-
protected readonly controlTokens = tokensInGroup('control');
|
|
52
|
-
|
|
53
|
-
private readonly overrides = signal<Record<string, string>>({});
|
|
54
|
-
protected readonly selection = signal<PosTokenSelection | null>(null);
|
|
55
|
-
protected readonly statusMessage = signal('');
|
|
56
|
-
|
|
57
|
-
protected readonly selectedTokens = computed(() => {
|
|
58
|
-
const selection = this.selection();
|
|
59
|
-
return selection ? lookupPosTokens(selection.variables) : [];
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
protected readonly hasOverrides = computed(
|
|
63
|
-
() => Object.keys(this.overrides()).length > 0,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
protected readonly themeStyle = computed(() =>
|
|
67
|
-
Object.entries(this.overrides())
|
|
68
|
-
.map(([variable, value]) => `${variable}: ${value}`)
|
|
69
|
-
.join('; '),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
/** Complete :root CSS for the consuming POS. Package defaults are not written. */
|
|
73
|
-
themeCss(): string {
|
|
74
|
-
return serializePosThemeCss(resolvedPosTheme(this.overrides()));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Load a previously exported theme as live overrides. Does not mutate defaults. */
|
|
78
|
-
loadThemeCss(css: string): void {
|
|
79
|
-
const parsed = parsePosThemeCss(css);
|
|
80
|
-
const knownCount = Object.keys(parsed).length;
|
|
81
|
-
this.overrides.set(overridesFromThemeValues(parsed));
|
|
82
|
-
|
|
83
|
-
if (knownCount === 0) {
|
|
84
|
-
this.statusMessage.set('No --pos-* tokens found in that file.');
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this.statusMessage.set(
|
|
89
|
-
`Imported ${knownCount} tokens as live overrides. Package defaults are unchanged.`,
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
resetTheme(): void {
|
|
94
|
-
this.overrides.set({});
|
|
95
|
-
this.statusMessage.set('Live overrides cleared. Package defaults restored in this lab.');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
protected exportThemeFile(): void {
|
|
99
|
-
downloadTextFile(POS_THEME_CSS_FILENAME, this.themeCss());
|
|
100
|
-
this.statusMessage.set(
|
|
101
|
-
`Downloaded ${POS_THEME_CSS_FILENAME}. Add it after the package stylesheet in the host POS.`,
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
protected async onImportFile(event: Event): Promise<void> {
|
|
106
|
-
const input = event.target;
|
|
107
|
-
if (!(input instanceof HTMLInputElement) || !input.files?.length) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const css = await input.files[0].text();
|
|
112
|
-
this.loadThemeCss(css);
|
|
113
|
-
input.value = '';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
protected selectToken(token: PosTokenDefinition): void {
|
|
117
|
-
this.selection.set({
|
|
118
|
-
id: `token:${token.variable}`,
|
|
119
|
-
title: token.name,
|
|
120
|
-
variables: [token.variable],
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
protected selectSample(sampleId: string): void {
|
|
125
|
-
const sample = POS_TOKEN_SAMPLES.find((item) => item.id === sampleId);
|
|
126
|
-
if (!sample) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
this.selection.set({
|
|
131
|
-
id: `sample:${sample.id}`,
|
|
132
|
-
title: sample.label,
|
|
133
|
-
variables: sample.variables,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected clearSelection(): void {
|
|
138
|
-
this.selection.set(null);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
protected isTokenSelected(variable: string): boolean {
|
|
142
|
-
const selection = this.selection();
|
|
143
|
-
return selection?.id === `token:${variable}`;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
protected isSampleSelected(sampleId: string): boolean {
|
|
147
|
-
return this.selection()?.id === `sample:${sampleId}`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
protected isModified(variable: string): boolean {
|
|
151
|
-
return variable in this.overrides();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
protected currentValue(variable: string): string {
|
|
155
|
-
return this.overrides()[variable] ?? POS_TOKEN_BY_VARIABLE.get(variable)?.defaultValue ?? '';
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
protected defaultValue(variable: string): string {
|
|
159
|
-
return POS_TOKEN_BY_VARIABLE.get(variable)?.defaultValue ?? '';
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
protected colorInputValue(variable: string): string | null {
|
|
163
|
-
return parseCssHex(this.currentValue(variable));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
protected tokenFieldId(variable: string): string {
|
|
167
|
-
return `pos-token-field-${variable.replace(/[^a-z0-9]+/gi, '-')}`;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
protected onTokenInput(variable: string, event: Event): void {
|
|
171
|
-
const target = event.target;
|
|
172
|
-
if (!(target instanceof HTMLInputElement)) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
this.setTokenValue(variable, target.value);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
protected resetToken(variable: string): void {
|
|
180
|
-
this.overrides.update((current) => {
|
|
181
|
-
if (!(variable in current)) {
|
|
182
|
-
return current;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const next = { ...current };
|
|
186
|
-
delete next[variable];
|
|
187
|
-
return next;
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
private setTokenValue(variable: string, raw: string): void {
|
|
192
|
-
const token = POS_TOKEN_BY_VARIABLE.get(variable);
|
|
193
|
-
if (!token) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const normalized = normalizePosTokenValue(token.kind, raw);
|
|
198
|
-
this.overrides.update((current) => {
|
|
199
|
-
const next = { ...current };
|
|
200
|
-
if (!normalized || normalized === token.defaultValue) {
|
|
201
|
-
delete next[variable];
|
|
202
|
-
} else {
|
|
203
|
-
next[variable] = normalized;
|
|
204
|
-
}
|
|
205
|
-
return next;
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
package/src/public-api.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Public API Surface of @retalia/pos-components
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export { PosLogin } from './lib/login/pos-login';
|
|
6
|
-
export type {
|
|
7
|
-
PosLoginIntent,
|
|
8
|
-
PosLoginSessionState,
|
|
9
|
-
PosLoginSessionStatus,
|
|
10
|
-
} from './lib/login/pos-login';
|
|
11
|
-
|
|
12
|
-
export { PosBasket } from './lib/basket/pos-basket';
|
|
13
|
-
export type {
|
|
14
|
-
PosBasketIntent,
|
|
15
|
-
PosBasketLine,
|
|
16
|
-
PosBasketTotals,
|
|
17
|
-
PosBasketVat,
|
|
18
|
-
} from './lib/basket/pos-basket';
|
|
19
|
-
|
|
20
|
-
export { PosItemEntry } from './lib/item-entry/pos-item-entry';
|
|
21
|
-
export type { PosItemEntryIntent } from './lib/item-entry/pos-item-entry';
|
|
22
|
-
|
|
23
|
-
export { PosTender } from './lib/tender/pos-tender';
|
|
24
|
-
export type { PosTenderIntent } from './lib/tender/pos-tender';
|
|
25
|
-
|
|
26
|
-
export { PosReceipt } from './lib/receipt/pos-receipt';
|
|
27
|
-
export type {
|
|
28
|
-
PosReceiptIntent,
|
|
29
|
-
PosReceiptLine,
|
|
30
|
-
PosReceiptTotals,
|
|
31
|
-
PosReceiptVat,
|
|
32
|
-
PosReceiptPayment,
|
|
33
|
-
PosReceiptDocument,
|
|
34
|
-
} from './lib/receipt/pos-receipt';
|
|
35
|
-
|
|
36
|
-
export { PosTokens } from './lib/tokens/pos-tokens';
|
|
37
|
-
export type { PosTokenSwatch } from './lib/tokens/pos-tokens';
|
package/tsconfig.lib.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
-
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
-
{
|
|
4
|
-
"extends": "../../tsconfig.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"rootDir": "./src",
|
|
7
|
-
"outDir": "../../out-tsc/lib",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationMap": true,
|
|
10
|
-
"types": []
|
|
11
|
-
},
|
|
12
|
-
"include": ["src/**/*.ts"],
|
|
13
|
-
"exclude": ["**/*.spec.ts", "**/*.stories.ts"]
|
|
14
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
-
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
-
{
|
|
4
|
-
"extends": "./tsconfig.lib.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"declarationMap": false
|
|
7
|
-
},
|
|
8
|
-
"angularCompilerOptions": {
|
|
9
|
-
"compilationMode": "partial"
|
|
10
|
-
}
|
|
11
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
-
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
-
{
|
|
4
|
-
"extends": "../../tsconfig.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"rootDir": "./src",
|
|
7
|
-
"outDir": "../../out-tsc/spec",
|
|
8
|
-
"types": ["vitest/globals"]
|
|
9
|
-
},
|
|
10
|
-
"include": ["src/**/*.d.ts", "src/**/*.spec.ts"]
|
|
11
|
-
}
|
|
File without changes
|
|
File without changes
|