@masterteam/components 0.0.45 → 0.0.47
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 +2 -2
- package/fesm2022/masterteam-components-upload-field.mjs +12 -2
- package/fesm2022/masterteam-components-upload-field.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +241 -170
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/index.d.ts +19 -4
- package/package.json +54 -54
- package/upload-field/index.d.ts +4 -2
|
@@ -73,71 +73,86 @@ function hslToHex(h, s, l) {
|
|
|
73
73
|
return `#${f(0)}${f(8)}${f(4)}`;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* Defines the "ideal" lightness and saturation adjustment for each shade.
|
|
77
|
+
* Lightness for 500 is set to 50 as a balanced default.
|
|
78
|
+
*/
|
|
79
|
+
const PALETTE_PROFILE = {
|
|
80
|
+
'0': { l: 98, s_adjust: -50 },
|
|
81
|
+
'50': { l: 95, s_adjust: -40 },
|
|
82
|
+
'100': { l: 90, s_adjust: -30 },
|
|
83
|
+
'200': { l: 80, s_adjust: -20 },
|
|
84
|
+
'300': { l: 70, s_adjust: -10 },
|
|
85
|
+
'400': { l: 60, s_adjust: -5 },
|
|
86
|
+
'500': { l: 50, s_adjust: 0 },
|
|
87
|
+
'600': { l: 45, s_adjust: 5 },
|
|
88
|
+
'700': { l: 35, s_adjust: 10 },
|
|
89
|
+
'800': { l: 25, s_adjust: 15 },
|
|
90
|
+
'900': { l: 15, s_adjust: 20 },
|
|
91
|
+
'950': { l: 8, s_adjust: 25 },
|
|
92
|
+
};
|
|
93
|
+
// Helper to ensure palette is always in the correct 50-950 order
|
|
94
|
+
const ALL_SHADES = [
|
|
95
|
+
'0',
|
|
96
|
+
'50',
|
|
97
|
+
'100',
|
|
98
|
+
'200',
|
|
99
|
+
'300',
|
|
100
|
+
'400',
|
|
101
|
+
'500',
|
|
102
|
+
'600',
|
|
103
|
+
'700',
|
|
104
|
+
'800',
|
|
105
|
+
'900',
|
|
106
|
+
'950',
|
|
107
|
+
];
|
|
108
|
+
/**
|
|
109
|
+
* Clamps a number between a min and max value.
|
|
110
|
+
*/
|
|
111
|
+
function clamp(value, min, max) {
|
|
112
|
+
return Math.max(min, Math.min(max, value));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Generates a Tailwind-like color palette (50-950) from any given base color.
|
|
77
116
|
*
|
|
78
|
-
* @param
|
|
79
|
-
* @
|
|
80
|
-
*
|
|
117
|
+
* @param baseColorHex - The hex string of the base color (e.g., "#0284c7").
|
|
118
|
+
* @param baseColorShade - The shade of the base color (e.g., "500", "700").
|
|
119
|
+
* @returns An object representing the full color palette.
|
|
81
120
|
*/
|
|
82
|
-
function generateTailwindPalette(
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
const saturationIncreasesDarker = {
|
|
119
|
-
'600': 5,
|
|
120
|
-
'700': 10,
|
|
121
|
-
'800': 15,
|
|
122
|
-
'900': 20,
|
|
123
|
-
'950': 25, // Can increase saturation for darker shades
|
|
124
|
-
};
|
|
125
|
-
for (const shade in lightnessStepsDarker) {
|
|
126
|
-
if (Object.prototype.hasOwnProperty.call(lightnessStepsDarker, shade)) {
|
|
127
|
-
const newL = lightnessStepsDarker[shade];
|
|
128
|
-
// Ensure saturation doesn't exceed 100
|
|
129
|
-
const newS = Math.min(100, s + saturationIncreasesDarker[shade]);
|
|
130
|
-
palette[shade] = hslToHex(h, newS, newL);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// Sort the keys numerically to ensure consistent order
|
|
134
|
-
const sortedPalette = {};
|
|
135
|
-
Object.keys(palette)
|
|
136
|
-
.sort((a, b) => parseInt(a) - parseInt(b))
|
|
137
|
-
.forEach((key) => {
|
|
138
|
-
sortedPalette[key] = palette[key];
|
|
139
|
-
});
|
|
140
|
-
return sortedPalette;
|
|
121
|
+
function generateTailwindPalette(baseColorHex, baseColorShade = '500') {
|
|
122
|
+
// 1. Get HSL of the input color
|
|
123
|
+
const [h_base, s_base, l_base] = hexToHsl(baseColorHex);
|
|
124
|
+
// 2. Find the anchors
|
|
125
|
+
const baseProfile = PALETTE_PROFILE[baseColorShade];
|
|
126
|
+
/** The Hue is constant across the entire palette. */
|
|
127
|
+
const h = h_base;
|
|
128
|
+
/**
|
|
129
|
+
* Calculate the 500-shade's saturation by "reversing" the adjustment
|
|
130
|
+
* from the base color.
|
|
131
|
+
* e.g., if base is 700 (s_adjust: +10) and s_base is 80,
|
|
132
|
+
* s_500 will be 70.
|
|
133
|
+
*/
|
|
134
|
+
const s_500 = clamp(s_base - baseProfile.s_adjust, 0, 100);
|
|
135
|
+
/**
|
|
136
|
+
* Calculate the lightness "offset". This is the difference between
|
|
137
|
+
* the base color's actual lightness and its "ideal" lightness
|
|
138
|
+
* from the profile.
|
|
139
|
+
* e.g., if base is 700 (ideal L: 35) and l_base is 38,
|
|
140
|
+
* the offset is +3. This offset will be applied to all shades.
|
|
141
|
+
*/
|
|
142
|
+
const l_offset = l_base - baseProfile.l;
|
|
143
|
+
// 3. Generate the full palette
|
|
144
|
+
const palette = {};
|
|
145
|
+
for (const shade of ALL_SHADES) {
|
|
146
|
+
const profile = PALETTE_PROFILE[shade];
|
|
147
|
+
// Calculate the new saturation and lightness for this shade
|
|
148
|
+
const newS = clamp(s_500 + profile.s_adjust, 0, 100);
|
|
149
|
+
const newL = clamp(profile.l + l_offset, 0, 100);
|
|
150
|
+
palette[shade] = hslToHex(h, newS, newL);
|
|
151
|
+
}
|
|
152
|
+
// 4. Ensure the originally provided color is used exactly
|
|
153
|
+
// (to avoid rounding errors from HSL conversion)
|
|
154
|
+
palette[baseColorShade] = baseColorHex;
|
|
155
|
+
return palette;
|
|
141
156
|
}
|
|
142
157
|
|
|
143
158
|
const toastStyle = {
|
|
@@ -158,111 +173,164 @@ function changePrimaryColor(color) {
|
|
|
158
173
|
},
|
|
159
174
|
});
|
|
160
175
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
formField: {
|
|
175
|
-
borderRadius: '{border.radius.lg}',
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
components: {
|
|
179
|
-
dialog: {
|
|
180
|
-
header: {
|
|
181
|
-
padding: '0',
|
|
182
|
-
},
|
|
183
|
-
content: {
|
|
184
|
-
padding: '0',
|
|
185
|
-
},
|
|
186
|
-
footer: {
|
|
187
|
-
padding: '0',
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
toast: {
|
|
191
|
-
root: {
|
|
192
|
-
borderRadius: '{border.radius.xl}',
|
|
193
|
-
},
|
|
176
|
+
function changeBackgroundColor(color) {
|
|
177
|
+
if (color) {
|
|
178
|
+
const palette = generateTailwindPalette(color, '100');
|
|
179
|
+
console.log('the background palette', palette);
|
|
180
|
+
document.documentElement.style.setProperty('--app-background-light', palette['100']);
|
|
181
|
+
document.documentElement.style.setProperty('--app-background-dark', palette['950']);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function changeTextColor(color) {
|
|
185
|
+
const palette = generateTailwindPalette(color ?? '#334155', '700');
|
|
186
|
+
updatePreset({
|
|
187
|
+
semantic: {
|
|
194
188
|
colorScheme: {
|
|
195
189
|
light: {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
190
|
+
text: {
|
|
191
|
+
color: palette['700'],
|
|
192
|
+
hoverColor: palette['800'],
|
|
193
|
+
hoverMutedColor: palette['600'],
|
|
194
|
+
mutedColor: palette['500'],
|
|
195
|
+
},
|
|
201
196
|
},
|
|
202
197
|
dark: {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
198
|
+
text: {
|
|
199
|
+
color: palette['0'],
|
|
200
|
+
hoverColor: palette['0'],
|
|
201
|
+
hoverMutedColor: palette['300'],
|
|
202
|
+
mutedColor: palette['400'],
|
|
203
|
+
},
|
|
208
204
|
},
|
|
209
205
|
},
|
|
210
206
|
},
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const MTPreset = (themeOptions) => {
|
|
210
|
+
const textPalette = generateTailwindPalette(themeOptions?.textColor ?? '#334155', '700');
|
|
211
|
+
const configs = {
|
|
212
|
+
options: {
|
|
213
|
+
prefix: 'mt',
|
|
214
|
+
cssLayer: {
|
|
215
|
+
name: 'primeng',
|
|
216
|
+
order: 'theme, base, primeng',
|
|
214
217
|
},
|
|
218
|
+
},
|
|
219
|
+
semantic: {
|
|
215
220
|
colorScheme: {
|
|
216
221
|
light: {
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
text: {
|
|
223
|
+
color: textPalette['700'],
|
|
224
|
+
hoverColor: textPalette['800'],
|
|
225
|
+
hoverMutedColor: textPalette['600'],
|
|
226
|
+
mutedColor: textPalette['500'],
|
|
219
227
|
},
|
|
220
228
|
},
|
|
221
229
|
dark: {
|
|
222
|
-
|
|
223
|
-
|
|
230
|
+
text: {
|
|
231
|
+
color: textPalette['0'],
|
|
232
|
+
hoverColor: textPalette['0'],
|
|
233
|
+
hoverMutedColor: textPalette['300'],
|
|
234
|
+
mutedColor: textPalette['400'],
|
|
224
235
|
},
|
|
225
236
|
},
|
|
226
237
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
root: {
|
|
238
|
+
primary: generateTailwindPalette(themeOptions?.primaryColor || '#334dff'),
|
|
239
|
+
content: {
|
|
230
240
|
borderRadius: '{border.radius.lg}',
|
|
231
241
|
},
|
|
232
|
-
|
|
233
|
-
paginator: {
|
|
234
|
-
root: {
|
|
242
|
+
formField: {
|
|
235
243
|
borderRadius: '{border.radius.lg}',
|
|
236
|
-
padding: '0 .5rem',
|
|
237
244
|
},
|
|
238
|
-
|
|
239
|
-
|
|
245
|
+
},
|
|
246
|
+
components: {
|
|
247
|
+
dialog: {
|
|
248
|
+
header: {
|
|
249
|
+
padding: '0',
|
|
250
|
+
},
|
|
251
|
+
content: {
|
|
252
|
+
padding: '0',
|
|
253
|
+
},
|
|
254
|
+
footer: {
|
|
255
|
+
padding: '0',
|
|
256
|
+
},
|
|
240
257
|
},
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
258
|
+
toast: {
|
|
259
|
+
root: {
|
|
260
|
+
borderRadius: '{border.radius.xl}',
|
|
261
|
+
},
|
|
262
|
+
colorScheme: {
|
|
263
|
+
light: {
|
|
264
|
+
success: toastStyle,
|
|
265
|
+
info: toastStyle,
|
|
266
|
+
warn: toastStyle,
|
|
267
|
+
error: toastStyle,
|
|
268
|
+
secondary: toastStyle,
|
|
269
|
+
},
|
|
270
|
+
dark: {
|
|
271
|
+
success: toastStyle,
|
|
272
|
+
info: toastStyle,
|
|
273
|
+
warn: toastStyle,
|
|
274
|
+
error: toastStyle,
|
|
275
|
+
secondary: toastStyle,
|
|
251
276
|
},
|
|
252
277
|
},
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
278
|
+
},
|
|
279
|
+
togglebutton: {
|
|
280
|
+
root: {
|
|
281
|
+
padding: '1px',
|
|
282
|
+
},
|
|
283
|
+
colorScheme: {
|
|
284
|
+
light: {
|
|
285
|
+
root: {
|
|
286
|
+
checkedColor: '{primary.500}',
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
dark: {
|
|
290
|
+
root: {
|
|
291
|
+
checkedColor: '{primary.400}',
|
|
261
292
|
},
|
|
262
293
|
},
|
|
263
294
|
},
|
|
264
295
|
},
|
|
265
|
-
|
|
296
|
+
selectbutton: {
|
|
297
|
+
root: {
|
|
298
|
+
borderRadius: '{border.radius.lg}',
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
paginator: {
|
|
302
|
+
root: {
|
|
303
|
+
borderRadius: '{border.radius.lg}',
|
|
304
|
+
padding: '0 .5rem',
|
|
305
|
+
},
|
|
306
|
+
navButton: {
|
|
307
|
+
borderRadius: '0',
|
|
308
|
+
},
|
|
309
|
+
colorScheme: {
|
|
310
|
+
light: {
|
|
311
|
+
navButton: {
|
|
312
|
+
color: '{surface.600}',
|
|
313
|
+
hoverBackground: '#fff',
|
|
314
|
+
selectedBackground: '{surface.200}',
|
|
315
|
+
selectedColor: '{surface.600}',
|
|
316
|
+
focusRing: {
|
|
317
|
+
color: '{surface.200}',
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
dark: {
|
|
322
|
+
navButton: {
|
|
323
|
+
color: '{surface.200}',
|
|
324
|
+
hoverBackground: 'transparent',
|
|
325
|
+
selectedBackground: 'transparent',
|
|
326
|
+
selectedColor: '#fff',
|
|
327
|
+
focusRing: {
|
|
328
|
+
color: '#fff',
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
css: () => `
|
|
266
334
|
.p-paginator {
|
|
267
335
|
--p-paginator-gap: 0;
|
|
268
336
|
--p-paginator-nav-button-width: 2.2rem;
|
|
@@ -324,35 +392,38 @@ const MTPreset = (primaryColor) => definePreset(Aura, {
|
|
|
324
392
|
border-left-color: var(--p-surface-500);
|
|
325
393
|
}
|
|
326
394
|
`,
|
|
327
|
-
},
|
|
328
|
-
toggleswitch: {
|
|
329
|
-
root: {
|
|
330
|
-
width: '2.5rem',
|
|
331
|
-
height: '1.4rem',
|
|
332
395
|
},
|
|
396
|
+
toggleswitch: {
|
|
397
|
+
root: {
|
|
398
|
+
width: '2.5rem',
|
|
399
|
+
height: '1.4rem',
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
// steps: {
|
|
403
|
+
// item: {
|
|
404
|
+
// link: {
|
|
405
|
+
// gap: 'calc(50% + 0.25rem)',
|
|
406
|
+
// },
|
|
407
|
+
// number: {
|
|
408
|
+
// font: {
|
|
409
|
+
// size: '0.9rem',
|
|
410
|
+
// },
|
|
411
|
+
// active: {
|
|
412
|
+
// color: 'white',
|
|
413
|
+
// background: '{primary.500}',
|
|
414
|
+
// border: {
|
|
415
|
+
// color: '{primary.500}',
|
|
416
|
+
// },
|
|
417
|
+
// },
|
|
418
|
+
// },
|
|
419
|
+
// },
|
|
420
|
+
// },
|
|
333
421
|
},
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
// number: {
|
|
340
|
-
// font: {
|
|
341
|
-
// size: '0.9rem',
|
|
342
|
-
// },
|
|
343
|
-
// active: {
|
|
344
|
-
// color: 'white',
|
|
345
|
-
// background: '{primary.500}',
|
|
346
|
-
// border: {
|
|
347
|
-
// color: '{primary.500}',
|
|
348
|
-
// },
|
|
349
|
-
// },
|
|
350
|
-
// },
|
|
351
|
-
// },
|
|
352
|
-
// },
|
|
353
|
-
},
|
|
354
|
-
});
|
|
355
|
-
function provideMTComponents(primaryColor) {
|
|
422
|
+
};
|
|
423
|
+
return definePreset(Aura, configs);
|
|
424
|
+
};
|
|
425
|
+
function provideMTComponents(themeOptions) {
|
|
426
|
+
changeBackgroundColor(themeOptions?.backgroundColor);
|
|
356
427
|
return providePrimeNG({
|
|
357
428
|
zIndex: {
|
|
358
429
|
modal: 1900,
|
|
@@ -361,7 +432,7 @@ function provideMTComponents(primaryColor) {
|
|
|
361
432
|
tooltip: 1600,
|
|
362
433
|
},
|
|
363
434
|
theme: {
|
|
364
|
-
preset: MTPreset(
|
|
435
|
+
preset: MTPreset(themeOptions),
|
|
365
436
|
options: {
|
|
366
437
|
darkModeSelector: '.dark',
|
|
367
438
|
},
|
|
@@ -830,5 +901,5 @@ function wrapValidatorWithMessage(validator, errorKey, message) {
|
|
|
830
901
|
* Generated bundle index. Do not edit.
|
|
831
902
|
*/
|
|
832
903
|
|
|
833
|
-
export { BaseFieldConfig, CheckboxFieldConfig, ColorPickerFieldConfig, DateFieldConfig, EditorFieldConfig, IconFieldConfig, MultiSelectFieldConfig, NumberFieldConfig, PickListFieldConfig, RadioButtonFieldConfig, RadioCardsFieldConfig, SelectFieldConfig, SliderFieldConfig, SpacerFieldConfig, TextFieldConfig, TextareaFieldConfig, ToggleFieldConfig, UploadFileFieldConfig, UserSearchFieldConfig, ValidatorConfig, changePrimaryColor, createCustomValidator, generateTailwindPalette, isInvalid, provideMTComponents, provideMTMessages, wrapValidatorWithMessage };
|
|
904
|
+
export { BaseFieldConfig, CheckboxFieldConfig, ColorPickerFieldConfig, DateFieldConfig, EditorFieldConfig, IconFieldConfig, MultiSelectFieldConfig, NumberFieldConfig, PickListFieldConfig, RadioButtonFieldConfig, RadioCardsFieldConfig, SelectFieldConfig, SliderFieldConfig, SpacerFieldConfig, TextFieldConfig, TextareaFieldConfig, ToggleFieldConfig, UploadFileFieldConfig, UserSearchFieldConfig, ValidatorConfig, changeBackgroundColor, changePrimaryColor, changeTextColor, createCustomValidator, generateTailwindPalette, isInvalid, provideMTComponents, provideMTMessages, wrapValidatorWithMessage };
|
|
834
905
|
//# sourceMappingURL=masterteam-components.mjs.map
|