@origostudio/origo-design 0.0.49 → 0.0.51
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/CHANGELOG.md +6 -4
- package/dist/packages/angular-renderer/CHANGELOG.md +22 -0
- package/dist/packages/angular-renderer/package.json +3 -3
- package/dist/packages/angular-renderer/src/components/primitives/autocomplete/autocomplete.component.d.ts +99 -0
- package/dist/packages/angular-renderer/src/components/primitives/autocomplete/autocomplete.component.js +306 -0
- package/dist/packages/angular-renderer/src/components/primitives/autocomplete/autocomplete.component.js.map +1 -0
- package/dist/packages/angular-renderer/src/components/primitives/combobox/combobox.component.d.ts +69 -0
- package/dist/packages/angular-renderer/src/components/primitives/combobox/combobox.component.js +276 -0
- package/dist/packages/angular-renderer/src/components/primitives/combobox/combobox.component.js.map +1 -0
- package/dist/packages/angular-renderer/src/components/primitives/date-picker/date-picker.component.d.ts +57 -0
- package/dist/packages/angular-renderer/src/components/primitives/date-picker/date-picker.component.js +257 -0
- package/dist/packages/angular-renderer/src/components/primitives/date-picker/date-picker.component.js.map +1 -0
- package/dist/packages/angular-renderer/src/components/primitives/date-range-picker/date-range-picker.component.d.ts +67 -0
- package/dist/packages/angular-renderer/src/components/primitives/date-range-picker/date-range-picker.component.js +299 -0
- package/dist/packages/angular-renderer/src/components/primitives/date-range-picker/date-range-picker.component.js.map +1 -0
- package/dist/packages/angular-renderer/src/components/primitives/multi-select/multi-select.component.d.ts +110 -0
- package/dist/packages/angular-renderer/src/components/primitives/multi-select/multi-select.component.js +323 -0
- package/dist/packages/angular-renderer/src/components/primitives/multi-select/multi-select.component.js.map +1 -0
- package/dist/packages/angular-renderer/src/components/primitives/select/select.component.d.ts +80 -19
- package/dist/packages/angular-renderer/src/components/primitives/select/select.component.js +201 -24
- package/dist/packages/angular-renderer/src/components/primitives/select/select.component.js.map +1 -1
- package/dist/packages/angular-renderer/src/components/primitives/select/selection-utils.d.ts +9 -0
- package/dist/packages/angular-renderer/src/components/primitives/select/selection-utils.js +69 -0
- package/dist/packages/angular-renderer/src/components/primitives/select/selection-utils.js.map +1 -0
- package/dist/packages/angular-renderer/src/components/primitives/time-picker/time-picker.component.d.ts +48 -0
- package/dist/packages/angular-renderer/src/components/primitives/time-picker/time-picker.component.js +214 -0
- package/dist/packages/angular-renderer/src/components/primitives/time-picker/time-picker.component.js.map +1 -0
- package/dist/packages/angular-renderer/src/index.d.ts +6 -0
- package/dist/packages/angular-renderer/src/index.js +6 -0
- package/dist/packages/angular-renderer/src/index.js.map +1 -1
- package/dist/packages/angular-renderer/src/lib/primitives.provider.js +12 -0
- package/dist/packages/angular-renderer/src/lib/primitives.provider.js.map +1 -1
- package/dist/packages/cli/CHANGELOG.md +8 -0
- package/dist/packages/cli/package.json +2 -2
- package/dist/packages/cli/package.json.bak +2 -2
- package/dist/packages/core/CHANGELOG.md +8 -0
- package/dist/packages/core/package.json +1 -1
- package/dist/packages/core/package.json.bak +1 -1
- package/dist/packages/design-tokens/CHANGELOG.md +8 -0
- package/dist/packages/design-tokens/package.json +1 -1
- package/dist/packages/playground/browser/{chunk-B_swdRuc.js → chunk-2fyh0Go5.js} +1 -1
- package/dist/packages/playground/browser/{chunk-C8l8Pst_.js → chunk-6qDdu3iP.js} +1 -1
- package/dist/packages/playground/browser/{chunk-G1sQXMvG.js → chunk-BQHgLM1h.js} +1 -1
- package/dist/packages/playground/browser/{chunk-Cb2ALrKC.js → chunk-BQrkBjEv.js} +1 -1
- package/dist/packages/playground/browser/{chunk-BbeNQQ9Z.js → chunk-BSIGVQT8.js} +1 -1
- package/dist/packages/playground/browser/{chunk-BlCRDoSd.js → chunk-CD79k8Eb.js} +1 -1
- package/dist/packages/playground/browser/{chunk-CCE_vAje.js → chunk-D6mKAQPx.js} +1 -1
- package/dist/packages/playground/browser/{chunk-DoYDPF2-.js → chunk-DBZa4hap.js} +1 -1
- package/dist/packages/playground/browser/{chunk-CpaI4VGh.js → chunk-DGb2Oa6d.js} +1 -1
- package/dist/packages/playground/browser/{chunk-B8mwHWgW.js → chunk-DPEeny3K.js} +1 -1
- package/dist/packages/playground/browser/{chunk-DgLZ-dIi.js → chunk-DeS5TtZS.js} +1 -1
- package/dist/packages/playground/browser/{chunk-r4-UbXQJ.js → chunk-DnW3HJ2k.js} +1 -1
- package/dist/packages/playground/browser/{chunk-lFsGUZ3A.js → chunk-V8VJI0nO.js} +1 -1
- package/dist/packages/playground/browser/{chunk-XTbjIUbx.js → chunk-mGxxpk2V.js} +1 -1
- package/dist/packages/playground/browser/{chunk-DkxgAarv.js → chunk-vt9o3pSK.js} +1 -1
- package/dist/packages/playground/browser/index.html +1 -1
- package/dist/packages/playground/browser/main-6RRVB3JV.js +740 -0
- package/package.json +1 -1
- package/packages/angular-renderer/CHANGELOG.md +22 -0
- package/packages/angular-renderer/package.json +3 -3
- package/packages/angular-renderer/src/components/primitives/autocomplete/autocomplete.component.html +83 -0
- package/packages/angular-renderer/src/components/primitives/autocomplete/autocomplete.component.scss +161 -0
- package/packages/angular-renderer/src/components/primitives/autocomplete/autocomplete.component.ts +338 -0
- package/packages/angular-renderer/src/components/primitives/combobox/combobox.component.html +90 -0
- package/packages/angular-renderer/src/components/primitives/combobox/combobox.component.scss +189 -0
- package/packages/angular-renderer/src/components/primitives/combobox/combobox.component.ts +281 -0
- package/packages/angular-renderer/src/components/primitives/date-picker/date-picker.component.html +73 -0
- package/packages/angular-renderer/src/components/primitives/date-picker/date-picker.component.scss +77 -0
- package/packages/angular-renderer/src/components/primitives/date-picker/date-picker.component.ts +294 -0
- package/packages/angular-renderer/src/components/primitives/date-range-picker/date-range-picker.component.html +83 -0
- package/packages/angular-renderer/src/components/primitives/date-range-picker/date-range-picker.component.scss +92 -0
- package/packages/angular-renderer/src/components/primitives/date-range-picker/date-range-picker.component.ts +357 -0
- package/packages/angular-renderer/src/components/primitives/icon-button/icon-button.component.html +1 -1
- package/packages/angular-renderer/src/components/primitives/multi-select/multi-select.component.html +150 -0
- package/packages/angular-renderer/src/components/primitives/multi-select/multi-select.component.scss +240 -0
- package/packages/angular-renderer/src/components/primitives/multi-select/multi-select.component.ts +362 -0
- package/packages/angular-renderer/src/components/primitives/select/select.component.html +92 -14
- package/packages/angular-renderer/src/components/primitives/select/select.component.scss +188 -13
- package/packages/angular-renderer/src/components/primitives/select/select.component.ts +242 -34
- package/packages/angular-renderer/src/components/primitives/select/selection-utils.ts +92 -0
- package/packages/angular-renderer/src/components/primitives/time-picker/time-picker.component.html +65 -0
- package/packages/angular-renderer/src/components/primitives/time-picker/time-picker.component.scss +65 -0
- package/packages/angular-renderer/src/components/primitives/time-picker/time-picker.component.ts +229 -0
- package/packages/angular-renderer/src/index.ts +6 -0
- package/packages/angular-renderer/src/lib/primitives.provider.ts +12 -0
- package/packages/cli/CHANGELOG.md +8 -0
- package/packages/cli/package.json +2 -2
- package/packages/core/CHANGELOG.md +8 -0
- package/packages/core/package.json +1 -1
- package/packages/design-tokens/CHANGELOG.md +8 -0
- package/packages/design-tokens/package.json +1 -1
- package/packages/devtools/CHANGELOG.md +14 -0
- package/packages/devtools/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/packages/devtools/package.json +3 -3
- package/packages/playground/CHANGELOG.md +8 -0
- package/packages/playground/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/packages/playground/package.json +3 -3
- package/dist/packages/playground/browser/main-D2PNGI4C.js +0 -734
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
ViewEncapsulation,
|
|
5
|
+
input,
|
|
6
|
+
model,
|
|
7
|
+
signal,
|
|
8
|
+
computed,
|
|
9
|
+
inject,
|
|
10
|
+
effect,
|
|
11
|
+
untracked,
|
|
12
|
+
HostListener,
|
|
13
|
+
ElementRef,
|
|
14
|
+
} from '@angular/core';
|
|
15
|
+
import { InteractionContract } from '@origostudio/core';
|
|
16
|
+
import { OrigoAdapter } from '../../../adapters/web/adapter';
|
|
17
|
+
import { WebExperienceAdapterService } from '../../../adapters/web/experience-adapter.service';
|
|
18
|
+
|
|
19
|
+
export interface DateRangePickerProps {
|
|
20
|
+
format?: string;
|
|
21
|
+
minDate?: string;
|
|
22
|
+
maxDate?: string;
|
|
23
|
+
showTime?: boolean;
|
|
24
|
+
timezone?: string;
|
|
25
|
+
startDate?: string; // ISO 8601 UTC
|
|
26
|
+
endDate?: string; // ISO 8601 UTC
|
|
27
|
+
'aria-label'?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface CalendarDay {
|
|
31
|
+
date: Date;
|
|
32
|
+
isCurrentMonth: boolean;
|
|
33
|
+
isToday: boolean;
|
|
34
|
+
disabled: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Component({
|
|
38
|
+
selector: 'origo-date-range-picker',
|
|
39
|
+
standalone: true,
|
|
40
|
+
templateUrl: './date-range-picker.component.html',
|
|
41
|
+
styleUrls: ['./date-range-picker.component.scss'],
|
|
42
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
43
|
+
encapsulation: ViewEncapsulation.ShadowDom,
|
|
44
|
+
})
|
|
45
|
+
export class DateRangePickerComponent implements OrigoAdapter<DateRangePickerProps> {
|
|
46
|
+
static readonly contractSchema = {
|
|
47
|
+
format: 'string',
|
|
48
|
+
minDate: 'string',
|
|
49
|
+
maxDate: 'string',
|
|
50
|
+
showTime: 'boolean',
|
|
51
|
+
timezone: 'string',
|
|
52
|
+
startDate: 'string',
|
|
53
|
+
endDate: 'string',
|
|
54
|
+
'aria-label': 'string',
|
|
55
|
+
permissions: 'array',
|
|
56
|
+
rules: 'array',
|
|
57
|
+
metadata: 'object',
|
|
58
|
+
};
|
|
59
|
+
static readonly strictContract = false;
|
|
60
|
+
|
|
61
|
+
contract = input.required<InteractionContract<DateRangePickerProps>>();
|
|
62
|
+
|
|
63
|
+
// DateRangePicker doesn't use a single value model in the same way, but keeping it for adapter compat if needed
|
|
64
|
+
value = model<any>(null);
|
|
65
|
+
|
|
66
|
+
startDate = signal<string | null>(null);
|
|
67
|
+
endDate = signal<string | null>(null);
|
|
68
|
+
|
|
69
|
+
isOpen = signal<boolean>(false);
|
|
70
|
+
currentViewDate = signal<Date>(
|
|
71
|
+
new Date(Date.UTC(new Date().getUTCFullYear(), new Date().getUTCMonth(), 1))
|
|
72
|
+
);
|
|
73
|
+
selectionPhase = signal<'start' | 'end'>('start');
|
|
74
|
+
|
|
75
|
+
private experienceAdapter = inject(WebExperienceAdapterService);
|
|
76
|
+
private elementRef = inject(ElementRef);
|
|
77
|
+
|
|
78
|
+
weekDays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
79
|
+
computedAriaLabel = computed(() => this.contract().props?.['aria-label'] || 'Date Range Picker');
|
|
80
|
+
|
|
81
|
+
displayStartValue = computed(() => this.formatDateStr(this.startDate()));
|
|
82
|
+
displayEndValue = computed(() => this.formatDateStr(this.endDate()));
|
|
83
|
+
|
|
84
|
+
private parseSafeUTC(isoString: string | null | undefined): Date | null {
|
|
85
|
+
if (!isoString || isoString === 'null' || isoString === 'undefined') return null;
|
|
86
|
+
const d = new Date(isoString);
|
|
87
|
+
if (isNaN(d.getTime())) return null;
|
|
88
|
+
return d;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private formatDateStr(val: string | null): string {
|
|
92
|
+
const d = this.parseSafeUTC(val);
|
|
93
|
+
if (!d) return '';
|
|
94
|
+
return `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, '0')}-${String(d.getUTCDate()).padStart(2, '0')}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
constructor() {
|
|
98
|
+
effect(() => {
|
|
99
|
+
const s = this.contract().props?.startDate;
|
|
100
|
+
const e = this.contract().props?.endDate;
|
|
101
|
+
untracked(() => {
|
|
102
|
+
this.startDate.set(s === undefined || s === null ? null : String(s));
|
|
103
|
+
this.endDate.set(e === undefined || e === null ? null : String(e));
|
|
104
|
+
|
|
105
|
+
const dateToView = this.parseSafeUTC(this.startDate()) || new Date();
|
|
106
|
+
this.currentViewDate.set(
|
|
107
|
+
new Date(Date.UTC(dateToView.getUTCFullYear(), dateToView.getUTCMonth(), 1))
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@HostListener('document:mousedown', ['$event'])
|
|
114
|
+
onClickOutside(event: MouseEvent) {
|
|
115
|
+
if (this.isOpen() && !this.elementRef.nativeElement.contains(event.target)) {
|
|
116
|
+
this.cancelSelection();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@HostListener('document:keydown.escape')
|
|
121
|
+
onEscape() {
|
|
122
|
+
if (this.isOpen()) {
|
|
123
|
+
this.cancelSelection();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private cancelSelection() {
|
|
128
|
+
// If we're mid-selection, revert to the contract state
|
|
129
|
+
if (this.selectionPhase() === 'end') {
|
|
130
|
+
const s = this.contract().props?.startDate;
|
|
131
|
+
this.startDate.set(s === undefined || s === null ? null : String(s));
|
|
132
|
+
this.selectionPhase.set('start');
|
|
133
|
+
}
|
|
134
|
+
this.isOpen.set(false);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
toggleCalendar() {
|
|
138
|
+
if (this.isOpen()) {
|
|
139
|
+
this.cancelSelection();
|
|
140
|
+
} else {
|
|
141
|
+
this.isOpen.set(true);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
currentMonthYear = computed(() => {
|
|
146
|
+
const d = this.currentViewDate();
|
|
147
|
+
const months = [
|
|
148
|
+
'January',
|
|
149
|
+
'February',
|
|
150
|
+
'March',
|
|
151
|
+
'April',
|
|
152
|
+
'May',
|
|
153
|
+
'June',
|
|
154
|
+
'July',
|
|
155
|
+
'August',
|
|
156
|
+
'September',
|
|
157
|
+
'October',
|
|
158
|
+
'November',
|
|
159
|
+
'December',
|
|
160
|
+
];
|
|
161
|
+
return `${months[d.getUTCMonth()]} ${d.getUTCFullYear()}`;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
private isDateDisabled(date: Date): boolean {
|
|
165
|
+
const minDateStr = this.contract().props?.minDate;
|
|
166
|
+
const maxDateStr = this.contract().props?.maxDate;
|
|
167
|
+
|
|
168
|
+
if (minDateStr) {
|
|
169
|
+
const minD = this.parseSafeUTC(minDateStr);
|
|
170
|
+
if (minD && date < minD) return true;
|
|
171
|
+
}
|
|
172
|
+
if (maxDateStr) {
|
|
173
|
+
const maxD = this.parseSafeUTC(maxDateStr);
|
|
174
|
+
if (maxD && date > maxD) return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
calendarGrid = computed(() => {
|
|
180
|
+
const viewDate = this.currentViewDate();
|
|
181
|
+
const year = viewDate.getUTCFullYear();
|
|
182
|
+
const month = viewDate.getUTCMonth();
|
|
183
|
+
|
|
184
|
+
const firstDayOfMonth = new Date(Date.UTC(year, month, 1));
|
|
185
|
+
|
|
186
|
+
const startingDayOfWeek = firstDayOfMonth.getUTCDay();
|
|
187
|
+
|
|
188
|
+
const startDateGrid = new Date(firstDayOfMonth);
|
|
189
|
+
startDateGrid.setUTCDate(startDateGrid.getUTCDate() - startingDayOfWeek);
|
|
190
|
+
|
|
191
|
+
const weeks: CalendarDay[][] = [];
|
|
192
|
+
const currentDay = new Date(startDateGrid);
|
|
193
|
+
|
|
194
|
+
const today = new Date();
|
|
195
|
+
|
|
196
|
+
while (weeks.length < 6) {
|
|
197
|
+
if (currentDay.getUTCDay() === 0) {
|
|
198
|
+
weeks.push([]);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
weeks[weeks.length - 1].push({
|
|
202
|
+
date: new Date(currentDay),
|
|
203
|
+
isCurrentMonth: currentDay.getUTCMonth() === month,
|
|
204
|
+
isToday:
|
|
205
|
+
currentDay.getUTCFullYear() === today.getUTCFullYear() &&
|
|
206
|
+
currentDay.getUTCMonth() === today.getUTCMonth() &&
|
|
207
|
+
currentDay.getUTCDate() === today.getUTCDate(),
|
|
208
|
+
disabled: this.isDateDisabled(currentDay),
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
currentDay.setUTCDate(currentDay.getUTCDate() + 1);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return weeks;
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
isSameDate(d1Str: string | null, d2: Date): boolean {
|
|
218
|
+
const d1 = this.parseSafeUTC(d1Str);
|
|
219
|
+
if (!d1) return false;
|
|
220
|
+
return (
|
|
221
|
+
d1.getUTCFullYear() === d2.getUTCFullYear() &&
|
|
222
|
+
d1.getUTCMonth() === d2.getUTCMonth() &&
|
|
223
|
+
d1.getUTCDate() === d2.getUTCDate()
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
isSelected(date: Date): boolean {
|
|
228
|
+
return this.isSameDate(this.startDate(), date) || this.isSameDate(this.endDate(), date);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
isInRange(date: Date): boolean {
|
|
232
|
+
const sDate = this.parseSafeUTC(this.startDate());
|
|
233
|
+
const eDate = this.parseSafeUTC(this.endDate());
|
|
234
|
+
if (!sDate || !eDate) return false;
|
|
235
|
+
|
|
236
|
+
// Normalize to start of UTC day for comparison
|
|
237
|
+
const normDate = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
238
|
+
const normS = Date.UTC(sDate.getUTCFullYear(), sDate.getUTCMonth(), sDate.getUTCDate());
|
|
239
|
+
const normE = Date.UTC(eDate.getUTCFullYear(), eDate.getUTCMonth(), eDate.getUTCDate());
|
|
240
|
+
|
|
241
|
+
return normDate >= Math.min(normS, normE) && normDate <= Math.max(normS, normE);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
onDayClick(date: Date) {
|
|
245
|
+
if (this.isDateDisabled(date)) return;
|
|
246
|
+
|
|
247
|
+
if (this.selectionPhase() === 'start') {
|
|
248
|
+
const iso = date.toISOString();
|
|
249
|
+
this.startDate.set(iso);
|
|
250
|
+
this.endDate.set(null);
|
|
251
|
+
this.selectionPhase.set('end');
|
|
252
|
+
} else {
|
|
253
|
+
let startD = this.parseSafeUTC(this.startDate());
|
|
254
|
+
if (!startD) {
|
|
255
|
+
startD = date;
|
|
256
|
+
}
|
|
257
|
+
let endD = date;
|
|
258
|
+
|
|
259
|
+
if (endD.getTime() < startD.getTime()) {
|
|
260
|
+
const temp = startD;
|
|
261
|
+
startD = endD;
|
|
262
|
+
endD = temp;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
this.selectRange(startD, endD);
|
|
266
|
+
this.selectionPhase.set('start');
|
|
267
|
+
this.isOpen.set(false);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
selectRange(start: Date, end: Date) {
|
|
272
|
+
const s = new Date(
|
|
273
|
+
Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), start.getUTCDate())
|
|
274
|
+
).toISOString();
|
|
275
|
+
const e = new Date(
|
|
276
|
+
Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), end.getUTCDate())
|
|
277
|
+
).toISOString();
|
|
278
|
+
|
|
279
|
+
let actualStart = s;
|
|
280
|
+
let actualEnd = e;
|
|
281
|
+
|
|
282
|
+
if (new Date(e).getTime() < new Date(s).getTime()) {
|
|
283
|
+
actualStart = e;
|
|
284
|
+
actualEnd = s;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
this.startDate.set(actualStart);
|
|
288
|
+
this.endDate.set(actualEnd);
|
|
289
|
+
|
|
290
|
+
this.experienceAdapter.updateState(this.contract().id, 'startDate', actualStart);
|
|
291
|
+
this.experienceAdapter.updateState(this.contract().id, 'endDate', actualEnd);
|
|
292
|
+
|
|
293
|
+
// Also notify if 'value' model binding is used to pass range object
|
|
294
|
+
this.value.set({ startDate: actualStart, endDate: actualEnd });
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
prevMonth() {
|
|
298
|
+
const d = this.currentViewDate();
|
|
299
|
+
this.currentViewDate.set(new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() - 1, 1)));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
nextMonth() {
|
|
303
|
+
const d = this.currentViewDate();
|
|
304
|
+
this.currentViewDate.set(new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 1)));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
onInputKeyDown(event: KeyboardEvent) {
|
|
308
|
+
if (event.key === 'Enter' || event.key === ' ' || event.key === 'ArrowDown') {
|
|
309
|
+
event.preventDefault();
|
|
310
|
+
this.isOpen.set(true);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
onDayKeyDown(event: KeyboardEvent, date: Date) {
|
|
315
|
+
const d = new Date(date);
|
|
316
|
+
let handled = false;
|
|
317
|
+
|
|
318
|
+
switch (event.key) {
|
|
319
|
+
case 'Enter':
|
|
320
|
+
case ' ':
|
|
321
|
+
this.onDayClick(d);
|
|
322
|
+
handled = true;
|
|
323
|
+
break;
|
|
324
|
+
case 'ArrowRight':
|
|
325
|
+
d.setUTCDate(d.getUTCDate() + 1);
|
|
326
|
+
handled = true;
|
|
327
|
+
break;
|
|
328
|
+
case 'ArrowLeft':
|
|
329
|
+
d.setUTCDate(d.getUTCDate() - 1);
|
|
330
|
+
handled = true;
|
|
331
|
+
break;
|
|
332
|
+
case 'ArrowDown':
|
|
333
|
+
d.setUTCDate(d.getUTCDate() + 7);
|
|
334
|
+
handled = true;
|
|
335
|
+
break;
|
|
336
|
+
case 'ArrowUp':
|
|
337
|
+
d.setUTCDate(d.getUTCDate() - 7);
|
|
338
|
+
handled = true;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (handled) {
|
|
343
|
+
event.preventDefault();
|
|
344
|
+
if (
|
|
345
|
+
d.getUTCMonth() !== this.currentViewDate().getUTCMonth() ||
|
|
346
|
+
d.getUTCFullYear() !== this.currentViewDate().getUTCFullYear()
|
|
347
|
+
) {
|
|
348
|
+
this.currentViewDate.set(new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1)));
|
|
349
|
+
}
|
|
350
|
+
setTimeout(() => {
|
|
351
|
+
const id = `day-${d.getUTCFullYear()}-${d.getUTCMonth()}-${d.getUTCDate()}`;
|
|
352
|
+
const el = this.elementRef.nativeElement.shadowRoot?.getElementById(id);
|
|
353
|
+
if (el) el.focus();
|
|
354
|
+
}, 0);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
package/packages/angular-renderer/src/components/primitives/icon-button/icon-button.component.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[disabled]="computedDisabled()"
|
|
4
4
|
[attr.aria-label]="computedAriaLabel()"
|
|
5
5
|
[attr.aria-describedby]="computedAriaDescribedBy()"
|
|
6
|
-
[title]="contract().props
|
|
6
|
+
[title]="contract().props.tooltip || null"
|
|
7
7
|
(click)="onClick()"
|
|
8
8
|
>
|
|
9
9
|
@if (computedLoading()) {
|
package/packages/angular-renderer/src/components/primitives/multi-select/multi-select.component.html
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<div class="origo-multi-select__wrapper">
|
|
2
|
+
<div class="origo-multi-select__control">
|
|
3
|
+
<button
|
|
4
|
+
type="button"
|
|
5
|
+
class="origo-multi-select__trigger"
|
|
6
|
+
[id]="contract().id + '-trigger'"
|
|
7
|
+
role="combobox"
|
|
8
|
+
[attr.aria-expanded]="isOpen()"
|
|
9
|
+
[attr.aria-haspopup]="'listbox'"
|
|
10
|
+
[attr.aria-controls]="isOpen() ? contract().id + '-listbox' : null"
|
|
11
|
+
[attr.aria-activedescendant]="
|
|
12
|
+
isOpen() && activeIndex() >= 0 ? contract().id + '-option-' + activeIndex() : null
|
|
13
|
+
"
|
|
14
|
+
[attr.aria-invalid]="computedInvalid() ? 'true' : null"
|
|
15
|
+
[attr.aria-required]="computedRequired() ? 'true' : null"
|
|
16
|
+
[attr.aria-label]="computedAriaLabel()"
|
|
17
|
+
[attr.aria-describedby]="computedAriaDescribedBy()"
|
|
18
|
+
[disabled]="computedDisabled()"
|
|
19
|
+
(click)="toggleOpen()"
|
|
20
|
+
(keydown)="onKeydown($event)"
|
|
21
|
+
>
|
|
22
|
+
<div class="origo-multi-select__display">
|
|
23
|
+
@if (computedDisplay() === 'chip' && computedSelectedOptions().length > 0) {
|
|
24
|
+
<div class="origo-multi-select__chips">
|
|
25
|
+
@for (opt of computedSelectedOptions(); track opt.value) {
|
|
26
|
+
<span class="origo-multi-select__chip">
|
|
27
|
+
<span class="origo-multi-select__chip-label">{{ opt.label }}</span>
|
|
28
|
+
<span
|
|
29
|
+
class="origo-multi-select__chip-remove"
|
|
30
|
+
role="button"
|
|
31
|
+
tabindex="0"
|
|
32
|
+
aria-label="Remove item"
|
|
33
|
+
(click)="removeOption(opt.value, $event)"
|
|
34
|
+
(keydown.enter)="removeOption(opt.value, $event)"
|
|
35
|
+
>✕</span
|
|
36
|
+
>
|
|
37
|
+
</span>
|
|
38
|
+
}
|
|
39
|
+
</div>
|
|
40
|
+
} @else {
|
|
41
|
+
<span
|
|
42
|
+
class="origo-multi-select__label"
|
|
43
|
+
[class.origo-multi-select__label--placeholder]="!displaySummary()"
|
|
44
|
+
>
|
|
45
|
+
{{ displaySummary() || computedPlaceholder() }}
|
|
46
|
+
</span>
|
|
47
|
+
}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<span class="origo-multi-select__icons">
|
|
51
|
+
@if (
|
|
52
|
+
computedClearable() && value().length > 0 && !computedDisabled() && !computedReadonly()
|
|
53
|
+
) {
|
|
54
|
+
<span
|
|
55
|
+
class="origo-multi-select__clear"
|
|
56
|
+
role="button"
|
|
57
|
+
tabindex="0"
|
|
58
|
+
aria-label="Clear selection"
|
|
59
|
+
(click)="clear($event)"
|
|
60
|
+
(keydown.enter)="clear($event)"
|
|
61
|
+
>✕</span
|
|
62
|
+
>
|
|
63
|
+
}
|
|
64
|
+
<span class="origo-multi-select__arrow" aria-hidden="true">▼</span>
|
|
65
|
+
</span>
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
@if (isOpen()) {
|
|
70
|
+
<div
|
|
71
|
+
class="origo-multi-select__dropdown"
|
|
72
|
+
[id]="contract().id + '-listbox'"
|
|
73
|
+
role="listbox"
|
|
74
|
+
aria-multiselectable="true"
|
|
75
|
+
[attr.aria-label]="computedAriaLabel()"
|
|
76
|
+
>
|
|
77
|
+
@if (computedFilter()) {
|
|
78
|
+
<div class="origo-select__filter-container">
|
|
79
|
+
<input
|
|
80
|
+
type="text"
|
|
81
|
+
class="origo-multi-select__filter-input"
|
|
82
|
+
[placeholder]="computedFilterPlaceholder()"
|
|
83
|
+
[value]="filterQuery()"
|
|
84
|
+
(input)="onFilterInput($event)"
|
|
85
|
+
(keydown)="onKeydown($event)"
|
|
86
|
+
aria-label="Filter options"
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@if (computedShowToggleAll()) {
|
|
92
|
+
<div
|
|
93
|
+
class="origo-multi-select__toggle-all"
|
|
94
|
+
role="button"
|
|
95
|
+
tabindex="0"
|
|
96
|
+
(click)="toggleAll()"
|
|
97
|
+
(keydown.enter)="toggleAll()"
|
|
98
|
+
>
|
|
99
|
+
<input
|
|
100
|
+
type="checkbox"
|
|
101
|
+
class="origo-multi-select__checkbox"
|
|
102
|
+
[checked]="isAllSelected()"
|
|
103
|
+
tabindex="-1"
|
|
104
|
+
aria-hidden="true"
|
|
105
|
+
/>
|
|
106
|
+
<span>Toggle All</span>
|
|
107
|
+
</div>
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
<ul class="origo-multi-select__options">
|
|
111
|
+
@for (opt of filteredOptions(); track opt.value; let idx = $index) {
|
|
112
|
+
<li
|
|
113
|
+
class="origo-multi-select__option"
|
|
114
|
+
[class.origo-multi-select__option--selected]="isSelected(opt)"
|
|
115
|
+
[class.origo-multi-select__option--active]="activeIndex() === idx"
|
|
116
|
+
[class.origo-multi-select__option--disabled]="opt.disabled"
|
|
117
|
+
[id]="contract().id + '-option-' + idx"
|
|
118
|
+
role="option"
|
|
119
|
+
[attr.aria-selected]="isSelected(opt)"
|
|
120
|
+
[attr.aria-disabled]="opt.disabled ? 'true' : null"
|
|
121
|
+
(click)="!opt.disabled && toggleOption(opt.value)"
|
|
122
|
+
>
|
|
123
|
+
<input
|
|
124
|
+
type="checkbox"
|
|
125
|
+
class="origo-multi-select__checkbox"
|
|
126
|
+
[checked]="isSelected(opt)"
|
|
127
|
+
[disabled]="opt.disabled"
|
|
128
|
+
tabindex="-1"
|
|
129
|
+
aria-hidden="true"
|
|
130
|
+
/>
|
|
131
|
+
<span>{{ opt.label }}</span>
|
|
132
|
+
</li>
|
|
133
|
+
} @empty {
|
|
134
|
+
<li class="origo-multi-select__no-options" role="presentation">No options found</li>
|
|
135
|
+
}
|
|
136
|
+
</ul>
|
|
137
|
+
</div>
|
|
138
|
+
}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
@if (computedErrorText()) {
|
|
142
|
+
<div class="origo-multi-select__error" [id]="contract().id + '-error'">
|
|
143
|
+
{{ computedErrorText() }}
|
|
144
|
+
</div>
|
|
145
|
+
}
|
|
146
|
+
@if (computedHelpText()) {
|
|
147
|
+
<div class="origo-multi-select__help" [id]="contract().id + '-help'">
|
|
148
|
+
{{ computedHelpText() }}
|
|
149
|
+
</div>
|
|
150
|
+
}
|