@widgetic/editor 4.1.18 → 4.1.20
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/WidgetPreview.svelte +77 -14
- package/dist/components/editors/CompositionEditorApp.svelte +71 -35
- package/dist/components/editors/CompositionEditorApp.svelte.d.ts +3 -1
- package/dist/components/editors/ContentTabBulkDrop.svelte +268 -0
- package/dist/components/editors/ContentTabBulkDrop.svelte.d.ts +37 -0
- package/dist/components/editors/EmbedAssistantPanel.svelte +303 -0
- package/dist/components/editors/EmbedAssistantPanel.svelte.d.ts +29 -0
- package/dist/components/editors/EmbedEditor.svelte +221 -15
- package/dist/components/editors/EmbedEditor.svelte.d.ts +31 -3
- package/dist/components/editors/PropsEditor.svelte +223 -30
- package/dist/components/editors/PropsEditor.svelte.d.ts +11 -0
- package/dist/components/editors/propsEditorContentStateFlatten.d.ts +12 -0
- package/dist/components/editors/propsEditorContentStateFlatten.js +40 -0
- package/dist/components/ic/BrowserInputController.svelte +184 -21
- package/dist/components/ic/BrowserInputController.svelte.d.ts +2 -0
- package/dist/components/ic/CheckboxInputController.svelte +11 -0
- package/dist/components/ic/ColorPickerInputController.svelte +2 -1
- package/dist/components/ic/DatePickerInputController.svelte +5 -3
- package/dist/components/ic/FontInputController.svelte +9 -4
- package/dist/components/ic/InputControllerHeader.svelte +4 -3
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +13 -0
- package/dist/components/ic/NumberControls.svelte +140 -17
- package/dist/components/ic/RadioGroupInputController.svelte +11 -0
- package/dist/components/ic/RangeCalendarInputController.svelte +38 -13
- package/dist/components/ic/TextAreaInputController.svelte +593 -321
- package/dist/components/ic/TextAreaPreviewInputController.svelte +46 -58
- package/dist/components/ic/VectorInputController.svelte +0 -1
- package/dist/components/ic/numberControlsValueArea.d.ts +29 -0
- package/dist/components/ic/numberControlsValueArea.js +51 -0
- package/dist/components/ic/optionGroupCardPointerDown.d.ts +9 -0
- package/dist/components/ic/optionGroupCardPointerDown.js +20 -0
- package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte +48 -6
- package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte.d.ts +4 -1
- package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte +34 -0
- package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte.d.ts +24 -0
- package/dist/components/ic/shared/fileBrowserOverlayEscape.d.ts +29 -0
- package/dist/components/ic/shared/fileBrowserOverlayEscape.js +21 -0
- package/dist/composition/compositionApi.d.ts +16 -0
- package/dist/composition/compositionApi.js +16 -1
- package/dist/composition/compositionEditorController.d.ts +46 -0
- package/dist/composition/compositionEditorController.js +277 -5
- package/dist/composition/compositionEditorSchemaCache.d.ts +35 -0
- package/dist/composition/compositionEditorSchemaCache.js +82 -0
- package/dist/contentBulkDrop/applyContentPlan.d.ts +18 -0
- package/dist/contentBulkDrop/applyContentPlan.js +55 -0
- package/dist/contentBulkDrop/bulkDropSummary.d.ts +4 -0
- package/dist/contentBulkDrop/bulkDropSummary.js +12 -0
- package/dist/contentBulkDrop/dragIntent.d.ts +7 -0
- package/dist/contentBulkDrop/dragIntent.js +24 -0
- package/dist/contentBulkDrop/filterDropFiles.d.ts +2 -0
- package/dist/contentBulkDrop/filterDropFiles.js +21 -0
- package/dist/contentBulkDrop/formatFileSize.d.ts +2 -0
- package/dist/contentBulkDrop/formatFileSize.js +13 -0
- package/dist/contentBulkDrop/types.d.ts +34 -0
- package/dist/contentBulkDrop/types.js +1 -0
- package/dist/contentBulkDrop/uploadQueue.d.ts +41 -0
- package/dist/contentBulkDrop/uploadQueue.js +114 -0
- package/dist/drafts/compositionDraft.d.ts +65 -0
- package/dist/drafts/compositionDraft.js +136 -0
- package/dist/drafts/compositionEditorViewState.d.ts +9 -0
- package/dist/drafts/compositionEditorViewState.js +33 -0
- package/dist/drafts/draftJournal.d.ts +59 -0
- package/dist/drafts/draftJournal.js +261 -0
- package/dist/embed/__fixtures__/gatewayGeneratedEmbedCodes.json +25 -0
- package/dist/embed/__fixtures__/generatedEmbedCodes.json +320 -0
- package/dist/embed/embedSchema.json +409 -0
- package/dist/embed/parseCompositionEmbedCode.d.ts +21 -0
- package/dist/embed/parseCompositionEmbedCode.js +379 -0
- package/dist/embedAssistant/embedAssistantEvents.d.ts +22 -0
- package/dist/embedAssistant/embedAssistantEvents.js +39 -0
- package/dist/embedAssistant/embedAssistantStream.d.ts +30 -0
- package/dist/embedAssistant/embedAssistantStream.js +125 -0
- package/dist/embedAssistant/highlightTiming.d.ts +1 -0
- package/dist/embedAssistant/highlightTiming.js +6 -0
- package/dist/embedAssistant/types.d.ts +27 -0
- package/dist/embedAssistant/types.js +1 -0
- package/dist/i18n/labels.js +8 -4
- package/dist/i18n/language.d.ts +38 -2
- package/dist/i18n/messages.d.ts +38 -1
- package/dist/i18n/messages.js +40 -1
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/utils/FontManager.d.ts +2 -0
- package/dist/utils/FontManager.js +16 -1
- package/dist/utils/isEditableEventTarget.d.ts +5 -0
- package/dist/utils/isEditableEventTarget.js +25 -0
- package/dist/utils/linkUrlValidation.d.ts +17 -0
- package/dist/utils/linkUrlValidation.js +120 -0
- package/dist/utils/mediaFileValue.d.ts +12 -0
- package/dist/utils/mediaFileValue.js +24 -0
- package/dist/utils/placeRichTextCaretAtDocumentEnd.d.ts +11 -0
- package/dist/utils/placeRichTextCaretAtDocumentEnd.js +26 -0
- package/package.json +7 -7
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
import { Input, StepperButton } from '@widgetic/design-system/components';
|
|
4
4
|
import { useEditorLanguage } from '../../i18n/language';
|
|
5
5
|
import { steppedNumber } from './numberControlsSteps';
|
|
6
|
+
import {
|
|
7
|
+
shouldRoutePointerToNumberInput,
|
|
8
|
+
selectionAfterValueAreaPress,
|
|
9
|
+
isPointerPastTextEnd,
|
|
10
|
+
selectionWhileDraggingFromValueChrome
|
|
11
|
+
} from './numberControlsValueArea';
|
|
6
12
|
|
|
7
13
|
const { t } = useEditorLanguage();
|
|
8
14
|
|
|
@@ -38,11 +44,28 @@
|
|
|
38
44
|
let autoRepeatTimer: ReturnType<typeof setTimeout> | null = null;
|
|
39
45
|
let autoRepeatInterval: ReturnType<typeof setInterval> | null = null;
|
|
40
46
|
|
|
47
|
+
let numberInputEl: HTMLInputElement | null = null;
|
|
48
|
+
let valueAreaDragActive = false;
|
|
49
|
+
|
|
50
|
+
function measureTextWidth(text: string, font: string): number {
|
|
51
|
+
if (typeof document === 'undefined') return text.length * 8;
|
|
52
|
+
const canvas = document.createElement('canvas');
|
|
53
|
+
const context = canvas.getContext('2d');
|
|
54
|
+
if (!context) return text.length * 8;
|
|
55
|
+
context.font = font;
|
|
56
|
+
return context.measureText(text).width;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function textWidthOnInput(input: HTMLInputElement): number {
|
|
60
|
+
return measureTextWidth(input.value, getComputedStyle(input).font);
|
|
61
|
+
}
|
|
62
|
+
|
|
41
63
|
const HOLD_DELAY = 400;
|
|
42
64
|
const REPEAT_INTERVAL = 80;
|
|
43
65
|
|
|
44
66
|
// Add unique ID generation
|
|
45
67
|
const inputId = `number-input-${Math.random().toString(36).substr(2, 9)}`;
|
|
68
|
+
const suffixDescriptionId = suffix ? `${inputId}-suffix` : undefined;
|
|
46
69
|
|
|
47
70
|
$: isAtMin = !wrapAround && value <= min;
|
|
48
71
|
$: isAtMax = !wrapAround && value >= max;
|
|
@@ -257,6 +280,9 @@
|
|
|
257
280
|
|
|
258
281
|
function handleKeyDown(e: KeyboardEvent) {
|
|
259
282
|
if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
|
|
283
|
+
e.preventDefault();
|
|
284
|
+
const input = e.currentTarget as HTMLInputElement;
|
|
285
|
+
input.setSelectionRange(0, input.value.length);
|
|
260
286
|
isEditing = true;
|
|
261
287
|
return;
|
|
262
288
|
}
|
|
@@ -285,8 +311,75 @@
|
|
|
285
311
|
}
|
|
286
312
|
}
|
|
287
313
|
|
|
314
|
+
function focusNumberInput(input: HTMLInputElement) {
|
|
315
|
+
input.focus({ preventScroll: true });
|
|
316
|
+
isEditing = true;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function endValueAreaDrag() {
|
|
320
|
+
valueAreaDragActive = false;
|
|
321
|
+
if (typeof window !== 'undefined') {
|
|
322
|
+
window.removeEventListener('mousemove', handleValueAreaMouseMove);
|
|
323
|
+
window.removeEventListener('mouseup', endValueAreaDrag);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function handleValueAreaMouseMove(event: MouseEvent) {
|
|
328
|
+
if (!valueAreaDragActive || isDisabled) return;
|
|
329
|
+
const input = numberInputEl ?? document.getElementById(inputId);
|
|
330
|
+
if (!(input instanceof HTMLInputElement)) return;
|
|
331
|
+
const pastEnd = isPointerPastTextEnd(
|
|
332
|
+
input.value,
|
|
333
|
+
input.getBoundingClientRect().left,
|
|
334
|
+
event.clientX,
|
|
335
|
+
textWidthOnInput(input)
|
|
336
|
+
);
|
|
337
|
+
const selection = selectionWhileDraggingFromValueChrome(
|
|
338
|
+
input.value.length,
|
|
339
|
+
pastEnd,
|
|
340
|
+
event.shiftKey
|
|
341
|
+
);
|
|
342
|
+
if (selection) {
|
|
343
|
+
input.setSelectionRange(selection.start, selection.end);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function handleValueAreaMouseDown(event: MouseEvent) {
|
|
348
|
+
if (isDisabled) return;
|
|
349
|
+
if (!shouldRoutePointerToNumberInput(event.target, inputId)) return;
|
|
350
|
+
const input = document.getElementById(inputId);
|
|
351
|
+
if (!(input instanceof HTMLInputElement)) return;
|
|
352
|
+
event.preventDefault();
|
|
353
|
+
focusNumberInput(input);
|
|
354
|
+
const { start, end } = selectionAfterValueAreaPress(inputValue, event.shiftKey);
|
|
355
|
+
input.setSelectionRange(start, end);
|
|
356
|
+
valueAreaDragActive = true;
|
|
357
|
+
window.addEventListener('mousemove', handleValueAreaMouseMove);
|
|
358
|
+
window.addEventListener('mouseup', endValueAreaDrag);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function handleInputMouseDown(event: MouseEvent) {
|
|
362
|
+
if (isDisabled || event.button !== 0) return;
|
|
363
|
+
const input = event.currentTarget as HTMLInputElement;
|
|
364
|
+
const pastEnd = isPointerPastTextEnd(
|
|
365
|
+
input.value,
|
|
366
|
+
input.getBoundingClientRect().left,
|
|
367
|
+
event.clientX,
|
|
368
|
+
textWidthOnInput(input)
|
|
369
|
+
);
|
|
370
|
+
if (!pastEnd) return;
|
|
371
|
+
event.preventDefault();
|
|
372
|
+
focusNumberInput(input);
|
|
373
|
+
const { start, end } = selectionAfterValueAreaPress(inputValue, event.shiftKey);
|
|
374
|
+
input.setSelectionRange(start, end);
|
|
375
|
+
valueAreaDragActive = true;
|
|
376
|
+
window.addEventListener('mousemove', handleValueAreaMouseMove);
|
|
377
|
+
window.addEventListener('mouseup', endValueAreaDrag);
|
|
378
|
+
}
|
|
379
|
+
|
|
288
380
|
onDestroy(() => {
|
|
289
381
|
stopAutoRepeat();
|
|
382
|
+
endValueAreaDrag();
|
|
290
383
|
});
|
|
291
384
|
</script>
|
|
292
385
|
|
|
@@ -302,42 +395,67 @@
|
|
|
302
395
|
it is dead space (the padding that keeps the value 12px in used to sit on the surface, outside the input, and the input
|
|
303
396
|
drew its own square hover box inside the rounded surface, which looked cut out).
|
|
304
397
|
-->
|
|
398
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
305
399
|
<label
|
|
306
400
|
for={inputId}
|
|
307
401
|
class="number-controls-hit-area flex h-full min-w-0 flex-1 items-center rounded-s-lg {inputPaddingClass} {isDisabled
|
|
308
402
|
? 'cursor-default'
|
|
309
403
|
: 'cursor-text'} {suffix ? 'justify-start gap-0' : ''}"
|
|
404
|
+
onmousedown={handleValueAreaMouseDown}
|
|
310
405
|
>
|
|
311
406
|
{#if suffix}
|
|
312
|
-
<span class="number-controls-value inline-flex max-w-full min-w-0 items-baseline gap-0">
|
|
407
|
+
<span class="number-controls-value inline-flex w-fit max-w-full min-w-0 items-baseline gap-0">
|
|
408
|
+
<span class="number-controls-digit-sizer relative inline-block w-fit max-w-full">
|
|
409
|
+
<!-- The sizer is as wide as the digits themselves (no `ch` guess: a digit, a minus sign and a dot are not equally wide), so nothing is left after the number -->
|
|
410
|
+
<span class="invisible block whitespace-pre text-body tabular-nums" aria-hidden="true">
|
|
411
|
+
{inputValue || '0'}
|
|
412
|
+
</span>
|
|
413
|
+
<Input
|
|
414
|
+
id={inputId}
|
|
415
|
+
type="text"
|
|
416
|
+
bind:ref={numberInputEl}
|
|
417
|
+
value={inputValue}
|
|
418
|
+
aria-describedby={suffixDescriptionId}
|
|
419
|
+
onfocus={onFocus}
|
|
420
|
+
oninput={handleInput}
|
|
421
|
+
onblur={handleBlur}
|
|
422
|
+
onkeydown={handleKeyDown}
|
|
423
|
+
onmousedown={handleInputMouseDown}
|
|
424
|
+
readonly={isLocked}
|
|
425
|
+
{disabled}
|
|
426
|
+
class="number-controls-input number-controls-input-with-suffix select-text absolute inset-0 h-full w-full min-w-0 border-0 bg-transparent px-0 text-start text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
427
|
+
/>
|
|
428
|
+
</span>
|
|
429
|
+
{#if suffixDescriptionId}
|
|
430
|
+
<span id={suffixDescriptionId} class="sr-only">{suffix}</span>
|
|
431
|
+
{/if}
|
|
432
|
+
<span
|
|
433
|
+
class="pointer-events-none shrink-0 select-none text-body text-foreground"
|
|
434
|
+
aria-hidden="true"
|
|
435
|
+
>
|
|
436
|
+
{suffix}
|
|
437
|
+
</span>
|
|
438
|
+
</span>
|
|
439
|
+
{:else}
|
|
440
|
+
<span class="number-controls-digit-sizer relative inline-block w-fit max-w-full">
|
|
441
|
+
<span class="invisible block whitespace-pre text-body tabular-nums" aria-hidden="true">
|
|
442
|
+
{inputValue || '0'}
|
|
443
|
+
</span>
|
|
313
444
|
<Input
|
|
314
445
|
id={inputId}
|
|
315
446
|
type="text"
|
|
447
|
+
bind:ref={numberInputEl}
|
|
316
448
|
value={inputValue}
|
|
317
449
|
onfocus={onFocus}
|
|
318
450
|
oninput={handleInput}
|
|
319
451
|
onblur={handleBlur}
|
|
320
452
|
onkeydown={handleKeyDown}
|
|
453
|
+
onmousedown={handleInputMouseDown}
|
|
321
454
|
readonly={isLocked}
|
|
322
455
|
{disabled}
|
|
323
|
-
|
|
324
|
-
class="number-controls-input number-controls-input-with-suffix h-full w-auto min-w-[1ch] max-w-full shrink border-0 bg-transparent px-0 text-start text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
456
|
+
class="number-controls-input absolute inset-0 h-full w-full min-w-0 border-0 bg-transparent px-0 text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
325
457
|
/>
|
|
326
|
-
<span class="pointer-events-none shrink-0 text-body text-foreground">{suffix}</span>
|
|
327
458
|
</span>
|
|
328
|
-
{:else}
|
|
329
|
-
<Input
|
|
330
|
-
id={inputId}
|
|
331
|
-
type="text"
|
|
332
|
-
value={inputValue}
|
|
333
|
-
onfocus={onFocus}
|
|
334
|
-
oninput={handleInput}
|
|
335
|
-
onblur={handleBlur}
|
|
336
|
-
onkeydown={handleKeyDown}
|
|
337
|
-
readonly={isLocked}
|
|
338
|
-
{disabled}
|
|
339
|
-
class="number-controls-input h-full min-w-0 flex-1 border-0 bg-transparent px-0 text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
340
|
-
/>
|
|
341
459
|
{/if}
|
|
342
460
|
</label>
|
|
343
461
|
|
|
@@ -367,6 +485,11 @@
|
|
|
367
485
|
|
|
368
486
|
<style>
|
|
369
487
|
:global(.number-controls-input) {
|
|
488
|
+
flex: none;
|
|
489
|
+
width: 100%;
|
|
490
|
+
min-width: 0;
|
|
491
|
+
max-width: 100%;
|
|
492
|
+
font-variant-numeric: tabular-nums;
|
|
370
493
|
text-align: start;
|
|
371
494
|
appearance: textfield;
|
|
372
495
|
-moz-appearance: textfield;
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* Shadcn UI radio group components for consistent styling and behavior
|
|
20
20
|
*/
|
|
21
21
|
import { Label, RadioGroup } from '@widgetic/design-system/components';
|
|
22
|
+
import { shouldPreventOptionGroupBackgroundFocusSteal } from './optionGroupCardPointerDown';
|
|
22
23
|
|
|
23
24
|
export let value: RadioGroupInputControllerProps['value'];
|
|
24
25
|
export let onChange: RadioGroupInputControllerProps['onChange'];
|
|
@@ -46,6 +47,14 @@
|
|
|
46
47
|
* Handles click on the entire row
|
|
47
48
|
* @param optionValue - The value to select
|
|
48
49
|
*/
|
|
50
|
+
|
|
51
|
+
/** `mousedown` default moves focus to `body` on non-focusable targets; cancel only that (not pointerdown). */
|
|
52
|
+
function handleCardMouseDown(event: MouseEvent) {
|
|
53
|
+
if (shouldPreventOptionGroupBackgroundFocusSteal(event.target)) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
function handleRowClick(optionValue: string) {
|
|
50
59
|
if (localValue !== optionValue) {
|
|
51
60
|
handleValueChange(optionValue);
|
|
@@ -71,9 +80,11 @@
|
|
|
71
80
|
</script>
|
|
72
81
|
|
|
73
82
|
<div class="flex flex-col gap-1">
|
|
83
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
74
84
|
<div
|
|
75
85
|
class="flex w-full flex-col gap-2 rounded-lg bg-accent px-3 py-4 transition-colors duration-fast hover:bg-accent-hover focus-within:outline-hidden focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background"
|
|
76
86
|
onfocusin={onFocus}
|
|
87
|
+
onmousedowncapture={handleCardMouseDown}
|
|
77
88
|
>
|
|
78
89
|
<RadioGroup.Root
|
|
79
90
|
value={localValue}
|
|
@@ -83,7 +83,13 @@
|
|
|
83
83
|
*/
|
|
84
84
|
function toCalendarDatePart(raw: unknown): CalendarDate | undefined {
|
|
85
85
|
if (raw instanceof CalendarDate) return raw;
|
|
86
|
-
if (
|
|
86
|
+
if (
|
|
87
|
+
typeof raw === 'object' &&
|
|
88
|
+
raw !== null &&
|
|
89
|
+
'year' in raw &&
|
|
90
|
+
'month' in raw &&
|
|
91
|
+
'day' in raw
|
|
92
|
+
) {
|
|
87
93
|
const part = raw as { year: number; month: number; day: number };
|
|
88
94
|
return new CalendarDate(part.year, part.month, part.day);
|
|
89
95
|
}
|
|
@@ -91,6 +97,10 @@
|
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
function updateCurrentValue() {
|
|
100
|
+
if ($openDropdowns?.has(controllerId)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
94
104
|
if (!value) {
|
|
95
105
|
currentValue = undefined;
|
|
96
106
|
return;
|
|
@@ -110,11 +120,17 @@
|
|
|
110
120
|
// It stays above `rangeCalendarValue` and `rangeCalendarPlaceholder`: `currentValue` is assigned inside
|
|
111
121
|
// `updateCurrentValue()`, which the compiler cannot see, so a statement written before this one would read the empty
|
|
112
122
|
// range of the first run and never run again (the calendar would open on today, with no range painted).
|
|
123
|
+
// Sync from the prop when it changes while the popover is closed. Do not also depend on
|
|
124
|
+
// `$openDropdowns`: closing the popover would re-sync from a parent `value` that has not caught up yet.
|
|
113
125
|
$: (value, updateCurrentValue());
|
|
114
126
|
|
|
127
|
+
/** Partial ranges must flow back into the calendar while the user is picking; clearing both ends resets the popover. */
|
|
115
128
|
$: rangeCalendarValue =
|
|
116
|
-
currentValue?.start instanceof CalendarDate
|
|
117
|
-
? {
|
|
129
|
+
currentValue?.start instanceof CalendarDate || currentValue?.end instanceof CalendarDate
|
|
130
|
+
? {
|
|
131
|
+
start: currentValue.start instanceof CalendarDate ? currentValue.start : undefined,
|
|
132
|
+
end: currentValue.end instanceof CalendarDate ? currentValue.end : undefined
|
|
133
|
+
}
|
|
118
134
|
: undefined;
|
|
119
135
|
|
|
120
136
|
$: rangeCalendarPlaceholder =
|
|
@@ -139,7 +155,7 @@
|
|
|
139
155
|
languageTag: string,
|
|
140
156
|
translate: Translate<EditorMessageKey>
|
|
141
157
|
): string {
|
|
142
|
-
if (!range || !range.start
|
|
158
|
+
if (!range || (!range.start && !range.end)) return translate('editor.date.pickRange');
|
|
143
159
|
|
|
144
160
|
try {
|
|
145
161
|
const formatDate = (date: DateValue) => {
|
|
@@ -153,7 +169,16 @@
|
|
|
153
169
|
);
|
|
154
170
|
};
|
|
155
171
|
|
|
156
|
-
|
|
172
|
+
if (range.start && range.end) {
|
|
173
|
+
return `${formatDate(range.start)} - ${formatDate(range.end)}`;
|
|
174
|
+
}
|
|
175
|
+
if (range.start) {
|
|
176
|
+
return `${formatDate(range.start)} - …`;
|
|
177
|
+
}
|
|
178
|
+
if (range.end) {
|
|
179
|
+
return `… - ${formatDate(range.end)}`;
|
|
180
|
+
}
|
|
181
|
+
return translate('editor.date.pickRange');
|
|
157
182
|
} catch (error) {
|
|
158
183
|
console.warn('[Editor] Error formatting date range:', error);
|
|
159
184
|
return translate('editor.date.pickRange');
|
|
@@ -167,14 +192,14 @@
|
|
|
167
192
|
* @param newValue - The newly selected date range
|
|
168
193
|
*/
|
|
169
194
|
function handleSelect(newValue: BitsDateRange | undefined): void {
|
|
170
|
-
if (newValue
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
195
|
+
if (!newValue) return;
|
|
196
|
+
|
|
197
|
+
const start = toCalendarDatePart(newValue.start);
|
|
198
|
+
const end = toCalendarDatePart(newValue.end);
|
|
199
|
+
currentValue = start || end ? { start, end } : undefined;
|
|
200
|
+
|
|
201
|
+
if (start && end) {
|
|
202
|
+
onChange({ start, end });
|
|
178
203
|
setTimeout(() => toggleDropdown(controllerId), 200);
|
|
179
204
|
}
|
|
180
205
|
}
|