@masterteam/components 0.0.262 → 0.0.264
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/assets/common.css +1 -1
- package/assets/i18n/ar.json +10 -2
- package/assets/i18n/en.json +10 -2
- package/fesm2022/masterteam-components-business-fields.mjs +13 -8
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-button.mjs +34 -4
- package/fesm2022/masterteam-components-button.mjs.map +1 -1
- package/fesm2022/masterteam-components-checkbox-field.mjs +8 -4
- package/fesm2022/masterteam-components-checkbox-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-client-page-menu.mjs +4 -3
- package/fesm2022/masterteam-components-client-page-menu.mjs.map +1 -1
- package/fesm2022/masterteam-components-client-page.mjs +48 -6
- package/fesm2022/masterteam-components-client-page.mjs.map +1 -1
- package/fesm2022/masterteam-components-color-picker-field.mjs +8 -4
- package/fesm2022/masterteam-components-color-picker-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-confirmation.mjs +1 -1
- package/fesm2022/masterteam-components-confirmation.mjs.map +1 -1
- package/fesm2022/masterteam-components-date-field.mjs +24 -5
- package/fesm2022/masterteam-components-date-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-drawer.mjs +1 -1
- package/fesm2022/masterteam-components-drawer.mjs.map +1 -1
- package/fesm2022/masterteam-components-dynamic-drawer.mjs +1 -1
- package/fesm2022/masterteam-components-dynamic-drawer.mjs.map +1 -1
- package/fesm2022/masterteam-components-editor-field.mjs +8 -4
- package/fesm2022/masterteam-components-editor-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-empty-state.mjs +53 -0
- package/fesm2022/masterteam-components-empty-state.mjs.map +1 -0
- package/fesm2022/masterteam-components-entities.mjs +187 -37
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components-field-validation.mjs +82 -3
- package/fesm2022/masterteam-components-field-validation.mjs.map +1 -1
- package/fesm2022/masterteam-components-icon-field.mjs +9 -12
- package/fesm2022/masterteam-components-icon-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-location-field.mjs +9 -5
- package/fesm2022/masterteam-components-location-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-module-summary-card.mjs +1 -1
- package/fesm2022/masterteam-components-module-summary-card.mjs.map +1 -1
- package/fesm2022/masterteam-components-multi-select-field.mjs +8 -4
- package/fesm2022/masterteam-components-multi-select-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-number-field.mjs +8 -4
- package/fesm2022/masterteam-components-number-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-page-header.mjs +2 -2
- package/fesm2022/masterteam-components-page-header.mjs.map +1 -1
- package/fesm2022/masterteam-components-pick-list-field.mjs +8 -4
- package/fesm2022/masterteam-components-pick-list-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-property-filter-builder.mjs +1 -1
- package/fesm2022/masterteam-components-property-filter-builder.mjs.map +1 -1
- package/fesm2022/masterteam-components-radio-button-field.mjs +1 -1
- package/fesm2022/masterteam-components-radio-button-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-radio-cards-field.mjs +8 -3
- package/fesm2022/masterteam-components-radio-cards-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-select-field.mjs +7 -3
- package/fesm2022/masterteam-components-select-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-slider-field.mjs +1 -1
- package/fesm2022/masterteam-components-slider-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-statistic-card.mjs +1 -1
- package/fesm2022/masterteam-components-statistic-card.mjs.map +1 -1
- package/fesm2022/masterteam-components-table.mjs +266 -65
- package/fesm2022/masterteam-components-table.mjs.map +1 -1
- package/fesm2022/masterteam-components-tabs.mjs +1 -1
- package/fesm2022/masterteam-components-tabs.mjs.map +1 -1
- package/fesm2022/masterteam-components-text-field.mjs +9 -5
- package/fesm2022/masterteam-components-text-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-textarea-field.mjs +8 -4
- package/fesm2022/masterteam-components-textarea-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-toggle-field.mjs +1 -1
- package/fesm2022/masterteam-components-toggle-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-tree.mjs +1 -1
- package/fesm2022/masterteam-components-tree.mjs.map +1 -1
- package/fesm2022/masterteam-components-treeselect-field.mjs +2 -2
- package/fesm2022/masterteam-components-treeselect-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-upload-field.mjs +9 -4
- package/fesm2022/masterteam-components-upload-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-uploader.mjs +28 -2
- package/fesm2022/masterteam-components-uploader.mjs.map +1 -1
- package/fesm2022/masterteam-components-user-search-field.mjs +8 -4
- package/fesm2022/masterteam-components-user-search-field.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +277 -36
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/package.json +5 -1
- package/types/masterteam-components-business-fields.d.ts +4 -0
- package/types/masterteam-components-button.d.ts +27 -1
- package/types/masterteam-components-checkbox-field.d.ts +4 -0
- package/types/masterteam-components-client-page.d.ts +7 -1
- package/types/masterteam-components-color-picker-field.d.ts +4 -0
- package/types/masterteam-components-date-field.d.ts +7 -1
- package/types/masterteam-components-editor-field.d.ts +4 -0
- package/types/masterteam-components-empty-state.d.ts +47 -0
- package/types/masterteam-components-entities.d.ts +80 -8
- package/types/masterteam-components-field-validation.d.ts +38 -2
- package/types/masterteam-components-icon-field.d.ts +4 -0
- package/types/masterteam-components-location-field.d.ts +4 -0
- package/types/masterteam-components-multi-select-field.d.ts +4 -0
- package/types/masterteam-components-number-field.d.ts +4 -0
- package/types/masterteam-components-pick-list-field.d.ts +4 -0
- package/types/masterteam-components-radio-cards-field.d.ts +4 -0
- package/types/masterteam-components-select-field.d.ts +4 -0
- package/types/masterteam-components-table.d.ts +123 -6
- package/types/masterteam-components-text-field.d.ts +4 -0
- package/types/masterteam-components-textarea-field.d.ts +4 -0
- package/types/masterteam-components-upload-field.d.ts +4 -0
- package/types/masterteam-components-user-search-field.d.ts +4 -0
- package/types/masterteam-components.d.ts +107 -2
|
@@ -160,6 +160,156 @@ function generateTailwindPalette(baseColorHex, baseColorShade = '500') {
|
|
|
160
160
|
return palette;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Color utility functions for brand display.
|
|
165
|
+
*/
|
|
166
|
+
/**
|
|
167
|
+
* Converts a hex color to a light shade (equivalent to primary-100 in Tailwind).
|
|
168
|
+
* This creates a color with ~10% opacity or a very light tint by mixing with white.
|
|
169
|
+
*/
|
|
170
|
+
function getLightColor(hexColor) {
|
|
171
|
+
const hex = hexColor.replace('#', '');
|
|
172
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
173
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
174
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
175
|
+
const lightR = Math.round(r * 0.1 + 255 * 0.9);
|
|
176
|
+
const lightG = Math.round(g * 0.1 + 255 * 0.9);
|
|
177
|
+
const lightB = Math.round(b * 0.1 + 255 * 0.9);
|
|
178
|
+
return `#${lightR.toString(16).padStart(2, '0')}${lightG
|
|
179
|
+
.toString(16)
|
|
180
|
+
.padStart(2, '0')}${lightB.toString(16).padStart(2, '0')}`;
|
|
181
|
+
}
|
|
182
|
+
function getContrastColor(bgColor) {
|
|
183
|
+
let r = 0, g = 0, b = 0;
|
|
184
|
+
if (bgColor.startsWith('#')) {
|
|
185
|
+
const hex = bgColor.slice(1);
|
|
186
|
+
if (hex.length === 3) {
|
|
187
|
+
r = parseInt(hex[0] + hex[0], 16);
|
|
188
|
+
g = parseInt(hex[1] + hex[1], 16);
|
|
189
|
+
b = parseInt(hex[2] + hex[2], 16);
|
|
190
|
+
}
|
|
191
|
+
else if (hex.length === 6) {
|
|
192
|
+
r = parseInt(hex.slice(0, 2), 16);
|
|
193
|
+
g = parseInt(hex.slice(2, 4), 16);
|
|
194
|
+
b = parseInt(hex.slice(4, 6), 16);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
198
|
+
return luminance > 0.5 ? '' : '#ffffff';
|
|
199
|
+
}
|
|
200
|
+
/** Parses `#rgb` / `#rrggbb` into 0-255 channels. Null when unparseable. */
|
|
201
|
+
function toRgb(hex) {
|
|
202
|
+
const value = hex.trim().replace('#', '');
|
|
203
|
+
const full = value.length === 3
|
|
204
|
+
? value
|
|
205
|
+
.split('')
|
|
206
|
+
.map((c) => c + c)
|
|
207
|
+
.join('')
|
|
208
|
+
: value;
|
|
209
|
+
if (full.length !== 6 || !/^[0-9a-f]{6}$/i.test(full)) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
return [
|
|
213
|
+
parseInt(full.slice(0, 2), 16),
|
|
214
|
+
parseInt(full.slice(2, 4), 16),
|
|
215
|
+
parseInt(full.slice(4, 6), 16),
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* WCAG 2.x relative luminance.
|
|
220
|
+
*
|
|
221
|
+
* Note this is NOT the 0.299/0.587/0.114 perceived-brightness formula used by
|
|
222
|
+
* `getContrastColor` above — that one is fine for "is this light or dark?" but
|
|
223
|
+
* it is not the definition a conformance ratio is measured against, so it
|
|
224
|
+
* cannot be used to decide whether text passes AA.
|
|
225
|
+
*/
|
|
226
|
+
function relativeLuminance(hex) {
|
|
227
|
+
const rgb = toRgb(hex);
|
|
228
|
+
if (!rgb) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
const [r, g, b] = rgb.map((channel) => {
|
|
232
|
+
const c = channel / 255;
|
|
233
|
+
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
234
|
+
});
|
|
235
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
236
|
+
}
|
|
237
|
+
/** WCAG contrast ratio between two hex colours, 1–21. Null if either is bad. */
|
|
238
|
+
function contrastRatio(foreground, background) {
|
|
239
|
+
const l1 = relativeLuminance(foreground);
|
|
240
|
+
const l2 = relativeLuminance(background);
|
|
241
|
+
if (l1 === null || l2 === null) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
245
|
+
}
|
|
246
|
+
/** WCAG 1.4.3 Contrast Minimum, normal-size text. */
|
|
247
|
+
const WCAG_AA_NORMAL_TEXT = 4.5;
|
|
248
|
+
/**
|
|
249
|
+
* The first shade at or below `preferred` on a generated ramp whose contrast
|
|
250
|
+
* against `foreground` clears `minRatio`.
|
|
251
|
+
*
|
|
252
|
+
* This is how the brand colour stays fully tenant-configurable while the
|
|
253
|
+
* primary button still passes AA (finding H-03). The shipped default
|
|
254
|
+
* `#2AAEC0` gives white text 2.65:1 — the single most important control in the
|
|
255
|
+
* product was the least legible one, and any tenant picking a light brand hit
|
|
256
|
+
* the same wall. Rather than hardcode a darker teal, which fixes exactly one
|
|
257
|
+
* tenant, we keep their hue and step down the ramp their own colour generated
|
|
258
|
+
* until the text is readable.
|
|
259
|
+
*
|
|
260
|
+
* Returns `preferred` unchanged when it already passes, so a tenant whose brand
|
|
261
|
+
* is dark enough sees no change at all. Returns the darkest available shade if
|
|
262
|
+
* none passes — better to be as close as the palette allows than to give up.
|
|
263
|
+
*/
|
|
264
|
+
function pickAccessibleShade(palette, preferred, foreground = '#ffffff', minRatio = WCAG_AA_NORMAL_TEXT) {
|
|
265
|
+
const ladder = ['500', '600', '700', '800', '900'];
|
|
266
|
+
const startIndex = ladder.indexOf(preferred);
|
|
267
|
+
const candidates = startIndex >= 0 ? ladder.slice(startIndex) : ladder;
|
|
268
|
+
let darkestAvailable = null;
|
|
269
|
+
for (const step of candidates) {
|
|
270
|
+
const shade = palette[step];
|
|
271
|
+
if (!shade) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
darkestAvailable = step;
|
|
275
|
+
const ratio = contrastRatio(foreground, shade);
|
|
276
|
+
if (ratio !== null && ratio >= minRatio) {
|
|
277
|
+
return step;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Nothing on the ramp clears the threshold — return the darkest step the
|
|
281
|
+
// palette actually has rather than one we already know fails. Falls back to
|
|
282
|
+
// `preferred` only when the palette carried none of the ladder steps at all.
|
|
283
|
+
return darkestAvailable ?? preferred;
|
|
284
|
+
}
|
|
285
|
+
/** Dark ink used when white text would not be legible on a status colour. */
|
|
286
|
+
const READABLE_DARK_INK = '#1f2937';
|
|
287
|
+
/**
|
|
288
|
+
* Picks the more legible of white and a dark ink for text sitting on `bgColor`.
|
|
289
|
+
*
|
|
290
|
+
* Status and lookup colours come from a tenant's own catalog, so they can be
|
|
291
|
+
* any hex at all — and the count badges on the Explore cards were painting
|
|
292
|
+
* white on every one of them, which measured 2.59:1 at the low end (finding
|
|
293
|
+
* H-03 / M-04). Rather than restrict what colours a tenant may choose, pick the
|
|
294
|
+
* foreground that actually reads on the colour they chose.
|
|
295
|
+
*
|
|
296
|
+
* Measured with the WCAG relative-luminance ratio, not the perceived-brightness
|
|
297
|
+
* shortcut in `getContrastColor`, because that shortcut is not the definition
|
|
298
|
+
* conformance is judged against. Unparseable input falls back to white, which
|
|
299
|
+
* is the behaviour every caller had before.
|
|
300
|
+
*/
|
|
301
|
+
function readableTextOn(bgColor, dark = READABLE_DARK_INK, light = '#ffffff') {
|
|
302
|
+
if (!bgColor) {
|
|
303
|
+
return light;
|
|
304
|
+
}
|
|
305
|
+
const onLight = contrastRatio(light, bgColor);
|
|
306
|
+
const onDark = contrastRatio(dark, bgColor);
|
|
307
|
+
if (onLight === null || onDark === null) {
|
|
308
|
+
return light;
|
|
309
|
+
}
|
|
310
|
+
return onDark > onLight ? dark : light;
|
|
311
|
+
}
|
|
312
|
+
|
|
163
313
|
/**
|
|
164
314
|
* Masterteam Design System — raw palettes and scales.
|
|
165
315
|
*
|
|
@@ -853,8 +1003,29 @@ function changeTextColor(color) {
|
|
|
853
1003
|
},
|
|
854
1004
|
});
|
|
855
1005
|
}
|
|
1006
|
+
/**
|
|
1007
|
+
* The palette step a filled primary control should use so white text on it
|
|
1008
|
+
* clears WCAG AA (4.5:1).
|
|
1009
|
+
*
|
|
1010
|
+
* Kept as a named helper because it is the whole of finding H-03: the shipped
|
|
1011
|
+
* default `#2AAEC0` gives white text 2.65:1, so Add / New / Filter / Apply /
|
|
1012
|
+
* Submit — the controls that most need to be legible — were the least legible
|
|
1013
|
+
* in the product, and every tenant who configured a light brand colour hit the
|
|
1014
|
+
* same wall. Darkening the shipped hex would have fixed exactly one tenant and
|
|
1015
|
+
* changed the product's colour; this keeps the hue and moves one step down the
|
|
1016
|
+
* ramp their own colour already generated. A brand that passes at 500 stays at
|
|
1017
|
+
* 500 and looks identical.
|
|
1018
|
+
*/
|
|
1019
|
+
function accessiblePrimaryShade(palette) {
|
|
1020
|
+
return pickAccessibleShade(palette, '500', '#ffffff', WCAG_AA_NORMAL_TEXT);
|
|
1021
|
+
}
|
|
856
1022
|
const MTPreset = (themeOptions) => {
|
|
857
1023
|
const textPalette = generateTailwindPalette(themeOptions?.textColor ?? '#334155', '700');
|
|
1024
|
+
const primaryPalette = generateTailwindPalette(themeOptions?.primaryColor || '#2AAEC0');
|
|
1025
|
+
// Which shade filled controls use. See `accessiblePrimaryShade` — the tenant's
|
|
1026
|
+
// hue is untouched; only the step on their own ramp moves, and only when white
|
|
1027
|
+
// text would otherwise fail WCAG AA (finding H-03).
|
|
1028
|
+
const primaryActionShade = accessiblePrimaryShade(primaryPalette);
|
|
858
1029
|
const configs = {
|
|
859
1030
|
options: {
|
|
860
1031
|
prefix: 'mt',
|
|
@@ -866,6 +1037,16 @@ const MTPreset = (themeOptions) => {
|
|
|
866
1037
|
semantic: {
|
|
867
1038
|
colorScheme: {
|
|
868
1039
|
light: {
|
|
1040
|
+
// Filled primary surfaces resolve to the first shade whose contrast
|
|
1041
|
+
// with white text passes AA — usually 500, deeper only when the
|
|
1042
|
+
// tenant's brand is too light. Borders/icons keep reading `primary.500`
|
|
1043
|
+
// directly, so the brand accent itself is unchanged.
|
|
1044
|
+
primary: {
|
|
1045
|
+
color: `{primary.${primaryActionShade}}`,
|
|
1046
|
+
contrastColor: '#ffffff',
|
|
1047
|
+
hoverColor: `{primary.${primaryActionShade}}`,
|
|
1048
|
+
activeColor: `{primary.${primaryActionShade}}`,
|
|
1049
|
+
},
|
|
869
1050
|
text: {
|
|
870
1051
|
color: textPalette['700'],
|
|
871
1052
|
hoverColor: textPalette['800'],
|
|
@@ -882,7 +1063,7 @@ const MTPreset = (themeOptions) => {
|
|
|
882
1063
|
},
|
|
883
1064
|
},
|
|
884
1065
|
},
|
|
885
|
-
primary:
|
|
1066
|
+
primary: primaryPalette,
|
|
886
1067
|
content: {
|
|
887
1068
|
borderRadius: '{border.radius.lg}',
|
|
888
1069
|
},
|
|
@@ -2175,41 +2356,84 @@ function isInvalid(control) {
|
|
|
2175
2356
|
const REQUEST_CONTEXT = new HttpContextToken(() => ({ useBaseUrl: false }));
|
|
2176
2357
|
|
|
2177
2358
|
/**
|
|
2178
|
-
*
|
|
2359
|
+
* Stable DOM ids for form fields.
|
|
2360
|
+
*
|
|
2361
|
+
* Every field component used to bind `[id]="ngControl?.name || label()"`. Used
|
|
2362
|
+
* inside a reactive form that resolves, but a stand-alone field with no control
|
|
2363
|
+
* and no label produced `id="undefined"` — literally, because Angular
|
|
2364
|
+
* stringifies. The global search input was exactly that case, which is why it
|
|
2365
|
+
* also had no associated `<label>` and reported as unlabelled in the
|
|
2366
|
+
* accessibility tree (findings L-03 and H-04).
|
|
2367
|
+
*
|
|
2368
|
+
* `slider-field` already solved this locally; this is that solution extracted so
|
|
2369
|
+
* the six components that got it wrong share one implementation instead of six
|
|
2370
|
+
* near-copies.
|
|
2179
2371
|
*/
|
|
2372
|
+
let nextUniqueId = 0;
|
|
2373
|
+
/** A process-unique fallback id, e.g. `mt-text-field-3`. */
|
|
2374
|
+
function nextFieldId(prefix) {
|
|
2375
|
+
return `${prefix}-${nextUniqueId++}`;
|
|
2376
|
+
}
|
|
2180
2377
|
/**
|
|
2181
|
-
*
|
|
2182
|
-
*
|
|
2378
|
+
* The id a field should render, in preference order: the reactive form control
|
|
2379
|
+
* name, then a slug of the visible label, then the generated fallback.
|
|
2380
|
+
*
|
|
2381
|
+
* Never returns an empty string or `"undefined"` — a label/input pair is only
|
|
2382
|
+
* associated if the id is real, so the fallback matters more than it looks.
|
|
2183
2383
|
*/
|
|
2184
|
-
function
|
|
2185
|
-
const
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
|
2189
|
-
const lightR = Math.round(r * 0.1 + 255 * 0.9);
|
|
2190
|
-
const lightG = Math.round(g * 0.1 + 255 * 0.9);
|
|
2191
|
-
const lightB = Math.round(b * 0.1 + 255 * 0.9);
|
|
2192
|
-
return `#${lightR.toString(16).padStart(2, '0')}${lightG
|
|
2193
|
-
.toString(16)
|
|
2194
|
-
.padStart(2, '0')}${lightB.toString(16).padStart(2, '0')}`;
|
|
2195
|
-
}
|
|
2196
|
-
function getContrastColor(bgColor) {
|
|
2197
|
-
let r = 0, g = 0, b = 0;
|
|
2198
|
-
if (bgColor.startsWith('#')) {
|
|
2199
|
-
const hex = bgColor.slice(1);
|
|
2200
|
-
if (hex.length === 3) {
|
|
2201
|
-
r = parseInt(hex[0] + hex[0], 16);
|
|
2202
|
-
g = parseInt(hex[1] + hex[1], 16);
|
|
2203
|
-
b = parseInt(hex[2] + hex[2], 16);
|
|
2204
|
-
}
|
|
2205
|
-
else if (hex.length === 6) {
|
|
2206
|
-
r = parseInt(hex.slice(0, 2), 16);
|
|
2207
|
-
g = parseInt(hex.slice(2, 4), 16);
|
|
2208
|
-
b = parseInt(hex.slice(4, 6), 16);
|
|
2209
|
-
}
|
|
2384
|
+
function resolveFieldId(controlName, label, fallbackId) {
|
|
2385
|
+
const name = controlName?.toString().trim();
|
|
2386
|
+
if (name) {
|
|
2387
|
+
return name;
|
|
2210
2388
|
}
|
|
2211
|
-
const
|
|
2212
|
-
return
|
|
2389
|
+
const slug = label?.trim().toLowerCase().replace(/\s+/g, '-');
|
|
2390
|
+
return slug || fallbackId;
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
/**
|
|
2394
|
+
* Helpers for wall-clock values — the `HH:mm:ss` shape a `Time` property
|
|
2395
|
+
* stores. A time of day carries no calendar date and no timezone, so it is
|
|
2396
|
+
* never serialized as an instant: `new Date('09:30:00')` is `Invalid Date`,
|
|
2397
|
+
* and pushing the clock through UTC would shift it by the viewer's offset.
|
|
2398
|
+
*/
|
|
2399
|
+
const CLOCK_TIME_PATTERN = /^(\d{1,2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?$/;
|
|
2400
|
+
/**
|
|
2401
|
+
* Parse a bare `H:mm`, `HH:mm`, or `HH:mm:ss` string — a trailing fractional
|
|
2402
|
+
* second, as .NET `TimeOnly`/`TimeSpan` may emit, is ignored. Returns `null`
|
|
2403
|
+
* for anything else, including full timestamps, which callers parse as dates.
|
|
2404
|
+
*/
|
|
2405
|
+
function parseClockTime(value) {
|
|
2406
|
+
if (typeof value !== 'string')
|
|
2407
|
+
return null;
|
|
2408
|
+
const match = CLOCK_TIME_PATTERN.exec(value.trim());
|
|
2409
|
+
if (!match)
|
|
2410
|
+
return null;
|
|
2411
|
+
const hours = Number(match[1]);
|
|
2412
|
+
const minutes = Number(match[2]);
|
|
2413
|
+
const seconds = match[3] ? Number(match[3]) : 0;
|
|
2414
|
+
if (hours > 23 || minutes > 59 || seconds > 59)
|
|
2415
|
+
return null;
|
|
2416
|
+
return { hours, minutes, seconds };
|
|
2417
|
+
}
|
|
2418
|
+
/** Read the local wall-clock time off a `Date`, or `null` for an invalid one. */
|
|
2419
|
+
function toClockTimeParts(date) {
|
|
2420
|
+
if (Number.isNaN(date.getTime()))
|
|
2421
|
+
return null;
|
|
2422
|
+
return {
|
|
2423
|
+
hours: date.getHours(),
|
|
2424
|
+
minutes: date.getMinutes(),
|
|
2425
|
+
seconds: date.getSeconds(),
|
|
2426
|
+
};
|
|
2427
|
+
}
|
|
2428
|
+
/** Format a wall-clock time as the `HH:mm:ss` text the backend stores. */
|
|
2429
|
+
function formatClockTime(parts) {
|
|
2430
|
+
return [parts.hours, parts.minutes, parts.seconds]
|
|
2431
|
+
.map((part) => part.toString().padStart(2, '0'))
|
|
2432
|
+
.join(':');
|
|
2433
|
+
}
|
|
2434
|
+
/** Seconds since midnight — the comparable form of a wall-clock time. */
|
|
2435
|
+
function clockTimeToSeconds(parts) {
|
|
2436
|
+
return parts.hours * 3600 + parts.minutes * 60 + parts.seconds;
|
|
2213
2437
|
}
|
|
2214
2438
|
|
|
2215
2439
|
class MTDateFormatPipe {
|
|
@@ -2220,10 +2444,14 @@ class MTDateFormatPipe {
|
|
|
2220
2444
|
return '';
|
|
2221
2445
|
}
|
|
2222
2446
|
try {
|
|
2223
|
-
|
|
2447
|
+
// A calendar date and a wall clock both carry no timezone of their own,
|
|
2448
|
+
// so they are pinned to `+0000` and rendered exactly as stored.
|
|
2449
|
+
const zonelessValue = type === 'date' && typeof value === 'string'
|
|
2224
2450
|
? parseDateOnlyValue(value)
|
|
2225
|
-
:
|
|
2226
|
-
|
|
2451
|
+
: type === 'time'
|
|
2452
|
+
? parseClockOnlyValue(value)
|
|
2453
|
+
: null;
|
|
2454
|
+
return formatDate(zonelessValue ?? value, toAngularDateFormat(this.formats[type] ?? this.formats.date), this.locale, zonelessValue ? '+0000' : this.formats.timezone);
|
|
2227
2455
|
}
|
|
2228
2456
|
catch {
|
|
2229
2457
|
return String(value);
|
|
@@ -2239,6 +2467,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
2239
2467
|
standalone: true,
|
|
2240
2468
|
}]
|
|
2241
2469
|
}] });
|
|
2470
|
+
/**
|
|
2471
|
+
* Keep a wall-clock time (`HH:mm:ss`, the shape a `Time` property stores)
|
|
2472
|
+
* independent from both browser and configured zones. Values still stored as a
|
|
2473
|
+
* full instant fall through to the normal timezone-aware path.
|
|
2474
|
+
*/
|
|
2475
|
+
function parseClockOnlyValue(value) {
|
|
2476
|
+
const clockTime = parseClockTime(value);
|
|
2477
|
+
if (!clockTime)
|
|
2478
|
+
return null;
|
|
2479
|
+
const parsed = new Date(0);
|
|
2480
|
+
parsed.setUTCHours(clockTime.hours, clockTime.minutes, clockTime.seconds, 0);
|
|
2481
|
+
return parsed;
|
|
2482
|
+
}
|
|
2242
2483
|
/** Keep a calendar date independent from both browser and configured zones. */
|
|
2243
2484
|
function parseDateOnlyValue(value) {
|
|
2244
2485
|
const match = /^(\d{4})-(\d{2})-(\d{2})(?=$|T)/.exec(value);
|
|
@@ -2267,5 +2508,5 @@ function parseDateOnlyValue(value) {
|
|
|
2267
2508
|
* Generated bundle index. Do not edit.
|
|
2268
2509
|
*/
|
|
2269
2510
|
|
|
2270
|
-
export { BaseFacade, BaseFieldConfig, CheckboxFieldConfig, ColorPickerFieldConfig, CrudStateBase, DEFAULT_MT_DATE_FORMATS, DS_BLUE, DS_CHART_SERIES, DS_CONTROL_HEIGHT, DS_DEFAULT_PRIMARY_COLOR, DS_ERROR, DS_FONT_FAMILY, DS_GRAY, DS_INDIGO, DS_RADIUS, DS_SEMANTIC, DS_SHADOW, DS_SUCCESS, DS_WARNING, DateFieldConfig, EditorFieldConfig, EntityListFieldConfig, IconFieldConfig, LocationFieldConfig, LookupMatrixFieldConfig, LookupModuleCheckListFieldConfig, MTDateFormatPipe, MT_DATE_FORMATS, MT_DESIGN_IDENTITY_CLASS, MultiSelectFieldConfig, NumberFieldConfig, PickListFieldConfig, REQUEST_CONTEXT, RadioButtonFieldConfig, RadioCardsFieldConfig, ScheduleItemSelectorFieldConfig, SchedulePredecessorFieldConfig, SchemaConnectionFieldConfig, SelectFieldConfig, SliderFieldConfig, SpacerFieldConfig, TextFieldConfig, TextareaFieldConfig, ToggleFieldConfig, UploadFileFieldConfig, UserSearchFieldConfig, ValidatorConfig, applyDesignIdentityClass, changeBackgroundColor, changePrimaryColor, changeTextColor, createCustomValidator, createEntityAdapter, dsChartSeries, dsIdentityConfigs, endLoading, generateTailwindPalette, getContrastColor, getLightColor, getMTDesignIdentity, handleApiRequest, isInvalid, provideMTComponents, provideMTConfirmation, provideMTDateFormats, provideMTMessages, setLoadingError, setMTDesignIdentity, startLoading, toAngularDateFormat, wrapValidatorWithMessage };
|
|
2511
|
+
export { BaseFacade, BaseFieldConfig, CheckboxFieldConfig, ColorPickerFieldConfig, CrudStateBase, DEFAULT_MT_DATE_FORMATS, DS_BLUE, DS_CHART_SERIES, DS_CONTROL_HEIGHT, DS_DEFAULT_PRIMARY_COLOR, DS_ERROR, DS_FONT_FAMILY, DS_GRAY, DS_INDIGO, DS_RADIUS, DS_SEMANTIC, DS_SHADOW, DS_SUCCESS, DS_WARNING, DateFieldConfig, EditorFieldConfig, EntityListFieldConfig, IconFieldConfig, LocationFieldConfig, LookupMatrixFieldConfig, LookupModuleCheckListFieldConfig, MTDateFormatPipe, MT_DATE_FORMATS, MT_DESIGN_IDENTITY_CLASS, MultiSelectFieldConfig, NumberFieldConfig, PickListFieldConfig, READABLE_DARK_INK, REQUEST_CONTEXT, RadioButtonFieldConfig, RadioCardsFieldConfig, ScheduleItemSelectorFieldConfig, SchedulePredecessorFieldConfig, SchemaConnectionFieldConfig, SelectFieldConfig, SliderFieldConfig, SpacerFieldConfig, TextFieldConfig, TextareaFieldConfig, ToggleFieldConfig, UploadFileFieldConfig, UserSearchFieldConfig, ValidatorConfig, WCAG_AA_NORMAL_TEXT, applyDesignIdentityClass, changeBackgroundColor, changePrimaryColor, changeTextColor, clockTimeToSeconds, contrastRatio, createCustomValidator, createEntityAdapter, dsChartSeries, dsIdentityConfigs, endLoading, formatClockTime, generateTailwindPalette, getContrastColor, getLightColor, getMTDesignIdentity, handleApiRequest, isInvalid, nextFieldId, parseClockTime, pickAccessibleShade, provideMTComponents, provideMTConfirmation, provideMTDateFormats, provideMTMessages, readableTextOn, relativeLuminance, resolveFieldId, setLoadingError, setMTDesignIdentity, startLoading, toAngularDateFormat, toClockTimeParts, wrapValidatorWithMessage };
|
|
2271
2512
|
//# sourceMappingURL=masterteam-components.mjs.map
|