ngx-kit 6.0.0 → 6.0.2
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/angle-selector/README.md +11 -11
- package/box-shadow/README.md +10 -10
- package/color-picker/README.md +20 -23
- package/data-table/README.md +34 -41
- package/date-picker/README.md +21 -26
- package/dialog/README.md +31 -33
- package/drawer-menu/README.md +51 -50
- package/dropzone/README.md +27 -26
- package/fesm2022/ngx-kit-box-shadow.mjs +2 -2
- package/fesm2022/ngx-kit-box-shadow.mjs.map +1 -1
- package/fesm2022/ngx-kit-color-picker.mjs +2 -2
- package/fesm2022/ngx-kit-color-picker.mjs.map +1 -1
- package/fesm2022/ngx-kit-data-table.mjs +68 -26
- package/fesm2022/ngx-kit-data-table.mjs.map +1 -1
- package/fesm2022/ngx-kit-dropzone.mjs +3 -3
- package/fesm2022/ngx-kit-dropzone.mjs.map +1 -1
- package/fesm2022/ngx-kit-form-field.mjs +129 -64
- package/fesm2022/ngx-kit-form-field.mjs.map +1 -1
- package/fesm2022/ngx-kit-gallery.mjs +2 -2
- package/fesm2022/ngx-kit-gallery.mjs.map +1 -1
- package/fesm2022/ngx-kit-gradient-picker.mjs +2 -2
- package/fesm2022/ngx-kit-gradient-picker.mjs.map +1 -1
- package/fesm2022/ngx-kit-image-editor.mjs +5 -5
- package/fesm2022/ngx-kit-image-editor.mjs.map +1 -1
- package/fesm2022/ngx-kit-time-picker.mjs +136 -83
- package/fesm2022/ngx-kit-time-picker.mjs.map +1 -1
- package/gallery/README.md +29 -29
- package/gradient-picker/README.md +16 -16
- package/image-editor/README.md +19 -19
- package/menu/README.md +27 -27
- package/message/README.md +34 -34
- package/notify/README.md +25 -23
- package/package.json +1 -1
- package/shared/README.md +32 -32
- package/time-picker/README.md +95 -0
- package/types/ngx-kit-data-table.d.ts +25 -5
- package/types/ngx-kit-form-field.d.ts +65 -27
- package/types/ngx-kit-image-editor.d.ts +1 -1
- package/types/ngx-kit-time-picker.d.ts +28 -24
|
@@ -18,6 +18,19 @@ const NGX_TIME_PICKER_CONFIG = new InjectionToken('ngx-time-picker-config', {
|
|
|
18
18
|
factory: () => DEFAULT_TIME_PICKER_CONFIG,
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
function normalizeTime(value) {
|
|
22
|
+
const match = value.match(/^(\d{1,2}):(\d{2})$/);
|
|
23
|
+
if (!match) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const hour = Number(match[1]);
|
|
27
|
+
const minute = Number(match[2]);
|
|
28
|
+
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return [hour.toString().padStart(2, '0'), minute.toString().padStart(2, '0')].join(':');
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
class NgxInputTimePickerComponent {
|
|
22
35
|
browserService = inject(BrowserService);
|
|
23
36
|
change = output();
|
|
@@ -37,8 +50,6 @@ class NgxInputTimePickerComponent {
|
|
|
37
50
|
*/
|
|
38
51
|
format = input(this.config.format, /* @ts-ignore */
|
|
39
52
|
...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
|
|
40
|
-
amOrPm = model(this.config.format == '12' ? 'AM' : undefined, /* @ts-ignore */
|
|
41
|
-
...(ngDevMode ? [{ debugName: "amOrPm" }] : /* istanbul ignore next */ []));
|
|
42
53
|
/**
|
|
43
54
|
* Minute step.
|
|
44
55
|
*/
|
|
@@ -77,6 +88,11 @@ class NgxInputTimePickerComponent {
|
|
|
77
88
|
return hour;
|
|
78
89
|
}, /* @ts-ignore */
|
|
79
90
|
...(ngDevMode ? [{ debugName: "displayHour" }] : /* istanbul ignore next */ []));
|
|
91
|
+
isPm = computed(() => {
|
|
92
|
+
const hour = Number(this.value().split(':')[0]);
|
|
93
|
+
return hour >= 12;
|
|
94
|
+
}, /* @ts-ignore */
|
|
95
|
+
...(ngDevMode ? [{ debugName: "isPm" }] : /* istanbul ignore next */ []));
|
|
80
96
|
displayMinute = computed(() => {
|
|
81
97
|
return this.parsedTime().minute;
|
|
82
98
|
}, /* @ts-ignore */
|
|
@@ -132,45 +148,58 @@ class NgxInputTimePickerComponent {
|
|
|
132
148
|
return 86;
|
|
133
149
|
}, /* @ts-ignore */
|
|
134
150
|
...(ngDevMode ? [{ debugName: "handLength" }] : /* istanbul ignore next */ []));
|
|
135
|
-
|
|
151
|
+
hourRadius = computed(() => {
|
|
152
|
+
if (this.mode() !== 'hour') {
|
|
153
|
+
return 94;
|
|
154
|
+
}
|
|
155
|
+
if (this.format() !== '24') {
|
|
156
|
+
return 94;
|
|
157
|
+
}
|
|
158
|
+
const hour = this.parsedTime().hour;
|
|
159
|
+
// 00, 13..23 → inner ring
|
|
160
|
+
if (hour === 0 || hour >= 13) {
|
|
161
|
+
return 58;
|
|
162
|
+
}
|
|
163
|
+
// 01..12 → outer ring
|
|
164
|
+
return 94;
|
|
165
|
+
}, /* @ts-ignore */
|
|
166
|
+
...(ngDevMode ? [{ debugName: "hourRadius" }] : /* istanbul ignore next */ []));
|
|
167
|
+
selectedPosition = computed(() => {
|
|
136
168
|
const angle = this.currentAngle();
|
|
137
169
|
const radians = ((angle - 90) * Math.PI) / 180;
|
|
138
|
-
const radius = this.
|
|
170
|
+
const radius = this.mode() === 'hour' ? this.hourRadius() : 94;
|
|
139
171
|
return {
|
|
140
172
|
x: 120 + Math.cos(radians) * radius,
|
|
141
173
|
y: 120 + Math.sin(radians) * radius,
|
|
142
174
|
};
|
|
143
175
|
}, /* @ts-ignore */
|
|
144
|
-
...(ngDevMode ? [{ debugName: "
|
|
145
|
-
|
|
176
|
+
...(ngDevMode ? [{ debugName: "selectedPosition" }] : /* istanbul ignore next */ []));
|
|
177
|
+
handEnd = computed(() => {
|
|
146
178
|
const angle = this.currentAngle();
|
|
147
179
|
const radians = ((angle - 90) * Math.PI) / 180;
|
|
148
|
-
const radius = this.mode() === 'hour' ?
|
|
180
|
+
const radius = this.mode() === 'hour' ? this.hourRadius() : 94;
|
|
149
181
|
return {
|
|
150
182
|
x: 120 + Math.cos(radians) * radius,
|
|
151
183
|
y: 120 + Math.sin(radians) * radius,
|
|
152
184
|
};
|
|
153
185
|
}, /* @ts-ignore */
|
|
154
|
-
...(ngDevMode ? [{ debugName: "
|
|
186
|
+
...(ngDevMode ? [{ debugName: "handEnd" }] : /* istanbul ignore next */ []));
|
|
155
187
|
_onChange = (value) => { };
|
|
156
188
|
_onTouched = () => { };
|
|
157
189
|
_validatorOnChange = () => { };
|
|
158
190
|
constructor() { }
|
|
159
191
|
ngOnInit() { }
|
|
160
192
|
writeValue(value) {
|
|
161
|
-
if (!value)
|
|
162
|
-
value
|
|
163
|
-
|
|
164
|
-
if (this.format() == '12') {
|
|
165
|
-
if (+s[0] > 12) {
|
|
166
|
-
s[0] = (+s[0] - 12).toString().padStart(2, '0');
|
|
167
|
-
this.amOrPm.set('PM');
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
this.amOrPm.set('AM');
|
|
171
|
-
}
|
|
193
|
+
if (!value) {
|
|
194
|
+
this.value.set('12:00');
|
|
195
|
+
return;
|
|
172
196
|
}
|
|
173
|
-
|
|
197
|
+
const normalized = normalizeTime(value);
|
|
198
|
+
if (normalized === null) {
|
|
199
|
+
// invalid value
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
this.value.set(normalized);
|
|
174
203
|
}
|
|
175
204
|
validate(control) {
|
|
176
205
|
return null;
|
|
@@ -247,54 +276,71 @@ class NgxInputTimePickerComponent {
|
|
|
247
276
|
return;
|
|
248
277
|
}
|
|
249
278
|
const rect = svg.getBoundingClientRect();
|
|
250
|
-
/*
|
|
251
|
-
* SVG viewBox = 0 0 240 240
|
|
252
|
-
*
|
|
253
|
-
* Convert browser coordinates
|
|
254
|
-
* to SVG coordinates.
|
|
255
|
-
*/
|
|
256
279
|
const x = ((event.clientX - rect.left) / rect.width) * 240;
|
|
257
280
|
const y = ((event.clientY - rect.top) / rect.height) * 240;
|
|
281
|
+
if (this.mode() === 'hour') {
|
|
282
|
+
this.updateHourFromPointer(x, y);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this.updateMinuteFromPointer(x, y);
|
|
286
|
+
}
|
|
287
|
+
updateHourFromPointer(x, y) {
|
|
258
288
|
const dx = x - 120;
|
|
259
289
|
const dy = y - 120;
|
|
290
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
260
291
|
let angle = (Math.atan2(dy, dx) * 180) / Math.PI + 90;
|
|
261
292
|
if (angle < 0) {
|
|
262
293
|
angle += 360;
|
|
263
294
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
295
|
+
let hour = Math.round(angle / 30) % 12;
|
|
296
|
+
if (this.format() === '12') {
|
|
297
|
+
hour = hour === 0 ? 12 : hour;
|
|
298
|
+
this.setTime(hour, this.parsedTime().minute);
|
|
299
|
+
return;
|
|
269
300
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
301
|
+
/*
|
|
302
|
+
* 24 hour mode
|
|
303
|
+
*
|
|
304
|
+
* Outer ring:
|
|
305
|
+
* 1 ... 12
|
|
306
|
+
*
|
|
307
|
+
* Inner ring:
|
|
308
|
+
* 13 ... 23, 00
|
|
309
|
+
*/
|
|
310
|
+
const INNER_RING_THRESHOLD = 76;
|
|
311
|
+
const isInnerRing = distance < INNER_RING_THRESHOLD;
|
|
312
|
+
if (isInnerRing) {
|
|
313
|
+
/*
|
|
314
|
+
* Inner ring:
|
|
315
|
+
*
|
|
316
|
+
* 12 position -> 00
|
|
317
|
+
* 1 position -> 13
|
|
318
|
+
* 2 position -> 14
|
|
319
|
+
* ...
|
|
320
|
+
* 11 position -> 23
|
|
321
|
+
*/
|
|
322
|
+
hour = hour === 0 ? 0 : hour + 12;
|
|
275
323
|
}
|
|
276
|
-
|
|
324
|
+
else {
|
|
277
325
|
/*
|
|
278
|
-
*
|
|
279
|
-
* to inner or outer 12-hour ring.
|
|
326
|
+
* Outer ring:
|
|
280
327
|
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
328
|
+
* 12 position -> 12
|
|
329
|
+
* 1 ... 11 -> 1 ... 11
|
|
283
330
|
*/
|
|
284
|
-
|
|
285
|
-
const currentIsPm = currentHour >= 12;
|
|
286
|
-
if (hour !== 12) {
|
|
287
|
-
hour = currentIsPm ? hour + 12 : hour;
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
hour = currentIsPm ? 12 : 0;
|
|
291
|
-
}
|
|
331
|
+
hour = hour === 0 ? 12 : hour;
|
|
292
332
|
}
|
|
293
333
|
this.setTime(hour, this.parsedTime().minute);
|
|
294
334
|
}
|
|
295
|
-
|
|
335
|
+
updateMinuteFromPointer(x, y) {
|
|
336
|
+
const dx = x - 120;
|
|
337
|
+
const dy = y - 120;
|
|
338
|
+
let angle = (Math.atan2(dy, dx) * 180) / Math.PI + 90;
|
|
339
|
+
if (angle < 0) {
|
|
340
|
+
angle += 360;
|
|
341
|
+
}
|
|
296
342
|
let minute = Math.round(angle / 6);
|
|
297
|
-
minute
|
|
343
|
+
minute %= 60;
|
|
298
344
|
const step = Math.max(1, this.minuteStep());
|
|
299
345
|
minute = Math.round(minute / step) * step;
|
|
300
346
|
if (minute >= 60) {
|
|
@@ -307,13 +353,6 @@ class NgxInputTimePickerComponent {
|
|
|
307
353
|
const m = String(minute).padStart(2, '0');
|
|
308
354
|
this.value.set(`${h}:${m}`);
|
|
309
355
|
}
|
|
310
|
-
isSelectedHour(hour) {
|
|
311
|
-
const current = this.displayHour();
|
|
312
|
-
return current === hour;
|
|
313
|
-
}
|
|
314
|
-
isSelectedMinute(minute) {
|
|
315
|
-
return this.displayMinute() === minute;
|
|
316
|
-
}
|
|
317
356
|
formatHour(hour) {
|
|
318
357
|
if (this.format() === '24') {
|
|
319
358
|
return String(hour).padStart(2, '0');
|
|
@@ -349,10 +388,25 @@ class NgxInputTimePickerComponent {
|
|
|
349
388
|
y: 120 + Math.sin(radians) * 94,
|
|
350
389
|
};
|
|
351
390
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
391
|
+
togglePmAm(val) {
|
|
392
|
+
const [hour, minute] = this.value().split(':').map(Number);
|
|
393
|
+
let newHour = hour;
|
|
394
|
+
if (val === 'AM') {
|
|
395
|
+
// 12:xx PM → 00:xx
|
|
396
|
+
if (hour >= 12) {
|
|
397
|
+
newHour = hour - 12;
|
|
398
|
+
}
|
|
355
399
|
}
|
|
400
|
+
else {
|
|
401
|
+
// 00:xx AM → 12:xx PM
|
|
402
|
+
if (hour < 12) {
|
|
403
|
+
newHour = hour + 12;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const value = `${String(newHour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`;
|
|
407
|
+
this.value.set(value);
|
|
408
|
+
}
|
|
409
|
+
ok() {
|
|
356
410
|
this.change.emit(this.value());
|
|
357
411
|
this._onChange(this.value());
|
|
358
412
|
}
|
|
@@ -360,7 +414,7 @@ class NgxInputTimePickerComponent {
|
|
|
360
414
|
this.cancel.emit();
|
|
361
415
|
}
|
|
362
416
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NgxInputTimePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
363
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.4", type: NgxInputTimePickerComponent, isStandalone: true, selector: "ngx-time-picker", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null },
|
|
417
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.4", type: NgxInputTimePickerComponent, isStandalone: true, selector: "ngx-time-picker", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, minuteStep: { classPropertyName: "minuteStep", publicName: "minuteStep", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, autoSwitchToMinute: { classPropertyName: "autoSwitchToMinute", publicName: "autoSwitchToMinute", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { change: "change", cancel: "cancel", value: "valueChange" }, providers: [
|
|
364
418
|
{
|
|
365
419
|
provide: NG_VALUE_ACCESSOR,
|
|
366
420
|
useExisting: forwardRef(() => NgxInputTimePickerComponent),
|
|
@@ -371,7 +425,7 @@ class NgxInputTimePickerComponent {
|
|
|
371
425
|
useExisting: forwardRef(() => NgxInputTimePickerComponent),
|
|
372
426
|
multi: true,
|
|
373
427
|
},
|
|
374
|
-
], viewQueries: [{ propertyName: "clock", first: true, predicate: ["clock"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"ngx-time-picker\" [class.ngx-time-picker--disabled]=\"disabled()\">\n <!-- Header -->\n <div class=\"ngx-time-picker__header\">\n <button\n type=\"button\"\n class=\"ngx-time-picker__value\"\n [class.active]=\"mode() === 'hour'\"\n [disabled]=\"disabled()\"\n (click)=\"setMode('hour')\">\n {{ formatHour(displayHour()) }}\n </button>\n\n <span class=\"ngx-time-picker__separator\">:</span>\n\n <button\n type=\"button\"\n class=\"ngx-time-picker__value\"\n [class.active]=\"mode() === 'minute'\"\n [disabled]=\"disabled()\"\n (click)=\"setMode('minute')\">\n {{ formatMinute(displayMinute()) }}\n </button>\n\n @if (format() == '12') {\n <div class=\"ngx-time-picker_format\">\n <button [class.active]=\"
|
|
428
|
+
], viewQueries: [{ propertyName: "clock", first: true, predicate: ["clock"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"ngx-time-picker\" [class.ngx-time-picker--disabled]=\"disabled()\">\n <!-- Header -->\n <div class=\"ngx-time-picker__header\">\n <button\n type=\"button\"\n class=\"ngx-time-picker__value\"\n [class.active]=\"mode() === 'hour'\"\n [disabled]=\"disabled()\"\n (click)=\"setMode('hour')\">\n {{ formatHour(displayHour()) }}\n </button>\n\n <span class=\"ngx-time-picker__separator\">:</span>\n\n <button\n type=\"button\"\n class=\"ngx-time-picker__value\"\n [class.active]=\"mode() === 'minute'\"\n [disabled]=\"disabled()\"\n (click)=\"setMode('minute')\">\n {{ formatMinute(displayMinute()) }}\n </button>\n\n @if (format() == '12') {\n <div class=\"ngx-time-picker_format\">\n <button [class.active]=\"!isPm()\" (click)=\"togglePmAm('AM')\">\n {{ config.amText }}\n </button>\n <button [class.active]=\"isPm()\" (click)=\"togglePmAm('PM')\">\n {{ config.pmText }}\n </button>\n </div>\n }\n </div>\n\n <!-- Clock -->\n <div class=\"ngx-time-picker__clock-wrapper\">\n <svg\n #clock\n class=\"ngx-time-picker__clock\"\n viewBox=\"0 0 240 240\"\n xmlns=\"http://www.w3.org/2000/svg\"\n (pointerdown)=\"startPointer($event)\"\n (pointermove)=\"movePointer($event)\"\n (pointerup)=\"endPointer($event)\"\n (pointercancel)=\"endPointer($event)\">\n <!-- Background -->\n <circle class=\"clock-background\" cx=\"120\" cy=\"120\" r=\"112\" />\n\n <!-- Selected hand line -->\n <line class=\"clock-hand\" x1=\"120\" y1=\"120\" [attr.x2]=\"handEnd().x\" [attr.y2]=\"handEnd().y\" />\n\n <!-- Selected circle -->\n <circle\n class=\"clock-selected\"\n [attr.cx]=\"selectedPosition().x\"\n [attr.cy]=\"selectedPosition().y\"\n r=\"18\" />\n\n <!-- Center -->\n <circle class=\"clock-center\" cx=\"120\" cy=\"120\" r=\"5\" />\n\n <!-- HOURS -->\n @if (mode() === 'hour') {\n @for (hour of hourNumbers(); track hour) {\n @if (format() === '24' && (hour >= 13 || hour == 0)) {\n <g class=\"clock-number clock-number--inner\" (click)=\"selectHour(hour)\">\n <circle\n [attr.cx]=\"hourPosition(hour - 12, true).x\"\n [attr.cy]=\"hourPosition(hour - 12, true).y\"\n r=\"16\" />\n\n <text\n [attr.x]=\"hourPosition(hour - 12, true).x\"\n [attr.y]=\"hourPosition(hour - 12, true).y\">\n {{ hour == 0 ? '00' : hour }}\n </text>\n </g>\n } @else {\n <g\n class=\"clock-number\"\n [class.selected]=\"displayHour() == hour\"\n (click)=\"selectHour(hour)\">\n <circle [attr.cx]=\"hourPosition(hour).x\" [attr.cy]=\"hourPosition(hour).y\" r=\"18\" />\n\n <text [attr.x]=\"hourPosition(hour).x\" [attr.y]=\"hourPosition(hour).y\">\n {{ hour }}\n </text>\n </g>\n }\n }\n }\n\n <!-- MINUTES -->\n @if (mode() === 'minute') {\n @for (minute of minuteNumbers(); track minute) {\n <g\n class=\"clock-number\"\n [class.selected]=\"displayMinute() == minute\"\n (click)=\"selectMinute(minute)\">\n <circle\n [attr.cx]=\"minutePosition(minute).x\"\n [attr.cy]=\"minutePosition(minute).y\"\n r=\"18\" />\n\n <text [attr.x]=\"minutePosition(minute).x\" [attr.y]=\"minutePosition(minute).y\">\n {{ formatMinute(minute) }}\n </text>\n </g>\n }\n }\n </svg>\n </div>\n <div class=\"ngx-time-picker--footer\">\n <button (click)=\"close()\">\n {{ config.cancelButtonText }}\n </button>\n\n <button (click)=\"ok()\">\n {{ config.confirmButtonText }}\n </button>\n </div>\n</div>\n", styles: [":host{--ngx-time-picker-clock-bg: light-dark(#f8f8f8, #181818);--ngx-time-picker-header-bg: #6200ee;--ngx-time-picker-header-fg: #fff;--ngx-clock-bg: light-dark(#e8e8e8, #35363c);display:inline-block}.ngx-time-picker{width:300px;max-width:100%;border-radius:15px;overflow:hidden;direction:ltr;user-select:none;-webkit-user-select:none;border:1px rgba(134,134,134,.3490196078) solid;box-shadow:0 0 20px #7a7a7a21}.ngx-time-picker__header{display:flex;align-items:center;justify-content:center;height:82px;background:var(--ngx-time-picker-header-bg, );color:var(--ngx-time-picker-header-fg)}.ngx-time-picker__value{border:0;padding:0;background:transparent;color:#ffffff8c;font-size:48px;line-height:1;font-weight:400;cursor:pointer;transition:color .16s ease,opacity .16s ease;font-variant-numeric:tabular-nums}.ngx-time-picker__value:hover{color:#fffc}.ngx-time-picker__value.active{color:#fff}.ngx-time-picker__value:disabled{cursor:default}.ngx-time-picker__separator{margin-inline:4px;font-size:44px;line-height:1;color:#fff}.ngx-time-picker__clock-wrapper{display:flex;align-items:center;justify-content:center;padding:20px;background:var(--ngx-time-picker-clock-bg)}.ngx-time-picker__clock{width:250px;height:250px;touch-action:none;overflow:visible;cursor:pointer}.clock-background{fill:var(--ngx-clock-bg)}.clock-hand{stroke:#1976d2;stroke-width:2;stroke-linecap:round;pointer-events:none}.clock-center,.clock-selected{fill:#1976d2;pointer-events:none}.clock-number{cursor:pointer}.clock-number circle{fill:transparent}.clock-number text{fill:currentColor;font-size:14px;font-family:Roboto,Arial,sans-serif;text-anchor:middle;dominant-baseline:central;pointer-events:none;transition:fill .12s ease}.clock-number:hover circle{fill:#1976d21f}.clock-number.selected text{fill:#000;font-weight:500}.clock-number--inner text{font-size:12px}.ngx-time-picker--disabled{opacity:.5;pointer-events:none}.ngx-time-picker--footer{display:flex;justify-content:flex-end;gap:5px;padding:5px 10px;background:var(--ngx-time-picker-clock-bg)}.ngx-time-picker--footer button{outline:none;background:none;color:inherit;border:none;border-radius:4px;padding:8px 15px;box-shadow:none;transition:all .3s}.ngx-time-picker--footer button:not([disabled]):hover{cursor:pointer;background:#816ef175}.ngx-time-picker_format{display:flex;flex-direction:column;margin:0 15px;gap:5px}.ngx-time-picker_format button{all:unset;opacity:.4;cursor:pointer}.ngx-time-picker_format button.active{opacity:1}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
375
429
|
}
|
|
376
430
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NgxInputTimePickerComponent, decorators: [{
|
|
377
431
|
type: Component,
|
|
@@ -386,8 +440,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
386
440
|
useExisting: forwardRef(() => NgxInputTimePickerComponent),
|
|
387
441
|
multi: true,
|
|
388
442
|
},
|
|
389
|
-
], template: "<div class=\"ngx-time-picker\" [class.ngx-time-picker--disabled]=\"disabled()\">\n <!-- Header -->\n <div class=\"ngx-time-picker__header\">\n <button\n type=\"button\"\n class=\"ngx-time-picker__value\"\n [class.active]=\"mode() === 'hour'\"\n [disabled]=\"disabled()\"\n (click)=\"setMode('hour')\">\n {{ formatHour(displayHour()) }}\n </button>\n\n <span class=\"ngx-time-picker__separator\">:</span>\n\n <button\n type=\"button\"\n class=\"ngx-time-picker__value\"\n [class.active]=\"mode() === 'minute'\"\n [disabled]=\"disabled()\"\n (click)=\"setMode('minute')\">\n {{ formatMinute(displayMinute()) }}\n </button>\n\n @if (format() == '12') {\n <div class=\"ngx-time-picker_format\">\n <button [class.active]=\"
|
|
390
|
-
}], ctorParameters: () => [], propDecorators: { change: [{ type: i0.Output, args: ["change"] }], cancel: [{ type: i0.Output, args: ["cancel"] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }],
|
|
443
|
+
], template: "<div class=\"ngx-time-picker\" [class.ngx-time-picker--disabled]=\"disabled()\">\n <!-- Header -->\n <div class=\"ngx-time-picker__header\">\n <button\n type=\"button\"\n class=\"ngx-time-picker__value\"\n [class.active]=\"mode() === 'hour'\"\n [disabled]=\"disabled()\"\n (click)=\"setMode('hour')\">\n {{ formatHour(displayHour()) }}\n </button>\n\n <span class=\"ngx-time-picker__separator\">:</span>\n\n <button\n type=\"button\"\n class=\"ngx-time-picker__value\"\n [class.active]=\"mode() === 'minute'\"\n [disabled]=\"disabled()\"\n (click)=\"setMode('minute')\">\n {{ formatMinute(displayMinute()) }}\n </button>\n\n @if (format() == '12') {\n <div class=\"ngx-time-picker_format\">\n <button [class.active]=\"!isPm()\" (click)=\"togglePmAm('AM')\">\n {{ config.amText }}\n </button>\n <button [class.active]=\"isPm()\" (click)=\"togglePmAm('PM')\">\n {{ config.pmText }}\n </button>\n </div>\n }\n </div>\n\n <!-- Clock -->\n <div class=\"ngx-time-picker__clock-wrapper\">\n <svg\n #clock\n class=\"ngx-time-picker__clock\"\n viewBox=\"0 0 240 240\"\n xmlns=\"http://www.w3.org/2000/svg\"\n (pointerdown)=\"startPointer($event)\"\n (pointermove)=\"movePointer($event)\"\n (pointerup)=\"endPointer($event)\"\n (pointercancel)=\"endPointer($event)\">\n <!-- Background -->\n <circle class=\"clock-background\" cx=\"120\" cy=\"120\" r=\"112\" />\n\n <!-- Selected hand line -->\n <line class=\"clock-hand\" x1=\"120\" y1=\"120\" [attr.x2]=\"handEnd().x\" [attr.y2]=\"handEnd().y\" />\n\n <!-- Selected circle -->\n <circle\n class=\"clock-selected\"\n [attr.cx]=\"selectedPosition().x\"\n [attr.cy]=\"selectedPosition().y\"\n r=\"18\" />\n\n <!-- Center -->\n <circle class=\"clock-center\" cx=\"120\" cy=\"120\" r=\"5\" />\n\n <!-- HOURS -->\n @if (mode() === 'hour') {\n @for (hour of hourNumbers(); track hour) {\n @if (format() === '24' && (hour >= 13 || hour == 0)) {\n <g class=\"clock-number clock-number--inner\" (click)=\"selectHour(hour)\">\n <circle\n [attr.cx]=\"hourPosition(hour - 12, true).x\"\n [attr.cy]=\"hourPosition(hour - 12, true).y\"\n r=\"16\" />\n\n <text\n [attr.x]=\"hourPosition(hour - 12, true).x\"\n [attr.y]=\"hourPosition(hour - 12, true).y\">\n {{ hour == 0 ? '00' : hour }}\n </text>\n </g>\n } @else {\n <g\n class=\"clock-number\"\n [class.selected]=\"displayHour() == hour\"\n (click)=\"selectHour(hour)\">\n <circle [attr.cx]=\"hourPosition(hour).x\" [attr.cy]=\"hourPosition(hour).y\" r=\"18\" />\n\n <text [attr.x]=\"hourPosition(hour).x\" [attr.y]=\"hourPosition(hour).y\">\n {{ hour }}\n </text>\n </g>\n }\n }\n }\n\n <!-- MINUTES -->\n @if (mode() === 'minute') {\n @for (minute of minuteNumbers(); track minute) {\n <g\n class=\"clock-number\"\n [class.selected]=\"displayMinute() == minute\"\n (click)=\"selectMinute(minute)\">\n <circle\n [attr.cx]=\"minutePosition(minute).x\"\n [attr.cy]=\"minutePosition(minute).y\"\n r=\"18\" />\n\n <text [attr.x]=\"minutePosition(minute).x\" [attr.y]=\"minutePosition(minute).y\">\n {{ formatMinute(minute) }}\n </text>\n </g>\n }\n }\n </svg>\n </div>\n <div class=\"ngx-time-picker--footer\">\n <button (click)=\"close()\">\n {{ config.cancelButtonText }}\n </button>\n\n <button (click)=\"ok()\">\n {{ config.confirmButtonText }}\n </button>\n </div>\n</div>\n", styles: [":host{--ngx-time-picker-clock-bg: light-dark(#f8f8f8, #181818);--ngx-time-picker-header-bg: #6200ee;--ngx-time-picker-header-fg: #fff;--ngx-clock-bg: light-dark(#e8e8e8, #35363c);display:inline-block}.ngx-time-picker{width:300px;max-width:100%;border-radius:15px;overflow:hidden;direction:ltr;user-select:none;-webkit-user-select:none;border:1px rgba(134,134,134,.3490196078) solid;box-shadow:0 0 20px #7a7a7a21}.ngx-time-picker__header{display:flex;align-items:center;justify-content:center;height:82px;background:var(--ngx-time-picker-header-bg, );color:var(--ngx-time-picker-header-fg)}.ngx-time-picker__value{border:0;padding:0;background:transparent;color:#ffffff8c;font-size:48px;line-height:1;font-weight:400;cursor:pointer;transition:color .16s ease,opacity .16s ease;font-variant-numeric:tabular-nums}.ngx-time-picker__value:hover{color:#fffc}.ngx-time-picker__value.active{color:#fff}.ngx-time-picker__value:disabled{cursor:default}.ngx-time-picker__separator{margin-inline:4px;font-size:44px;line-height:1;color:#fff}.ngx-time-picker__clock-wrapper{display:flex;align-items:center;justify-content:center;padding:20px;background:var(--ngx-time-picker-clock-bg)}.ngx-time-picker__clock{width:250px;height:250px;touch-action:none;overflow:visible;cursor:pointer}.clock-background{fill:var(--ngx-clock-bg)}.clock-hand{stroke:#1976d2;stroke-width:2;stroke-linecap:round;pointer-events:none}.clock-center,.clock-selected{fill:#1976d2;pointer-events:none}.clock-number{cursor:pointer}.clock-number circle{fill:transparent}.clock-number text{fill:currentColor;font-size:14px;font-family:Roboto,Arial,sans-serif;text-anchor:middle;dominant-baseline:central;pointer-events:none;transition:fill .12s ease}.clock-number:hover circle{fill:#1976d21f}.clock-number.selected text{fill:#000;font-weight:500}.clock-number--inner text{font-size:12px}.ngx-time-picker--disabled{opacity:.5;pointer-events:none}.ngx-time-picker--footer{display:flex;justify-content:flex-end;gap:5px;padding:5px 10px;background:var(--ngx-time-picker-clock-bg)}.ngx-time-picker--footer button{outline:none;background:none;color:inherit;border:none;border-radius:4px;padding:8px 15px;box-shadow:none;transition:all .3s}.ngx-time-picker--footer button:not([disabled]):hover{cursor:pointer;background:#816ef175}.ngx-time-picker_format{display:flex;flex-direction:column;margin:0 15px;gap:5px}.ngx-time-picker_format button{all:unset;opacity:.4;cursor:pointer}.ngx-time-picker_format button.active{opacity:1}\n"] }]
|
|
444
|
+
}], ctorParameters: () => [], propDecorators: { change: [{ type: i0.Output, args: ["change"] }], cancel: [{ type: i0.Output, args: ["cancel"] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], minuteStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "minuteStep", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], autoSwitchToMinute: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoSwitchToMinute", required: false }] }], clock: [{ type: i0.ViewChild, args: ['clock', { isSignal: true }] }] } });
|
|
391
445
|
|
|
392
446
|
class NgxInputTimePicker {
|
|
393
447
|
el;
|
|
@@ -399,8 +453,6 @@ class NgxInputTimePicker {
|
|
|
399
453
|
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
400
454
|
format = input(this.config.format, /* @ts-ignore */
|
|
401
455
|
...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
|
|
402
|
-
amOrPm = model(/* @ts-ignore */
|
|
403
|
-
...(ngDevMode ? [undefined, { debugName: "amOrPm" }] : /* istanbul ignore next */ []));
|
|
404
456
|
pickerRef;
|
|
405
457
|
_onChange = (value) => { };
|
|
406
458
|
_onTouched = () => { };
|
|
@@ -467,7 +519,6 @@ class NgxInputTimePicker {
|
|
|
467
519
|
margin: 2,
|
|
468
520
|
configure: (instance, ref) => {
|
|
469
521
|
instance.writeValue(this.value());
|
|
470
|
-
instance.amOrPm.set(this.amOrPm());
|
|
471
522
|
instance.change.subscribe((c) => {
|
|
472
523
|
this.value.set(c ?? '');
|
|
473
524
|
this.emitChange();
|
|
@@ -491,24 +542,16 @@ class NgxInputTimePicker {
|
|
|
491
542
|
this._onTouched();
|
|
492
543
|
}
|
|
493
544
|
validate(control) {
|
|
494
|
-
|
|
545
|
+
const raw = this.value();
|
|
546
|
+
if (!raw)
|
|
547
|
+
return null; // empty is handled by Validators.required, not us
|
|
548
|
+
return normalizeTime(raw) === null ? { invalid: true } : null;
|
|
495
549
|
}
|
|
496
550
|
_formatValue() {
|
|
497
|
-
const s = this.value().split(':');
|
|
498
|
-
if (this.format() == '12') {
|
|
499
|
-
if (+s[0] > 12) {
|
|
500
|
-
s[0] = (+s[0] - 12).toString().padStart(2, '0');
|
|
501
|
-
this.amOrPm.set('PM');
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
this.amOrPm.set('AM');
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
this.value.set(s.join(':') + ' ' + this.amOrPm());
|
|
508
551
|
this.renderer.setProperty(this.el.nativeElement, 'value', this.value());
|
|
509
552
|
}
|
|
510
553
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: NgxInputTimePicker, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
511
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.4", type: NgxInputTimePicker, isStandalone: true, selector: "[ngxInputTimePicker]", inputs: { openOnCLick: { classPropertyName: "openOnCLick", publicName: "openOnCLick", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }
|
|
554
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.4", type: NgxInputTimePicker, isStandalone: true, selector: "[ngxInputTimePicker]", inputs: { openOnCLick: { classPropertyName: "openOnCLick", publicName: "openOnCLick", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { change: "change" }, host: { listeners: { "click": "onClick($event)", "input": "onInput($event)", "blur": "onBlur()" }, properties: { "attr.readOnly": "true" }, classAttribute: "ngx-datepicker-input" }, providers: [
|
|
512
555
|
{
|
|
513
556
|
provide: NG_VALUE_ACCESSOR,
|
|
514
557
|
useExisting: forwardRef(() => NgxInputTimePicker),
|
|
@@ -543,7 +586,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
543
586
|
},
|
|
544
587
|
],
|
|
545
588
|
}]
|
|
546
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { openOnCLick: [{ type: i0.Input, args: [{ isSignal: true, alias: "openOnCLick", required: false }] }], change: [{ type: i0.Output, args: ["change"] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }],
|
|
589
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { openOnCLick: [{ type: i0.Input, args: [{ isSignal: true, alias: "openOnCLick", required: false }] }], change: [{ type: i0.Output, args: ["change"] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], onClick: [{
|
|
547
590
|
type: HostListener,
|
|
548
591
|
args: ['click', ['$event']]
|
|
549
592
|
}], onInput: [{
|
|
@@ -554,9 +597,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
554
597
|
args: ['blur']
|
|
555
598
|
}] } });
|
|
556
599
|
|
|
600
|
+
function provideTimePicker(config) {
|
|
601
|
+
const configuration = { ...DEFAULT_TIME_PICKER_CONFIG, ...config };
|
|
602
|
+
return [
|
|
603
|
+
{
|
|
604
|
+
provide: NGX_TIME_PICKER_CONFIG,
|
|
605
|
+
useValue: configuration,
|
|
606
|
+
},
|
|
607
|
+
];
|
|
608
|
+
}
|
|
609
|
+
|
|
557
610
|
/**
|
|
558
611
|
* Generated bundle index. Do not edit.
|
|
559
612
|
*/
|
|
560
613
|
|
|
561
|
-
export { NgxInputTimePicker, NgxInputTimePickerComponent };
|
|
614
|
+
export { DEFAULT_TIME_PICKER_CONFIG, NGX_TIME_PICKER_CONFIG, NgxInputTimePicker, NgxInputTimePickerComponent, NgxTimePickerConfig, provideTimePicker };
|
|
562
615
|
//# sourceMappingURL=ngx-kit-time-picker.mjs.map
|