@classic-homes/theme-svelte 0.1.10 → 0.1.11

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.
@@ -29,12 +29,14 @@
29
29
  error?: string;
30
30
  /** Additional class for the trigger */
31
31
  class?: string;
32
+ /** Show only date picker without time selection */
33
+ dateOnly?: boolean;
32
34
  }
33
35
 
34
36
  let {
35
37
  value = $bindable(null),
36
38
  onValueChange,
37
- placeholder = 'Select date and time...',
39
+ placeholder,
38
40
  disabled = false,
39
41
  required = false,
40
42
  min,
@@ -45,8 +47,13 @@
45
47
  id,
46
48
  error,
47
49
  class: className,
50
+ dateOnly = false,
48
51
  }: Props = $props();
49
52
 
53
+ // Set default placeholder based on dateOnly mode
54
+ const defaultPlaceholder = $derived(dateOnly ? 'Select date...' : 'Select date and time...');
55
+ const effectivePlaceholder = $derived(placeholder ?? defaultPlaceholder);
56
+
50
57
  let open = $state(false);
51
58
 
52
59
  // Calendar state - initialize with current date
@@ -77,6 +84,9 @@
77
84
  day: 'numeric',
78
85
  year: 'numeric',
79
86
  });
87
+ if (dateOnly) {
88
+ return dateStr;
89
+ }
80
90
  const timeStr = value.toLocaleTimeString('en-US', {
81
91
  hour: 'numeric',
82
92
  minute: '2-digit',
@@ -139,12 +149,17 @@
139
149
 
140
150
  const newDate = new Date(viewYear, viewMonth, day);
141
151
 
142
- // Preserve or set time
143
- let h = hour;
144
- if (timeFormat === '12h') {
145
- h = period === 'PM' ? (hour === 12 ? 12 : hour + 12) : hour === 12 ? 0 : hour;
152
+ if (dateOnly) {
153
+ // Set to midnight for date-only mode
154
+ newDate.setHours(0, 0, 0, 0);
155
+ } else {
156
+ // Preserve or set time
157
+ let h = hour;
158
+ if (timeFormat === '12h') {
159
+ h = period === 'PM' ? (hour === 12 ? 12 : hour + 12) : hour === 12 ? 0 : hour;
160
+ }
161
+ newDate.setHours(h, minute, 0, 0);
146
162
  }
147
- newDate.setHours(h, minute, 0, 0);
148
163
 
149
164
  value = newDate;
150
165
  onValueChange?.(newDate);
@@ -227,7 +242,7 @@
227
242
  aria-invalid={error ? 'true' : undefined}
228
243
  >
229
244
  <span class="truncate">
230
- {displayValue || placeholder}
245
+ {displayValue || effectivePlaceholder}
231
246
  </span>
232
247
  <svg
233
248
  xmlns="http://www.w3.org/2000/svg"
@@ -344,43 +359,45 @@
344
359
  {/each}
345
360
  </div>
346
361
 
347
- <!-- Time selector -->
348
- <div class="border-t mt-3 pt-3">
349
- <div class="flex items-center gap-2">
350
- <span class="text-sm text-muted-foreground">Time:</span>
351
- <select
352
- bind:value={hour}
353
- onchange={updateTime}
354
- class="h-8 rounded-md border border-input bg-background px-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
355
- >
356
- {#each hourOptions as h}
357
- <option value={timeFormat === '12h' ? h : h}>
358
- {String(h).padStart(2, '0')}
359
- </option>
360
- {/each}
361
- </select>
362
- <span class="text-muted-foreground">:</span>
363
- <select
364
- bind:value={minute}
365
- onchange={updateTime}
366
- class="h-8 rounded-md border border-input bg-background px-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
367
- >
368
- {#each minuteOptions as m}
369
- <option value={m}>{String(m).padStart(2, '0')}</option>
370
- {/each}
371
- </select>
372
- {#if timeFormat === '12h'}
362
+ <!-- Time selector (hidden in dateOnly mode) -->
363
+ {#if !dateOnly}
364
+ <div class="border-t mt-3 pt-3">
365
+ <div class="flex items-center gap-2">
366
+ <span class="text-sm text-muted-foreground">Time:</span>
373
367
  <select
374
- bind:value={period}
368
+ bind:value={hour}
375
369
  onchange={updateTime}
376
370
  class="h-8 rounded-md border border-input bg-background px-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
377
371
  >
378
- <option value="AM">AM</option>
379
- <option value="PM">PM</option>
372
+ {#each hourOptions as h}
373
+ <option value={timeFormat === '12h' ? h : h}>
374
+ {String(h).padStart(2, '0')}
375
+ </option>
376
+ {/each}
380
377
  </select>
381
- {/if}
378
+ <span class="text-muted-foreground">:</span>
379
+ <select
380
+ bind:value={minute}
381
+ onchange={updateTime}
382
+ class="h-8 rounded-md border border-input bg-background px-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
383
+ >
384
+ {#each minuteOptions as m}
385
+ <option value={m}>{String(m).padStart(2, '0')}</option>
386
+ {/each}
387
+ </select>
388
+ {#if timeFormat === '12h'}
389
+ <select
390
+ bind:value={period}
391
+ onchange={updateTime}
392
+ class="h-8 rounded-md border border-input bg-background px-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
393
+ >
394
+ <option value="AM">AM</option>
395
+ <option value="PM">PM</option>
396
+ </select>
397
+ {/if}
398
+ </div>
382
399
  </div>
383
- </div>
400
+ {/if}
384
401
 
385
402
  <!-- Actions -->
386
403
  <div class="border-t mt-3 pt-3 flex justify-between">
@@ -25,6 +25,8 @@ interface Props {
25
25
  error?: string;
26
26
  /** Additional class for the trigger */
27
27
  class?: string;
28
+ /** Show only date picker without time selection */
29
+ dateOnly?: boolean;
28
30
  }
29
31
  declare const DateTimePicker: import("svelte").Component<Props, {}, "value">;
30
32
  type DateTimePicker = ReturnType<typeof DateTimePicker>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/theme-svelte",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Svelte components for the Classic theme system",
5
5
  "type": "module",
6
6
  "svelte": "./dist/lib/index.js",