noph-ui 0.40.0 → 0.40.1
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.
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- absorbed on purpose
|
|
38
38
|
type,
|
|
39
39
|
'aria-invalid': ariaInvalid,
|
|
40
|
+
style,
|
|
40
41
|
displayMonth = $bindable(),
|
|
41
42
|
open = $bindable(false),
|
|
42
43
|
element = $bindable(),
|
|
@@ -70,6 +71,8 @@
|
|
|
70
71
|
invalidDateMessage = 'Enter a valid date.',
|
|
71
72
|
selectedDateLabel = 'selected',
|
|
72
73
|
onchange,
|
|
74
|
+
oninput,
|
|
75
|
+
onblur,
|
|
73
76
|
...attributes
|
|
74
77
|
}: DockedDatePickerProps = $props()
|
|
75
78
|
|
|
@@ -77,7 +80,6 @@
|
|
|
77
80
|
|
|
78
81
|
const uid = $props.id()
|
|
79
82
|
|
|
80
|
-
let anchorElement = $state<HTMLDivElement>()
|
|
81
83
|
let menuElement = $state<HTMLDivElement>()
|
|
82
84
|
let mode = $state<'days' | 'months' | 'years'>('days')
|
|
83
85
|
let listMode = $state<'months' | 'years' | undefined>(undefined)
|
|
@@ -224,7 +226,7 @@
|
|
|
224
226
|
const closePicker = (restoreFocus = true) => {
|
|
225
227
|
menuElement?.hidePopover()
|
|
226
228
|
if (restoreFocus) {
|
|
227
|
-
|
|
229
|
+
element?.querySelector<HTMLElement>('input')?.focus()
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
|
|
@@ -290,185 +292,181 @@
|
|
|
290
292
|
}
|
|
291
293
|
</script>
|
|
292
294
|
|
|
293
|
-
<
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
<TextField
|
|
296
|
+
{...attributes}
|
|
297
|
+
class={['np-docked-date-picker', attributes.class]}
|
|
298
|
+
style={`anchor-name:--${uid};${style ?? ''}`}
|
|
299
|
+
{label}
|
|
300
|
+
{variant}
|
|
301
|
+
{issues}
|
|
302
|
+
{disabled}
|
|
303
|
+
{readonly}
|
|
304
|
+
{required}
|
|
305
|
+
{noAsterisk}
|
|
306
|
+
{autocomplete}
|
|
307
|
+
supportingText={supportingText ?? pattern}
|
|
308
|
+
bind:value={text}
|
|
309
|
+
bind:element
|
|
310
|
+
bind:inputElement
|
|
311
|
+
aria-invalid={inputInvalid || issues?.length || ariaInvalid === true || ariaInvalid === 'true'
|
|
312
|
+
? 'true'
|
|
313
|
+
: undefined}
|
|
314
|
+
oninput={(event) => {
|
|
315
|
+
handleInput(event)
|
|
316
|
+
oninput?.(event)
|
|
317
|
+
}}
|
|
318
|
+
onblur={(event) => {
|
|
319
|
+
handleBlur()
|
|
320
|
+
onblur?.(event)
|
|
321
|
+
}}
|
|
322
|
+
>
|
|
323
|
+
{#snippet end()}
|
|
324
|
+
<IconButton
|
|
325
|
+
type="button"
|
|
326
|
+
aria-label={openCalendarLabel}
|
|
327
|
+
aria-expanded={open}
|
|
328
|
+
aria-haspopup="dialog"
|
|
329
|
+
aria-controls={open ? `${uid}-calendar` : undefined}
|
|
299
330
|
{disabled}
|
|
300
|
-
{
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
supportingText={supportingText ?? pattern}
|
|
305
|
-
bind:value={text}
|
|
306
|
-
bind:inputElement
|
|
307
|
-
aria-invalid={inputInvalid || issues?.length || ariaInvalid === true || ariaInvalid === 'true'
|
|
308
|
-
? 'true'
|
|
309
|
-
: undefined}
|
|
310
|
-
oninput={handleInput}
|
|
311
|
-
onblur={handleBlur}
|
|
331
|
+
onclick={() => {
|
|
332
|
+
if (open) closePicker()
|
|
333
|
+
else openPicker()
|
|
334
|
+
}}
|
|
312
335
|
>
|
|
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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
selectedLabel={selectedDateLabel}
|
|
412
|
-
onselect={selectDay}
|
|
413
|
-
onmonthstep={(delta) => setMonth(addMonths(monthDate, delta))}
|
|
414
|
-
onfocusday={(date) => {
|
|
415
|
-
focusedDay = date
|
|
416
|
-
if (
|
|
417
|
-
date.getMonth() !== monthDate.getMonth() ||
|
|
418
|
-
date.getFullYear() !== monthDate.getFullYear()
|
|
419
|
-
) {
|
|
420
|
-
setMonth(date)
|
|
421
|
-
}
|
|
422
|
-
}}
|
|
423
|
-
/>
|
|
424
|
-
</div>
|
|
336
|
+
<CalendarToday />
|
|
337
|
+
</IconButton>
|
|
338
|
+
{/snippet}
|
|
339
|
+
</TextField>
|
|
340
|
+
<input
|
|
341
|
+
bind:this={valueInput}
|
|
342
|
+
class="np-docked-date-picker-value"
|
|
343
|
+
type="hidden"
|
|
344
|
+
value={current ?? ''}
|
|
345
|
+
{name}
|
|
346
|
+
{form}
|
|
347
|
+
{disabled}
|
|
348
|
+
/>
|
|
349
|
+
|
|
350
|
+
<Menu
|
|
351
|
+
id="{uid}-calendar"
|
|
352
|
+
role="dialog"
|
|
353
|
+
aria-label={label}
|
|
354
|
+
aria-modal="false"
|
|
355
|
+
class="np-docked-date-picker-menu"
|
|
356
|
+
style={`position-anchor:--${uid};`}
|
|
357
|
+
--np-menu-justify-self="none"
|
|
358
|
+
--np-menu-position-area="bottom span-right"
|
|
359
|
+
--np-menu-over-anchor-position-area="span-all span-right"
|
|
360
|
+
--np-menu-margin="0"
|
|
361
|
+
--np-menu-container-color="var(--np-docked-date-picker-container-color, var(--np-color-surface-container-high))"
|
|
362
|
+
--np-menu-container-shape="var(--np-docked-date-picker-container-shape, var(--np-shape-corner-large))"
|
|
363
|
+
anchor={element}
|
|
364
|
+
bind:element={menuElement}
|
|
365
|
+
bind:open
|
|
366
|
+
ontoggle={({ newState }) => {
|
|
367
|
+
if (newState === 'open') {
|
|
368
|
+
monthBeforeOpen = displayMonth
|
|
369
|
+
pending = current
|
|
370
|
+
focusCalendarWhenReady()
|
|
371
|
+
}
|
|
372
|
+
if (newState === 'closed') {
|
|
373
|
+
setMode('days')
|
|
374
|
+
listMode = undefined
|
|
375
|
+
focusedDay = undefined
|
|
376
|
+
displayMonth = monthBeforeOpen
|
|
377
|
+
}
|
|
378
|
+
}}
|
|
379
|
+
>
|
|
380
|
+
{#if open}
|
|
381
|
+
<div class="np-docked-date-picker-container" style:--np-calendar-rows={rowCount}>
|
|
382
|
+
<CalendarHeader
|
|
383
|
+
{mode}
|
|
384
|
+
monthLabel={shortMonthNames[monthDate.getMonth()]}
|
|
385
|
+
yearLabel={`${monthDate.getFullYear()}`}
|
|
386
|
+
{canPreviousMonth}
|
|
387
|
+
{canNextMonth}
|
|
388
|
+
{canPreviousYear}
|
|
389
|
+
{canNextYear}
|
|
390
|
+
{previousMonthLabel}
|
|
391
|
+
{nextMonthLabel}
|
|
392
|
+
{previousYearLabel}
|
|
393
|
+
{nextYearLabel}
|
|
394
|
+
{selectMonthLabel}
|
|
395
|
+
{selectYearLabel}
|
|
396
|
+
monthListId="{uid}-months"
|
|
397
|
+
yearListId="{uid}-years"
|
|
398
|
+
onpreviousmonth={() => setMonth(addMonths(monthDate, -1))}
|
|
399
|
+
onnextmonth={() => setMonth(addMonths(monthDate, 1))}
|
|
400
|
+
onpreviousyear={() => setMonth(addMonths(monthDate, -12))}
|
|
401
|
+
onnextyear={() => setMonth(addMonths(monthDate, 12))}
|
|
402
|
+
ontogglemonths={() => setMode(mode === 'months' ? 'days' : 'months')}
|
|
403
|
+
ontoggleyears={() => setMode(mode === 'years' ? 'days' : 'years')}
|
|
404
|
+
/>
|
|
405
|
+
|
|
406
|
+
<div class="np-docked-date-picker-views">
|
|
407
|
+
<div class="np-docked-date-picker-body" inert={mode !== 'days'}>
|
|
408
|
+
<Calendar
|
|
409
|
+
month={monthDate}
|
|
410
|
+
selected={pendingDate}
|
|
411
|
+
min={minDate}
|
|
412
|
+
max={maxDate}
|
|
413
|
+
{locale}
|
|
414
|
+
firstDayOfWeek={week}
|
|
415
|
+
{isDateEnabled}
|
|
416
|
+
{adjacentMonthDays}
|
|
417
|
+
dynamicRows
|
|
418
|
+
todayDate={todayValue}
|
|
419
|
+
focusedDate={focusedDay}
|
|
420
|
+
selectedLabel={selectedDateLabel}
|
|
421
|
+
onselect={selectDay}
|
|
422
|
+
onmonthstep={(delta) => setMonth(addMonths(monthDate, delta))}
|
|
423
|
+
onfocusday={(date) => {
|
|
424
|
+
focusedDay = date
|
|
425
|
+
if (
|
|
426
|
+
date.getMonth() !== monthDate.getMonth() ||
|
|
427
|
+
date.getFullYear() !== monthDate.getFullYear()
|
|
428
|
+
) {
|
|
429
|
+
setMonth(date)
|
|
430
|
+
}
|
|
431
|
+
}}
|
|
432
|
+
/>
|
|
433
|
+
</div>
|
|
425
434
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
</div>
|
|
435
|
+
{#if listMode}
|
|
436
|
+
<div class={['np-docked-date-picker-menu-view', mode !== 'days' && 'open']}>
|
|
437
|
+
<div class="np-docked-date-picker-menu-shade">
|
|
438
|
+
<Divider --np-divider-color="var(--np-color-outline-variant)" />
|
|
439
|
+
{#if listMode === 'months'}
|
|
440
|
+
<SelectionList
|
|
441
|
+
id="{uid}-months"
|
|
442
|
+
aria-label={selectMonthLabel}
|
|
443
|
+
options={monthOptions}
|
|
444
|
+
value={monthDate.getMonth()}
|
|
445
|
+
onselect={chooseMonth}
|
|
446
|
+
/>
|
|
447
|
+
{:else}
|
|
448
|
+
<SelectionList
|
|
449
|
+
id="{uid}-years"
|
|
450
|
+
aria-label={selectYearLabel}
|
|
451
|
+
options={yearOptions}
|
|
452
|
+
value={monthDate.getFullYear()}
|
|
453
|
+
onselect={chooseYear}
|
|
454
|
+
/>
|
|
455
|
+
{/if}
|
|
448
456
|
</div>
|
|
449
|
-
|
|
450
|
-
|
|
457
|
+
</div>
|
|
458
|
+
{/if}
|
|
459
|
+
</div>
|
|
451
460
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
</div>
|
|
461
|
+
<div class="np-docked-date-picker-actions">
|
|
462
|
+
<Button type="button" variant="text" onclick={() => closePicker()}>{cancelLabel}</Button>
|
|
463
|
+
<Button type="button" variant="text" onclick={confirm}>{confirmLabel}</Button>
|
|
456
464
|
</div>
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
</
|
|
465
|
+
</div>
|
|
466
|
+
{/if}
|
|
467
|
+
</Menu>
|
|
460
468
|
|
|
461
469
|
<style>
|
|
462
|
-
.np-docked-date-picker {
|
|
463
|
-
display: inline-flex;
|
|
464
|
-
flex-direction: column;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
.np-docked-date-picker-anchor {
|
|
468
|
-
display: inline-flex;
|
|
469
|
-
position: relative;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
470
|
:global(.np-docked-date-picker-menu .np-menu) {
|
|
473
471
|
padding: 0;
|
|
474
472
|
}
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- absorbed on purpose
|
|
52
52
|
type,
|
|
53
53
|
'aria-invalid': ariaInvalid,
|
|
54
|
+
style,
|
|
54
55
|
displayMonth = $bindable(),
|
|
55
56
|
open = $bindable(false),
|
|
56
57
|
element = $bindable(),
|
|
@@ -90,6 +91,8 @@
|
|
|
90
91
|
minuteLabel = 'Minute',
|
|
91
92
|
dayPeriodLabel = 'AM or PM',
|
|
92
93
|
onchange,
|
|
94
|
+
oninput,
|
|
95
|
+
onblur,
|
|
93
96
|
...attributes
|
|
94
97
|
}: DockedDateTimePickerProps = $props()
|
|
95
98
|
|
|
@@ -98,7 +101,6 @@
|
|
|
98
101
|
|
|
99
102
|
const uid = $props.id()
|
|
100
103
|
|
|
101
|
-
let anchorElement = $state<HTMLDivElement>()
|
|
102
104
|
let menuElement = $state<HTMLDivElement>()
|
|
103
105
|
let mode = $state<'days' | 'months' | 'years'>('days')
|
|
104
106
|
let listMode = $state<'months' | 'years' | undefined>(undefined)
|
|
@@ -307,7 +309,7 @@
|
|
|
307
309
|
const closePicker = (restoreFocus = true) => {
|
|
308
310
|
menuElement?.hidePopover()
|
|
309
311
|
if (restoreFocus) {
|
|
310
|
-
|
|
312
|
+
element?.querySelector<HTMLElement>('input')?.focus()
|
|
311
313
|
}
|
|
312
314
|
}
|
|
313
315
|
|
|
@@ -380,225 +382,217 @@
|
|
|
380
382
|
}
|
|
381
383
|
</script>
|
|
382
384
|
|
|
383
|
-
<
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
385
|
+
<TextField
|
|
386
|
+
{...attributes}
|
|
387
|
+
class={['np-docked-date-time-picker', attributes.class]}
|
|
388
|
+
style={`anchor-name:--${uid};${style ?? ''}`}
|
|
389
|
+
{label}
|
|
390
|
+
{variant}
|
|
391
|
+
{issues}
|
|
392
|
+
{disabled}
|
|
393
|
+
{readonly}
|
|
394
|
+
{required}
|
|
395
|
+
{noAsterisk}
|
|
396
|
+
{autocomplete}
|
|
397
|
+
supportingText={supportingText ?? pattern}
|
|
398
|
+
bind:value={text}
|
|
399
|
+
bind:element
|
|
400
|
+
bind:inputElement
|
|
401
|
+
aria-invalid={inputInvalid || issues?.length || ariaInvalid === true || ariaInvalid === 'true'
|
|
402
|
+
? 'true'
|
|
403
|
+
: undefined}
|
|
404
|
+
oninput={(event) => {
|
|
405
|
+
handleInput(event)
|
|
406
|
+
oninput?.(event)
|
|
407
|
+
}}
|
|
408
|
+
onblur={(event) => {
|
|
409
|
+
handleBlur()
|
|
410
|
+
onblur?.(event)
|
|
411
|
+
}}
|
|
412
|
+
>
|
|
413
|
+
{#snippet end()}
|
|
414
|
+
<IconButton
|
|
415
|
+
type="button"
|
|
416
|
+
aria-label={openCalendarLabel}
|
|
417
|
+
aria-expanded={open}
|
|
418
|
+
aria-haspopup="dialog"
|
|
419
|
+
aria-controls={open ? `${uid}-calendar` : undefined}
|
|
393
420
|
{disabled}
|
|
394
|
-
{
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
supportingText={supportingText ?? pattern}
|
|
399
|
-
bind:value={text}
|
|
400
|
-
bind:inputElement
|
|
401
|
-
aria-invalid={inputInvalid || issues?.length || ariaInvalid === true || ariaInvalid === 'true'
|
|
402
|
-
? 'true'
|
|
403
|
-
: undefined}
|
|
404
|
-
oninput={handleInput}
|
|
405
|
-
onblur={handleBlur}
|
|
421
|
+
onclick={() => {
|
|
422
|
+
if (open) closePicker()
|
|
423
|
+
else openPicker()
|
|
424
|
+
}}
|
|
406
425
|
>
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
selectedLabel={selectedDateLabel}
|
|
513
|
-
onselect={selectDay}
|
|
514
|
-
onmonthstep={(delta) => setMonth(addMonths(monthDate, delta))}
|
|
515
|
-
onfocusday={(date) => {
|
|
516
|
-
focusedDay = date
|
|
517
|
-
if (
|
|
518
|
-
date.getMonth() !== monthDate.getMonth() ||
|
|
519
|
-
date.getFullYear() !== monthDate.getFullYear()
|
|
520
|
-
) {
|
|
521
|
-
setMonth(date)
|
|
522
|
-
}
|
|
523
|
-
}}
|
|
524
|
-
/>
|
|
525
|
-
</div>
|
|
426
|
+
<CalendarToday />
|
|
427
|
+
</IconButton>
|
|
428
|
+
{/snippet}
|
|
429
|
+
</TextField>
|
|
430
|
+
<input
|
|
431
|
+
bind:this={valueInput}
|
|
432
|
+
class="np-docked-date-time-picker-value"
|
|
433
|
+
type="hidden"
|
|
434
|
+
value={current ?? ''}
|
|
435
|
+
{name}
|
|
436
|
+
{form}
|
|
437
|
+
{disabled}
|
|
438
|
+
/>
|
|
439
|
+
|
|
440
|
+
<Menu
|
|
441
|
+
id="{uid}-calendar"
|
|
442
|
+
role="dialog"
|
|
443
|
+
aria-label={label}
|
|
444
|
+
aria-modal="false"
|
|
445
|
+
class="np-docked-date-time-picker-menu"
|
|
446
|
+
style={`position-anchor:--${uid};`}
|
|
447
|
+
--np-menu-justify-self="none"
|
|
448
|
+
--np-menu-position-area="bottom span-right"
|
|
449
|
+
--np-menu-over-anchor-position-area="span-all span-right"
|
|
450
|
+
--np-menu-margin="0"
|
|
451
|
+
--np-menu-container-color="var(--np-docked-date-time-picker-container-color, var(--np-color-surface-container-high))"
|
|
452
|
+
--np-menu-container-shape="var(--np-docked-date-time-picker-container-shape, var(--np-shape-corner-large))"
|
|
453
|
+
anchor={element}
|
|
454
|
+
bind:element={menuElement}
|
|
455
|
+
bind:open
|
|
456
|
+
ontoggle={({ newState }) => {
|
|
457
|
+
if (newState === 'open') {
|
|
458
|
+
monthBeforeOpen = displayMonth
|
|
459
|
+
pendingDay = committed ? toISODate(committed) : undefined
|
|
460
|
+
pendingMinutes = committed ? minutesOfDay(committed) : defaultMinutes
|
|
461
|
+
focusCalendarWhenReady()
|
|
462
|
+
}
|
|
463
|
+
if (newState === 'closed') {
|
|
464
|
+
setMode('days')
|
|
465
|
+
listMode = undefined
|
|
466
|
+
focusedDay = undefined
|
|
467
|
+
displayMonth = monthBeforeOpen
|
|
468
|
+
}
|
|
469
|
+
}}
|
|
470
|
+
>
|
|
471
|
+
{#if open}
|
|
472
|
+
<div
|
|
473
|
+
class="np-docked-date-time-picker-container"
|
|
474
|
+
style:--np-calendar-rows={rowCount}
|
|
475
|
+
style:--np-time-columns={hour12 ? 3 : 2}
|
|
476
|
+
>
|
|
477
|
+
<div class="np-docked-date-time-picker-panels">
|
|
478
|
+
<div class="np-docked-date-time-picker-date">
|
|
479
|
+
<CalendarHeader
|
|
480
|
+
{mode}
|
|
481
|
+
monthLabel={shortMonthNames[monthDate.getMonth()]}
|
|
482
|
+
yearLabel={`${monthDate.getFullYear()}`}
|
|
483
|
+
{canPreviousMonth}
|
|
484
|
+
{canNextMonth}
|
|
485
|
+
{canPreviousYear}
|
|
486
|
+
{canNextYear}
|
|
487
|
+
{previousMonthLabel}
|
|
488
|
+
{nextMonthLabel}
|
|
489
|
+
{previousYearLabel}
|
|
490
|
+
{nextYearLabel}
|
|
491
|
+
{selectMonthLabel}
|
|
492
|
+
{selectYearLabel}
|
|
493
|
+
monthListId="{uid}-months"
|
|
494
|
+
yearListId="{uid}-years"
|
|
495
|
+
onpreviousmonth={() => setMonth(addMonths(monthDate, -1))}
|
|
496
|
+
onnextmonth={() => setMonth(addMonths(monthDate, 1))}
|
|
497
|
+
onpreviousyear={() => setMonth(addMonths(monthDate, -12))}
|
|
498
|
+
onnextyear={() => setMonth(addMonths(monthDate, 12))}
|
|
499
|
+
ontogglemonths={() => setMode(mode === 'months' ? 'days' : 'months')}
|
|
500
|
+
ontoggleyears={() => setMode(mode === 'years' ? 'days' : 'years')}
|
|
501
|
+
/>
|
|
502
|
+
|
|
503
|
+
<div class="np-docked-date-time-picker-views">
|
|
504
|
+
<div class="np-docked-date-time-picker-body" inert={mode !== 'days'}>
|
|
505
|
+
<Calendar
|
|
506
|
+
month={monthDate}
|
|
507
|
+
selected={pendingDate}
|
|
508
|
+
min={minDate}
|
|
509
|
+
max={maxDate}
|
|
510
|
+
{locale}
|
|
511
|
+
firstDayOfWeek={week}
|
|
512
|
+
{isDateEnabled}
|
|
513
|
+
{adjacentMonthDays}
|
|
514
|
+
dynamicRows
|
|
515
|
+
todayDate={todayValue}
|
|
516
|
+
focusedDate={focusedDay}
|
|
517
|
+
selectedLabel={selectedDateLabel}
|
|
518
|
+
onselect={selectDay}
|
|
519
|
+
onmonthstep={(delta) => setMonth(addMonths(monthDate, delta))}
|
|
520
|
+
onfocusday={(date) => {
|
|
521
|
+
focusedDay = date
|
|
522
|
+
if (
|
|
523
|
+
date.getMonth() !== monthDate.getMonth() ||
|
|
524
|
+
date.getFullYear() !== monthDate.getFullYear()
|
|
525
|
+
) {
|
|
526
|
+
setMonth(date)
|
|
527
|
+
}
|
|
528
|
+
}}
|
|
529
|
+
/>
|
|
530
|
+
</div>
|
|
526
531
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
</div>
|
|
532
|
+
{#if listMode}
|
|
533
|
+
<div class={['np-docked-date-time-picker-menu-view', mode !== 'days' && 'open']}>
|
|
534
|
+
<div class="np-docked-date-time-picker-menu-shade">
|
|
535
|
+
<Divider --np-divider-color="var(--np-color-outline-variant)" />
|
|
536
|
+
{#if listMode === 'months'}
|
|
537
|
+
<SelectionList
|
|
538
|
+
id="{uid}-months"
|
|
539
|
+
aria-label={selectMonthLabel}
|
|
540
|
+
options={monthOptions}
|
|
541
|
+
value={monthDate.getMonth()}
|
|
542
|
+
onselect={chooseMonth}
|
|
543
|
+
/>
|
|
544
|
+
{:else}
|
|
545
|
+
<SelectionList
|
|
546
|
+
id="{uid}-years"
|
|
547
|
+
aria-label={selectYearLabel}
|
|
548
|
+
options={yearOptions}
|
|
549
|
+
value={monthDate.getFullYear()}
|
|
550
|
+
onselect={chooseYear}
|
|
551
|
+
/>
|
|
552
|
+
{/if}
|
|
549
553
|
</div>
|
|
550
|
-
|
|
551
|
-
|
|
554
|
+
</div>
|
|
555
|
+
{/if}
|
|
552
556
|
</div>
|
|
557
|
+
</div>
|
|
553
558
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
559
|
+
<div class="np-docked-date-time-picker-time">
|
|
560
|
+
<div class="np-docked-date-time-picker-columns">
|
|
561
|
+
<TimeColumn
|
|
562
|
+
aria-label={hourLabel}
|
|
563
|
+
options={hourOptions}
|
|
564
|
+
value={pendingHour}
|
|
565
|
+
onselect={(hour) =>
|
|
566
|
+
setTime(hour * MINUTES_IN_HOUR + (pendingMinutes % MINUTES_IN_HOUR))}
|
|
567
|
+
/>
|
|
568
|
+
<TimeColumn
|
|
569
|
+
aria-label={minuteLabel}
|
|
570
|
+
options={minuteOptions}
|
|
571
|
+
value={pendingMinutes % MINUTES_IN_HOUR}
|
|
572
|
+
onselect={(minute) => setTime(pendingHour * MINUTES_IN_HOUR + minute)}
|
|
573
|
+
/>
|
|
574
|
+
{#if hour12}
|
|
563
575
|
<TimeColumn
|
|
564
|
-
aria-label={
|
|
565
|
-
options={
|
|
566
|
-
value={
|
|
567
|
-
onselect={(
|
|
576
|
+
aria-label={dayPeriodLabel}
|
|
577
|
+
options={periodOptions}
|
|
578
|
+
value={pendingPeriod}
|
|
579
|
+
onselect={(period) => setTime((pendingMinutes % HALF_DAY) + period * HALF_DAY)}
|
|
568
580
|
/>
|
|
569
|
-
|
|
570
|
-
<TimeColumn
|
|
571
|
-
aria-label={dayPeriodLabel}
|
|
572
|
-
options={periodOptions}
|
|
573
|
-
value={pendingPeriod}
|
|
574
|
-
onselect={(period) => setTime((pendingMinutes % HALF_DAY) + period * HALF_DAY)}
|
|
575
|
-
/>
|
|
576
|
-
{/if}
|
|
577
|
-
</div>
|
|
581
|
+
{/if}
|
|
578
582
|
</div>
|
|
579
583
|
</div>
|
|
584
|
+
</div>
|
|
580
585
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
</div>
|
|
586
|
+
<Divider --np-divider-color="var(--np-color-outline-variant)" />
|
|
587
|
+
<div class="np-docked-date-time-picker-actions">
|
|
588
|
+
<Button type="button" variant="text" onclick={() => closePicker()}>{cancelLabel}</Button>
|
|
589
|
+
<Button type="button" variant="text" onclick={confirm}>{confirmLabel}</Button>
|
|
586
590
|
</div>
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
</
|
|
591
|
+
</div>
|
|
592
|
+
{/if}
|
|
593
|
+
</Menu>
|
|
590
594
|
|
|
591
595
|
<style>
|
|
592
|
-
.np-docked-date-time-picker {
|
|
593
|
-
display: inline-flex;
|
|
594
|
-
flex-direction: column;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
.np-docked-date-time-picker-anchor {
|
|
598
|
-
display: inline-flex;
|
|
599
|
-
position: relative;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
596
|
:global(.np-docked-date-time-picker-menu .np-menu) {
|
|
603
597
|
padding: 0;
|
|
604
598
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { TextFieldElement } from '../text-field/types.js';
|
|
2
3
|
import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
3
4
|
export type ISODate = string;
|
|
4
5
|
export type ISODateTime = string;
|
|
@@ -26,11 +27,11 @@ interface MonthStepperLabelProps {
|
|
|
26
27
|
nextMonthLabel?: string;
|
|
27
28
|
previousMonthLabel?: string;
|
|
28
29
|
}
|
|
29
|
-
export interface DockedDatePickerProps extends Omit<HTMLAttributes<
|
|
30
|
+
export interface DockedDatePickerProps extends Omit<HTMLAttributes<TextFieldElement>, 'onchange'>, DatePickerLocaleProps, DatePickerRangeProps, DatePickerCommonLabelProps, MonthStepperLabelProps {
|
|
30
31
|
value?: ISODate | number | null;
|
|
31
32
|
displayMonth?: ISODate;
|
|
32
33
|
open?: boolean;
|
|
33
|
-
element?:
|
|
34
|
+
element?: HTMLSpanElement;
|
|
34
35
|
name?: string;
|
|
35
36
|
form?: string;
|
|
36
37
|
required?: boolean;
|
|
@@ -54,11 +55,11 @@ export interface DockedDatePickerProps extends Omit<HTMLAttributes<HTMLDivElemen
|
|
|
54
55
|
invalidDateMessage?: string;
|
|
55
56
|
onchange?: (value: ISODate | undefined) => void;
|
|
56
57
|
}
|
|
57
|
-
export interface DockedDateTimePickerProps extends Omit<HTMLAttributes<
|
|
58
|
+
export interface DockedDateTimePickerProps extends Omit<HTMLAttributes<TextFieldElement>, 'onchange'>, DatePickerLocaleProps, Omit<DatePickerRangeProps, 'min' | 'max'>, DatePickerCommonLabelProps, MonthStepperLabelProps {
|
|
58
59
|
value?: ISODateTime | number | null;
|
|
59
60
|
displayMonth?: ISODate;
|
|
60
61
|
open?: boolean;
|
|
61
|
-
element?:
|
|
62
|
+
element?: HTMLSpanElement;
|
|
62
63
|
min?: ISODate | ISODateTime;
|
|
63
64
|
max?: ISODate | ISODateTime;
|
|
64
65
|
name?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SliderProps } from './types.ts';
|
|
2
|
-
declare const Slider: import("svelte").Component<SliderProps, {}, "value" | "element" | "
|
|
2
|
+
declare const Slider: import("svelte").Component<SliderProps, {}, "value" | "element" | "inputElement" | "endValue" | "endInputElement">;
|
|
3
3
|
type Slider = ReturnType<typeof Slider>;
|
|
4
4
|
export default Slider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noph-ui",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://noph.dev",
|
|
6
6
|
"repository": {
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
"svelte-check": "^4.7.5",
|
|
98
98
|
"typescript": "^6.0.3",
|
|
99
99
|
"typescript-eslint": "^8.66.0",
|
|
100
|
+
"valibot": "^1.4.2",
|
|
100
101
|
"vite": "8.2.1",
|
|
101
102
|
"vitest": "^4.1.10",
|
|
102
103
|
"vitest-browser-svelte": "^2.1.1"
|