@widgetic/editor 4.1.13 → 4.1.15
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/dist/components/PreviewChromeControls.svelte +15 -21
- package/dist/components/WidgetPreview.svelte +136 -105
- package/dist/components/color-select/ColorSelect.svelte +203 -224
- package/dist/components/color-select/constants.d.ts +4 -2
- package/dist/components/color-select/constants.js +4 -2
- package/dist/components/color-select/render.js +10 -9
- package/dist/components/editors/CompositionEditorApp.svelte +55 -40
- package/dist/components/editors/EditLeaseNotice.svelte +44 -33
- package/dist/components/editors/EmbedEditor.svelte +133 -259
- package/dist/components/editors/PropsEditor.svelte +426 -1333
- package/dist/components/editors/props-editor.css +5 -68
- package/dist/components/ic/AngleInputController.svelte +202 -277
- package/dist/components/ic/BrowserInputController.svelte +813 -803
- package/dist/components/ic/CheckboxInputController.svelte +92 -169
- package/dist/components/ic/CheckboxInputController.svelte.d.ts +2 -8
- package/dist/components/ic/ColorPickerInputController.svelte +1589 -1587
- package/dist/components/ic/ColorPickerInputController.svelte.d.ts +3 -3
- package/dist/components/ic/DateFieldInputController.svelte +455 -465
- package/dist/components/ic/DatePickerInputController.svelte +355 -368
- package/dist/components/ic/DatePickerInputController.svelte.d.ts +1 -1
- package/dist/components/ic/DropdownInputController.svelte +130 -200
- package/dist/components/ic/FixedPositionInputController.svelte +255 -276
- package/dist/components/ic/FixedPositionInputController.svelte.d.ts +5 -1
- package/dist/components/ic/FontInputController.svelte +2110 -2231
- package/dist/components/ic/FontInputController.svelte.d.ts +11 -11
- package/dist/components/ic/InputControllerHeader.svelte +141 -147
- package/dist/components/ic/InputControllerRenderer.svelte +5 -1
- package/dist/components/ic/InputControllerRenderer.svelte.d.ts +2 -1
- package/dist/components/ic/InputControllerRow.svelte +74 -0
- package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +401 -0
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte.d.ts +11 -0
- package/dist/components/ic/KnowledgeTextForm.svelte +109 -0
- package/dist/components/ic/KnowledgeTextForm.svelte.d.ts +15 -0
- package/dist/components/ic/NumberControls.svelte +303 -269
- package/dist/components/ic/NumberControls.svelte.d.ts +4 -1
- package/dist/components/ic/NumberInputController.svelte +361 -301
- package/dist/components/ic/NumberInputController.svelte.d.ts +2 -0
- package/dist/components/ic/PositionInputController.svelte +253 -176
- package/dist/components/ic/PositionInputController.svelte.d.ts +2 -0
- package/dist/components/ic/RadioGroupInputController.svelte +71 -137
- package/dist/components/ic/RadioGroupInputController.svelte.d.ts +2 -8
- package/dist/components/ic/RangeCalendarInputController.svelte +233 -270
- package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +2 -2
- package/dist/components/ic/RoundedCornersInputController.svelte +412 -435
- package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +2 -0
- package/dist/components/ic/SliderInputController.svelte +263 -332
- package/dist/components/ic/SliderInputController.svelte.d.ts +1 -1
- package/dist/components/ic/SliderRangeInputController.svelte +140 -144
- package/dist/components/ic/SliderRangeInputController.svelte.d.ts +3 -3
- package/dist/components/ic/SwitchInputController.svelte +47 -109
- package/dist/components/ic/TagsInputController.svelte +95 -110
- package/dist/components/ic/TextAreaInputController.svelte +1794 -1935
- package/dist/components/ic/TextAreaPreviewInputController.svelte +436 -438
- package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +2 -2
- package/dist/components/ic/TextInputController.svelte +65 -75
- package/dist/components/ic/TextInputController.svelte.d.ts +2 -0
- package/dist/components/ic/TimeInputController.svelte +433 -431
- package/dist/components/ic/VectorInputController.svelte +1833 -1831
- package/dist/components/ic/VectorInputController.svelte.d.ts +10 -10
- package/dist/components/ic/index.d.ts +2 -0
- package/dist/components/ic/index.js +2 -0
- package/dist/components/ic/shared/CategoryTabs.svelte +28 -35
- package/dist/components/ic/shared/ItemGrid.svelte +145 -179
- package/dist/components/ic/shared/RecentItemsSection.svelte +208 -271
- package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte +23 -38
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte.d.ts +1 -4
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +45 -0
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte.d.ts +26 -0
- package/dist/components/ui/checkerboard-background/CheckerboardBackground.svelte +20 -12
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte +39 -0
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte.d.ts +10 -0
- package/dist/composition/compositionApi.d.ts +21 -1
- package/dist/composition/compositionApi.js +64 -5
- package/dist/composition/knowledgeDocuments.d.ts +90 -0
- package/dist/composition/knowledgeDocuments.js +94 -0
- package/dist/composition/knowledgeDocumentsPanel.d.ts +152 -0
- package/dist/composition/knowledgeDocumentsPanel.js +443 -0
- package/dist/i18n/language.d.ts +86 -36
- package/dist/i18n/messages.d.ts +97 -34
- package/dist/i18n/messages.js +104 -34
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/knowledgeDocumentsContext.d.ts +10 -0
- package/dist/knowledgeDocumentsContext.js +31 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +26 -2
- package/package.json +4 -4
|
@@ -18,380 +18,367 @@
|
|
|
18
18
|
-->
|
|
19
19
|
|
|
20
20
|
<script module lang="ts">
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
import type { Writable } from 'svelte/store';
|
|
22
|
+
|
|
23
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
24
|
+
* interface cannot drift from what the component actually reads. */
|
|
25
|
+
export interface DatePickerInputControllerProps {
|
|
26
|
+
label: string;
|
|
27
|
+
value?: any;
|
|
28
|
+
onChange: (newValue: CalendarDate) => void;
|
|
29
|
+
description?: string;
|
|
30
|
+
controllerId: string;
|
|
31
|
+
openDropdowns: Writable<Set<string>>;
|
|
32
|
+
toggleDropdown: (id: string) => void;
|
|
33
|
+
onFocus?: () => void;
|
|
34
|
+
}
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
37
|
<script lang="ts">
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
38
|
+
// Svelte imports
|
|
39
|
+
import { onMount, onDestroy } from 'svelte';
|
|
40
|
+
import { listenForScroll } from '../../utils/shadowDom';
|
|
41
|
+
import { useEditorLanguage } from '../../i18n/language';
|
|
42
|
+
import type { EditorMessageKey } from '../../i18n/messages';
|
|
43
|
+
import type { Translate } from '@widgetic/design-system/i18n';
|
|
44
|
+
|
|
45
|
+
// The words of the editor in the language of the page, and the language itself (how a month and a date are written).
|
|
46
|
+
const { t, locale } = useEditorLanguage();
|
|
47
|
+
|
|
48
|
+
// Shadcn UI Components
|
|
49
|
+
import { Select } from '@widgetic/design-system/components';
|
|
50
|
+
import { Popover } from '@widgetic/design-system/components';
|
|
51
|
+
import InputControllerRow from './InputControllerRow.svelte';
|
|
52
|
+
import { Calendar } from '@widgetic/design-system/components';
|
|
53
|
+
|
|
54
|
+
// Internationalized date imports
|
|
55
|
+
import { CalendarDate, getLocalTimeZone, today, DateFormatter } from '@internationalized/date';
|
|
56
|
+
import type { DateValue } from '@internationalized/date';
|
|
57
|
+
|
|
58
|
+
// Lucide Icons
|
|
59
|
+
import { IconCalendar } from '@widgetic/design-system/icons';
|
|
60
|
+
import EditorCalendarStyles from '../ui/calendar-editor-fit/EditorCalendarStyles.svelte';
|
|
61
|
+
|
|
62
|
+
// Component props with TypeScript types
|
|
63
|
+
export let label: DatePickerInputControllerProps['label'];
|
|
64
|
+
export let value: DatePickerInputControllerProps['value'];
|
|
65
|
+
export let onChange: DatePickerInputControllerProps['onChange'];
|
|
66
|
+
export let description: DatePickerInputControllerProps['description'] = undefined;
|
|
67
|
+
export let controllerId: DatePickerInputControllerProps['controllerId'];
|
|
68
|
+
export let openDropdowns: DatePickerInputControllerProps['openDropdowns'];
|
|
69
|
+
export let toggleDropdown: DatePickerInputControllerProps['toggleDropdown'];
|
|
70
|
+
export let onFocus: DatePickerInputControllerProps['onFocus'] = () => {};
|
|
71
|
+
|
|
72
|
+
// Default to today's date in local timezone for placeholder
|
|
73
|
+
let placeholder = today(getLocalTimeZone());
|
|
74
|
+
let currentValue: CalendarDate | undefined;
|
|
75
|
+
|
|
76
|
+
// Month and year options setup: the names of the months are written by the language of the page
|
|
77
|
+
$: monthFmt = new DateFormatter($locale, { month: 'long' });
|
|
78
|
+
$: monthOptions = Array.from({ length: 12 }, (_, monthIndex) => ({
|
|
79
|
+
value: String(monthIndex + 1),
|
|
80
|
+
label: monthFmt.format(new Date(2021, monthIndex, 1))
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
const yearOptions = Array.from({ length: 100 }, (_, i) => {
|
|
84
|
+
const year = String(new Date().getFullYear() - i);
|
|
85
|
+
return { label: year, value: year };
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
$: defaultYear = placeholder
|
|
89
|
+
? {
|
|
90
|
+
value: String(placeholder.year),
|
|
91
|
+
label: String(placeholder.year)
|
|
92
|
+
}
|
|
93
|
+
: undefined;
|
|
94
|
+
|
|
95
|
+
$: defaultMonth = placeholder
|
|
96
|
+
? {
|
|
97
|
+
value: String(placeholder.month),
|
|
98
|
+
label: monthFmt.format(placeholder.toDate(getLocalTimeZone()))
|
|
99
|
+
}
|
|
100
|
+
: undefined;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Updates the current value when the external value changes
|
|
104
|
+
* Handles initialization and updates of the date state
|
|
105
|
+
* Creates a new CalendarDate instance to prevent reference issues
|
|
106
|
+
*/
|
|
107
|
+
function updateCurrentValue() {
|
|
108
|
+
// console.log('🔄 [DatePicker] updateCurrentValue called with:', { value, type: typeof value });
|
|
109
|
+
|
|
110
|
+
if (!value) {
|
|
111
|
+
currentValue = undefined;
|
|
112
|
+
placeholder = today(getLocalTimeZone());
|
|
113
|
+
// console.log('✅ [DatePicker] Set to undefined, placeholder:', placeholder);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (value instanceof CalendarDate) {
|
|
118
|
+
currentValue = value;
|
|
119
|
+
// console.log('✅ [DatePicker] Already CalendarDate:', currentValue);
|
|
120
|
+
} else if (
|
|
121
|
+
typeof value === 'object' &&
|
|
122
|
+
value !== null &&
|
|
123
|
+
'year' in value &&
|
|
124
|
+
'month' in value &&
|
|
125
|
+
'day' in value
|
|
126
|
+
) {
|
|
127
|
+
try {
|
|
128
|
+
currentValue = new CalendarDate(value.year, value.month, value.day);
|
|
129
|
+
// console.log('✅ [DatePicker] Created CalendarDate from object:', { original: value, created: currentValue });
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.error('❌ [DatePicker] Failed to create CalendarDate from object:', {
|
|
132
|
+
value,
|
|
133
|
+
error
|
|
134
|
+
});
|
|
135
|
+
currentValue = undefined;
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
console.warn('⚠️ [DatePicker] Invalid date value provided:', value);
|
|
139
|
+
currentValue = undefined;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
placeholder = currentValue ?? today(getLocalTimeZone());
|
|
143
|
+
// console.log('🎯 [DatePicker] Final state:', { currentValue, placeholder });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Watch for value changes and update internal state
|
|
147
|
+
$: (value, updateCurrentValue());
|
|
148
|
+
|
|
149
|
+
// Track dropdown state through store subscription
|
|
150
|
+
$: open = $openDropdowns?.has(controllerId) || false;
|
|
151
|
+
|
|
152
|
+
// Computed values for Calendar component with extra safety
|
|
153
|
+
$: calendarValue = currentValue;
|
|
154
|
+
$: calendarDefaultMonth = placeholder;
|
|
155
|
+
$: isCalendarReady = placeholder instanceof CalendarDate;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Formats a CalendarDate for display
|
|
159
|
+
* Handles undefined dates and invalid objects
|
|
160
|
+
* Returns a user-friendly date string
|
|
161
|
+
* @param date - The date to format
|
|
162
|
+
* @returns Formatted date string
|
|
163
|
+
*/
|
|
164
|
+
function formatDate(
|
|
165
|
+
date: CalendarDate | undefined,
|
|
166
|
+
languageTag: string,
|
|
167
|
+
translate: Translate<EditorMessageKey>
|
|
168
|
+
): string {
|
|
169
|
+
if (!date || !(date instanceof CalendarDate)) return translate('editor.date.pick');
|
|
170
|
+
try {
|
|
171
|
+
// Convert to JavaScript Date for localized formatting
|
|
172
|
+
const jsDate = new Date(date.year, date.month - 1, date.day);
|
|
173
|
+
return jsDate.toLocaleDateString(languageTag, { dateStyle: 'long' });
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.error('Error formatting date:', error);
|
|
176
|
+
return translate('editor.date.pick');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Handles date selection from the calendar
|
|
182
|
+
* Validates the selected date and updates state
|
|
183
|
+
* Closes the dropdown after selection
|
|
184
|
+
* @param newValue - The newly selected date
|
|
185
|
+
*/
|
|
186
|
+
function handleSelect(newValue: DateValue | undefined) {
|
|
187
|
+
if (newValue instanceof CalendarDate) {
|
|
188
|
+
onChange(newValue);
|
|
189
|
+
toggleDropdown(controllerId);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Toggles the date picker dropdown visibility
|
|
195
|
+
* Manages dropdown state through the provided toggle function
|
|
196
|
+
*/
|
|
197
|
+
function handleToggle() {
|
|
198
|
+
toggleDropdown(controllerId);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Closes the dropdown if it's currently open
|
|
203
|
+
* Used for cleanup and external close triggers
|
|
204
|
+
*/
|
|
205
|
+
function closeDropdown() {
|
|
206
|
+
if (open) {
|
|
207
|
+
toggleDropdown(controllerId);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Handles scroll events to prevent UI issues
|
|
213
|
+
* Closes the dropdown when scrolling occurs outside the dropdowns
|
|
214
|
+
*/
|
|
215
|
+
function handleScroll(event: Event) {
|
|
216
|
+
// Ensure target is an HTMLElement
|
|
217
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const target = event.target;
|
|
222
|
+
|
|
223
|
+
// Check if scroll happened inside our dropdowns
|
|
224
|
+
const isInsideDropdown = target.closest('.month-year-dropdown-content');
|
|
225
|
+
|
|
226
|
+
// If scrolling is inside our dropdowns, don't close
|
|
227
|
+
if (isInsideDropdown) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// If scrolling outside our dropdowns, close
|
|
232
|
+
if (open) {
|
|
233
|
+
closeDropdown();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// The control's own element, which says which tree (the page or a module's shadow root) to listen for scrolling in
|
|
238
|
+
let controllerElement: HTMLDivElement | undefined;
|
|
239
|
+
let stopListeningForScroll: () => void = () => {};
|
|
240
|
+
|
|
241
|
+
// Setup scroll event listener on mount (the page and, inside a module, the module's own panels: a scroll never
|
|
242
|
+
// leaves a shadow root, so a listener on the window alone does not hear about those)
|
|
243
|
+
onMount(() => {
|
|
244
|
+
stopListeningForScroll = listenForScroll(controllerElement, handleScroll);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// Cleanup scroll event listener on destroy
|
|
248
|
+
onDestroy(() => {
|
|
249
|
+
stopListeningForScroll();
|
|
250
|
+
});
|
|
233
251
|
</script>
|
|
234
252
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
</div>
|
|
360
|
-
</div>
|
|
361
|
-
|
|
362
|
-
{#if description}
|
|
363
|
-
<p class="subtext text-grey5">{description}</p>
|
|
364
|
-
{/if}
|
|
253
|
+
<EditorCalendarStyles />
|
|
254
|
+
|
|
255
|
+
<!-- Date Picker Container (Figma IC Date Picker 172:399 + Calendar 210:3967) -->
|
|
256
|
+
<div bind:this={controllerElement} class="date-picker-input-controller">
|
|
257
|
+
<InputControllerRow {label} {description}>
|
|
258
|
+
<Popover.Root {open} onOpenChange={handleToggle}>
|
|
259
|
+
<Popover.Trigger
|
|
260
|
+
class="date-picker-trigger group flex h-9 w-full items-center gap-2 rounded-lg bg-accent pe-2 ps-3 transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
261
|
+
onfocusin={onFocus}
|
|
262
|
+
>
|
|
263
|
+
<span
|
|
264
|
+
class="min-w-0 flex-1 truncate text-start text-body {currentValue
|
|
265
|
+
? 'text-foreground'
|
|
266
|
+
: 'text-muted-foreground'}"
|
|
267
|
+
>
|
|
268
|
+
{formatDate(currentValue, $locale, $t)}
|
|
269
|
+
</span>
|
|
270
|
+
<IconCalendar
|
|
271
|
+
class="size-4 shrink-0 stroke-[1.333] text-muted-foreground transition-colors duration-fast group-hover:text-foreground"
|
|
272
|
+
aria-hidden="true"
|
|
273
|
+
/>
|
|
274
|
+
</Popover.Trigger>
|
|
275
|
+
|
|
276
|
+
<Popover.Content
|
|
277
|
+
class="date-picker-popover z-50 w-[248px] border border-border p-3 shadow-none"
|
|
278
|
+
align="end"
|
|
279
|
+
sideOffset={8}
|
|
280
|
+
>
|
|
281
|
+
<div class="flex w-full flex-col gap-3">
|
|
282
|
+
<div class="flex w-full items-center gap-2">
|
|
283
|
+
<Select.Root
|
|
284
|
+
type="single"
|
|
285
|
+
value={defaultMonth?.value}
|
|
286
|
+
onValueChange={(value: string) => {
|
|
287
|
+
if (!value || !placeholder) return;
|
|
288
|
+
const monthValue = parseInt(value, 10);
|
|
289
|
+
if (monthValue === placeholder?.month) return;
|
|
290
|
+
// Re-create placeholder/currValue using explicit CalendarDate constructor to ensure
|
|
291
|
+
// we pass a plain CalendarDate instance that the Calendar component can recognise.
|
|
292
|
+
placeholder = new CalendarDate(placeholder.year, monthValue, placeholder.day);
|
|
293
|
+
if (currentValue) {
|
|
294
|
+
const newValue = new CalendarDate(
|
|
295
|
+
currentValue.year,
|
|
296
|
+
monthValue,
|
|
297
|
+
currentValue.day
|
|
298
|
+
);
|
|
299
|
+
currentValue = newValue;
|
|
300
|
+
onChange(newValue);
|
|
301
|
+
}
|
|
302
|
+
}}
|
|
303
|
+
>
|
|
304
|
+
<Select.Trigger
|
|
305
|
+
aria-label={$t('editor.date.selectMonth')}
|
|
306
|
+
class="month-year-dropdown-content h-9 min-w-0 flex-[1.5] rounded-lg bg-accent px-3 text-body hover:bg-accent-hover"
|
|
307
|
+
>
|
|
308
|
+
<span class="truncate">{defaultMonth?.label || $t('editor.date.selectMonth')}</span>
|
|
309
|
+
</Select.Trigger>
|
|
310
|
+
<Select.Content class="month-year-dropdown-content max-h-[200px] overflow-y-auto">
|
|
311
|
+
{#each monthOptions as { value, label }}
|
|
312
|
+
<Select.Item {value} {label}>
|
|
313
|
+
{label}
|
|
314
|
+
</Select.Item>
|
|
315
|
+
{/each}
|
|
316
|
+
</Select.Content>
|
|
317
|
+
</Select.Root>
|
|
318
|
+
<Select.Root
|
|
319
|
+
type="single"
|
|
320
|
+
value={defaultYear?.value}
|
|
321
|
+
onValueChange={(value: string) => {
|
|
322
|
+
if (!value || !placeholder) return;
|
|
323
|
+
const yearValue = parseInt(value, 10);
|
|
324
|
+
if (yearValue === placeholder?.year) return;
|
|
325
|
+
// Same fix as above – ensure a clean CalendarDate instance.
|
|
326
|
+
placeholder = new CalendarDate(yearValue, placeholder.month, placeholder.day);
|
|
327
|
+
if (currentValue) {
|
|
328
|
+
const newValue = new CalendarDate(
|
|
329
|
+
yearValue,
|
|
330
|
+
currentValue.month,
|
|
331
|
+
currentValue.day
|
|
332
|
+
);
|
|
333
|
+
currentValue = newValue;
|
|
334
|
+
onChange(newValue);
|
|
335
|
+
}
|
|
336
|
+
}}
|
|
337
|
+
>
|
|
338
|
+
<Select.Trigger
|
|
339
|
+
aria-label={$t('editor.date.selectYear')}
|
|
340
|
+
class="month-year-dropdown-content h-9 min-w-0 flex-1 rounded-lg bg-accent px-3 text-body hover:bg-accent-hover"
|
|
341
|
+
>
|
|
342
|
+
<span class="truncate">{defaultYear?.label || $t('editor.date.selectYear')}</span>
|
|
343
|
+
</Select.Trigger>
|
|
344
|
+
<Select.Content class="month-year-dropdown-content max-h-[200px] overflow-y-auto">
|
|
345
|
+
{#each yearOptions as { value, label }}
|
|
346
|
+
<Select.Item {value} {label}>
|
|
347
|
+
{label}
|
|
348
|
+
</Select.Item>
|
|
349
|
+
{/each}
|
|
350
|
+
</Select.Content>
|
|
351
|
+
</Select.Root>
|
|
352
|
+
</div>
|
|
353
|
+
<!-- Style the calendar content -->
|
|
354
|
+
<div class="calendar-no-header">
|
|
355
|
+
<Calendar
|
|
356
|
+
mode="single"
|
|
357
|
+
locale={$locale}
|
|
358
|
+
calendarLabel={$t('editor.date.calendarLabel')}
|
|
359
|
+
previousLabel={$t('editor.date.previousMonth')}
|
|
360
|
+
nextLabel={$t('editor.date.nextMonth')}
|
|
361
|
+
onValueChange={(date: DateValue | undefined) => {
|
|
362
|
+
if (date instanceof CalendarDate) {
|
|
363
|
+
currentValue = date;
|
|
364
|
+
placeholder = date;
|
|
365
|
+
onChange(date);
|
|
366
|
+
closeDropdown();
|
|
367
|
+
}
|
|
368
|
+
}}
|
|
369
|
+
fixedWeeks
|
|
370
|
+
class="calendar-editor-fit p-0"
|
|
371
|
+
/>
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
</Popover.Content>
|
|
375
|
+
</Popover.Root>
|
|
376
|
+
</InputControllerRow>
|
|
365
377
|
</div>
|
|
366
378
|
|
|
367
379
|
<style>
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/* Style the calendar content */
|
|
375
|
-
:global(.calendar-content) {
|
|
376
|
-
border: 1px solid hsl(var(--grey2)) !important;
|
|
377
|
-
background: white !important;
|
|
378
|
-
border-radius: var(--radius) !important;
|
|
379
|
-
margin-top: 4px !important;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/* Remove button styles */
|
|
383
|
-
:global(button.bg-transparent) {
|
|
384
|
-
outline: none !important;
|
|
385
|
-
box-shadow: none !important;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
:global(button.bg-transparent:hover),
|
|
389
|
-
:global(button.bg-transparent:focus) {
|
|
390
|
-
background-color: transparent !important;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/* Hide calendar header */
|
|
394
|
-
:global(.calendar-no-header header) {
|
|
395
|
-
display: none !important;
|
|
396
|
-
}
|
|
380
|
+
/* Hide calendar header (month nav lives in the dropdown row above) */
|
|
381
|
+
:global(.calendar-no-header header) {
|
|
382
|
+
display: none !important;
|
|
383
|
+
}
|
|
397
384
|
</style>
|