@spaethtech/svelte-ui 0.21.1-dev.121.3e3f7cf → 0.21.1-dev.124.7b5c577
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/MIGRATION.md +20 -0
- package/dist/components/DatePicker2.svelte +103 -0
- package/dist/components/DatePicker2.svelte.d.ts +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/docs/components.md +17 -0
- package/docs/native-first-overlays.md +54 -0
- package/package.json +5 -1
package/MIGRATION.md
CHANGED
|
@@ -87,3 +87,23 @@ grep -rl 'Disclosure\|Accordion' src | xargs sed -i \
|
|
|
87
87
|
-e 's/\b\(Disclosure\|Accordion\)\b/\12/g'
|
|
88
88
|
# Review: this also rewrites import specifiers and any prose; check each hit.
|
|
89
89
|
```
|
|
90
|
+
|
|
91
|
+
### `DatePicker2` vs `DatePicker`
|
|
92
|
+
|
|
93
|
+
`DatePicker2` reuses `Input` with a real `<input type="date">` / `datetime-local`. **Unlike the other
|
|
94
|
+
`*2` components, the trigger content is NOT a pixel match** — the native control shows editable date
|
|
95
|
+
segments + the browser's picker indicator, not `DatePicker`'s formatted label + MDI calendar. The
|
|
96
|
+
field *frame* is identical (same `Input`), and the value format is identical, so the binding is
|
|
97
|
+
drop-in for single/datetime.
|
|
98
|
+
|
|
99
|
+
| `DatePicker` prop | `DatePicker2` behaviour |
|
|
100
|
+
| --- | --- |
|
|
101
|
+
| `value` (single `YYYY-MM-DD`, datetime `YYYY-MM-DDTHH:MM`), `time`, `min`, `max`, `size`, `variant`, `disabled`, `name`, `class` | ✅ Honoured. `name` sits on the `<input>` (submits natively — no hidden input). |
|
|
102
|
+
| `range` | ❌ **No native equivalent.** Falls back to a single date input (dev warning). Use two `DatePicker2`s (start/end) or stay on `DatePicker`. |
|
|
103
|
+
| `step`, `seconds`, `meridiem`, `weekStart` | ❌ Accepted but ignored — the OS picker owns time granularity + week layout. |
|
|
104
|
+
| `locale` | ❌ Ignored — the native input formats per the user's browser/OS locale. |
|
|
105
|
+
| `placeholder` | ❌ Ignored — native date inputs don't show placeholder text. |
|
|
106
|
+
| formatted label (e.g. "Mar 5, 2026") | ⚠️ Shown as native editable segments (e.g. `03/05/2026`) instead. |
|
|
107
|
+
|
|
108
|
+
**When NOT to swap:** range mode, a custom formatted trigger, or a specific locale/time-granularity
|
|
109
|
+
UI — stay on `DatePicker`. Swap for plain single-date / datetime fields that must work without JS.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
/**
|
|
3
|
+
* DatePicker2 — a native-first, no-JS/SSR-correct sibling of `DatePicker` (transitional `*2`, see
|
|
4
|
+
* MIGRATION.md). It reuses `Input` with a real `<input type="date">` (or `type="datetime-local">` in
|
|
5
|
+
* `time` mode), so date entry works with NO JavaScript, pops the browser's native date picker, and
|
|
6
|
+
* submits in a plain `<form>` via `name` — and the field FRAME (border/height/radius/focus) is
|
|
7
|
+
* pixel-identical to `DatePicker` because it is the same `Input`.
|
|
8
|
+
*
|
|
9
|
+
* HONEST caveat (unlike the other `*2` components): the native control renders its value as editable
|
|
10
|
+
* segments (e.g. `03/05/2025`) with the browser's own picker indicator, so the trigger *content* is
|
|
11
|
+
* NOT pixel-identical to `DatePicker`'s formatted label ("Mar 5, 2025") + MDI calendar. Only the
|
|
12
|
+
* frame matches. Value format for single/datetime is identical, so the binding is drop-in.
|
|
13
|
+
*
|
|
14
|
+
* Scope: single date + `time` (datetime). `range` has no native equivalent — if set, it falls back
|
|
15
|
+
* to a single date input (dev warning). `step`/`seconds`/`meridiem`/`weekStart`/`locale`/`placeholder`
|
|
16
|
+
* are accepted for drop-in compatibility but not honoured (the OS owns the native picker). See
|
|
17
|
+
* MIGRATION.md.
|
|
18
|
+
*/
|
|
19
|
+
-->
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
22
|
+
import type { Size } from "../types/sizes.js";
|
|
23
|
+
import type { Responsive } from "../types/responsive.js";
|
|
24
|
+
import type { Variant } from "../types/variants.js";
|
|
25
|
+
import type { StepSpec } from "../types/time.js";
|
|
26
|
+
import Input from "./Input.svelte";
|
|
27
|
+
import { DEV } from "esm-env";
|
|
28
|
+
|
|
29
|
+
type RangeValue = { start: string | null; end: string | null };
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
value = $bindable(),
|
|
33
|
+
range = false,
|
|
34
|
+
time = false,
|
|
35
|
+
min,
|
|
36
|
+
max,
|
|
37
|
+
disabled = false,
|
|
38
|
+
size = "md",
|
|
39
|
+
variant = "primary",
|
|
40
|
+
name,
|
|
41
|
+
class: cls = "",
|
|
42
|
+
// ── Accepted for DatePicker compatibility, but the native picker owns these (ignored). ──
|
|
43
|
+
step: _step,
|
|
44
|
+
seconds: _seconds,
|
|
45
|
+
meridiem: _meridiem,
|
|
46
|
+
weekStart: _weekStart,
|
|
47
|
+
locale: _locale,
|
|
48
|
+
placeholder: _placeholder,
|
|
49
|
+
...rest
|
|
50
|
+
}: {
|
|
51
|
+
/** `YYYY-MM-DD` (single) or `YYYY-MM-DDTHH:MM` (`time`). Drop-in with DatePicker's single/datetime. */
|
|
52
|
+
value?: string | RangeValue | null;
|
|
53
|
+
range?: boolean;
|
|
54
|
+
time?: boolean;
|
|
55
|
+
min?: string;
|
|
56
|
+
max?: string;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
size?: Responsive<Size>;
|
|
59
|
+
variant?: Variant;
|
|
60
|
+
/** Native form field name — the `<input>` carries it; submits with no JS. */
|
|
61
|
+
name?: string;
|
|
62
|
+
class?: string;
|
|
63
|
+
// accepted-but-ignored
|
|
64
|
+
step?: StepSpec;
|
|
65
|
+
seconds?: boolean;
|
|
66
|
+
meridiem?: boolean;
|
|
67
|
+
weekStart?: 0 | 1;
|
|
68
|
+
locale?: string;
|
|
69
|
+
placeholder?: string;
|
|
70
|
+
} & Omit<
|
|
71
|
+
HTMLInputAttributes,
|
|
72
|
+
"type" | "value" | "size" | "min" | "max" | "name" | "class" | "disabled"
|
|
73
|
+
> = $props();
|
|
74
|
+
|
|
75
|
+
$effect(() => {
|
|
76
|
+
if (DEV && range) {
|
|
77
|
+
console.warn(
|
|
78
|
+
"DatePicker2: `range` has no native equivalent — falling back to a single date input. " +
|
|
79
|
+
"Use two DatePicker2s (start/end) or stay on DatePicker for range. See MIGRATION.md.",
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// The native control only takes a string. Coerce away a RangeValue (range isn't supported here).
|
|
85
|
+
const strValue = $derived(typeof value === "string" ? value : "");
|
|
86
|
+
function onInput(v: string) {
|
|
87
|
+
value = v;
|
|
88
|
+
}
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<Input
|
|
92
|
+
type={time ? "datetime-local" : "date"}
|
|
93
|
+
value={strValue}
|
|
94
|
+
oninput={(e) => onInput((e.currentTarget as HTMLInputElement).value)}
|
|
95
|
+
{min}
|
|
96
|
+
{max}
|
|
97
|
+
{name}
|
|
98
|
+
{disabled}
|
|
99
|
+
{size}
|
|
100
|
+
{variant}
|
|
101
|
+
class={cls}
|
|
102
|
+
{...rest}
|
|
103
|
+
/>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
2
|
+
import type { Size } from "../types/sizes.js";
|
|
3
|
+
import type { Responsive } from "../types/responsive.js";
|
|
4
|
+
import type { Variant } from "../types/variants.js";
|
|
5
|
+
import type { StepSpec } from "../types/time.js";
|
|
6
|
+
type RangeValue = {
|
|
7
|
+
start: string | null;
|
|
8
|
+
end: string | null;
|
|
9
|
+
};
|
|
10
|
+
type $$ComponentProps = {
|
|
11
|
+
/** `YYYY-MM-DD` (single) or `YYYY-MM-DDTHH:MM` (`time`). Drop-in with DatePicker's single/datetime. */
|
|
12
|
+
value?: string | RangeValue | null;
|
|
13
|
+
range?: boolean;
|
|
14
|
+
time?: boolean;
|
|
15
|
+
min?: string;
|
|
16
|
+
max?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
size?: Responsive<Size>;
|
|
19
|
+
variant?: Variant;
|
|
20
|
+
/** Native form field name — the `<input>` carries it; submits with no JS. */
|
|
21
|
+
name?: string;
|
|
22
|
+
class?: string;
|
|
23
|
+
step?: StepSpec;
|
|
24
|
+
seconds?: boolean;
|
|
25
|
+
meridiem?: boolean;
|
|
26
|
+
weekStart?: 0 | 1;
|
|
27
|
+
locale?: string;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
} & Omit<HTMLInputAttributes, "type" | "value" | "size" | "min" | "max" | "name" | "class" | "disabled">;
|
|
30
|
+
declare const DatePicker2: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
31
|
+
type DatePicker2 = ReturnType<typeof DatePicker2>;
|
|
32
|
+
export default DatePicker2;
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export { default as Disclosure } from "./components/Disclosure.svelte";
|
|
|
72
72
|
export { default as Accordion } from "./components/Accordion.svelte";
|
|
73
73
|
export { default as Disclosure2 } from "./components/Disclosure2.svelte";
|
|
74
74
|
export { default as Accordion2 } from "./components/Accordion2.svelte";
|
|
75
|
+
export { default as DatePicker2 } from "./components/DatePicker2.svelte";
|
|
75
76
|
export { default as SideBarMenu } from "./components/SideBarMenu/SideBarMenu.svelte";
|
|
76
77
|
export type { SideBarMenuItem, SideBarMenuBadge, SideBarMenuBadgeVariant, SideBarMenuApi, SideBarMenuMode, SideBarMenuActiveRule, } from "./components/SideBarMenu/SideBarMenu.svelte";
|
|
77
78
|
export { Breadcrumbs } from "./components/Breadcrumbs/index.js";
|
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ export { default as Accordion } from "./components/Accordion.svelte";
|
|
|
71
71
|
// Native-first, no-JS/SSR-correct variants (transitional `*2` — see MIGRATION.md).
|
|
72
72
|
export { default as Disclosure2 } from "./components/Disclosure2.svelte";
|
|
73
73
|
export { default as Accordion2 } from "./components/Accordion2.svelte";
|
|
74
|
+
export { default as DatePicker2 } from "./components/DatePicker2.svelte";
|
|
74
75
|
// Navigation Components
|
|
75
76
|
export { default as SideBarMenu } from "./components/SideBarMenu/SideBarMenu.svelte";
|
|
76
77
|
export { Breadcrumbs } from "./components/Breadcrumbs/index.js";
|
package/docs/components.md
CHANGED
|
@@ -415,6 +415,23 @@ snaps to canonical on blur.
|
|
|
415
415
|
inject `parse`/`format`/`validate` backed by a phone library (e.g. `libphonenumber-js`); the
|
|
416
416
|
component bundles none.
|
|
417
417
|
|
|
418
|
+
### DatePicker2 (native-first)
|
|
419
|
+
|
|
420
|
+
**No-JS / SSR-correct** date entry: reuses `Input` with a real `<input type="date">` (or
|
|
421
|
+
`datetime-local` in `time` mode), so it works without JavaScript, pops the browser's native picker,
|
|
422
|
+
and submits via `name`. The field **frame** is pixel-identical to `DatePicker` (same `Input`).
|
|
423
|
+
|
|
424
|
+
- **Location**: `src/lib/components/DatePicker2.svelte`
|
|
425
|
+
- **Props**: drop-in superset of `DatePicker`'s single/datetime use — `value` (`YYYY-MM-DD` or
|
|
426
|
+
`YYYY-MM-DDTHH:MM`, identical format), `time`, `min`, `max`, `size`, `variant`, `disabled`, `name`,
|
|
427
|
+
`class`.
|
|
428
|
+
- **Caveat (unlike the other `*2`)**: the native control renders its value as **editable segments**
|
|
429
|
+
with the browser's picker indicator, so the trigger *content* is not a pixel match for
|
|
430
|
+
`DatePicker`'s formatted label — only the frame is. `range` has **no native equivalent** (falls
|
|
431
|
+
back to a single input with a dev warning); `step`/`seconds`/`meridiem`/`weekStart`/`locale`/
|
|
432
|
+
`placeholder` are accepted but ignored (the OS owns the picker). See `MIGRATION.md`.
|
|
433
|
+
- **Transitional**: ships alongside `DatePicker` under the `2` suffix.
|
|
434
|
+
|
|
418
435
|
## Navigation
|
|
419
436
|
|
|
420
437
|
### Breadcrumbs
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Native-first overlays — design note (Popup2 / Menu2 / Dialog2)
|
|
2
|
+
|
|
3
|
+
Status: **parked for a decision** (2026-10-24). The field-shaped native-first `*2` variants
|
|
4
|
+
(`Select2`, `Disclosure2`/`Accordion2`, `DatePicker2`) shipped; the **overlays** need a call on a
|
|
5
|
+
cross-browser tradeoff before they're worth building, because unlike the others they can't be made
|
|
6
|
+
both pixel-perfect *and* robustly no-JS today.
|
|
7
|
+
|
|
8
|
+
## Why the overlays are different
|
|
9
|
+
|
|
10
|
+
The shipped `*2` components lean on native elements that are **Baseline** and fully
|
|
11
|
+
self-positioning: `<select>`, `<details>`, `<input type=date>`. They need no placement logic — the
|
|
12
|
+
browser lays them out. `Popup`/`Menu`/`Dialog` are **anchored, top-layer overlays**: their whole job
|
|
13
|
+
is to appear *next to a trigger*, flipping/ shifting against the viewport. Today's `Popup` does both
|
|
14
|
+
halves in **JavaScript** — the Popover API for the top layer, and our `anchored` action for placement.
|
|
15
|
+
|
|
16
|
+
A no-JS rebuild would need:
|
|
17
|
+
|
|
18
|
+
1. **Toggle + top layer, no JS** — the **`popover` attribute** + a `popovertarget` button. This is
|
|
19
|
+
Baseline (2024): a `<button popovertarget="x">` opens/closes `<div popover id="x">` with
|
|
20
|
+
light-dismiss and top-layer, zero script. ✅ Solid.
|
|
21
|
+
2. **Placement next to the trigger, no JS** — **CSS anchor positioning** (`anchor-name` /
|
|
22
|
+
`position-anchor` / `position-area` / `position-try`). This is where it breaks down: Chromium has
|
|
23
|
+
it, Safari shipped it recently, **Firefox is still partial/flagged**. Without it, a `popover` opens
|
|
24
|
+
but lands in its default (centered) position — not under the button.
|
|
25
|
+
|
|
26
|
+
So a no-JS `Menu2` would toggle correctly everywhere but be **mispositioned in browsers lacking anchor
|
|
27
|
+
positioning** — the opposite of the "pixel-perfect" goal.
|
|
28
|
+
|
|
29
|
+
## Options
|
|
30
|
+
|
|
31
|
+
- **A — Progressive enhancement (recommended).** Ship `Menu2`/`Popup2` with `popover` +
|
|
32
|
+
`popovertarget` for the no-JS toggle, CSS anchor positioning for placement where supported, and a
|
|
33
|
+
sane `position-area` fallback. When JS is present (hydrated), optionally enhance with the existing
|
|
34
|
+
`anchored` engine for perfect placement everywhere. Honest caveat: no-JS placement is
|
|
35
|
+
Chromium/Safari-first until Firefox catches up. Best if php-svelte's target browsers are
|
|
36
|
+
Chromium/Safari.
|
|
37
|
+
- **B — Wait.** Hold the overlays until CSS anchor positioning is Baseline across the board, then the
|
|
38
|
+
no-JS story is clean everywhere. The field-shaped `*2` components already cover the common SSR form
|
|
39
|
+
needs (selects, disclosures, dates); menus/dialogs on a no-JS page are rarer.
|
|
40
|
+
- **C — Dialog-only now.** `Dialog2` as a `<dialog popover>` / `popover` panel is *centered* by
|
|
41
|
+
nature (a modal doesn't anchor to a trigger), so it dodges the anchor-positioning gap. A no-JS
|
|
42
|
+
"open this dialog" via `popovertarget` works cross-browser today; the modal **backdrop + focus
|
|
43
|
+
trap** still want `showModal()` (JS) for full fidelity, but a `popover` dialog is a reasonable no-JS
|
|
44
|
+
approximation. Menu/Popup stay parked.
|
|
45
|
+
|
|
46
|
+
## Recommendation
|
|
47
|
+
|
|
48
|
+
Decide between **A** (build now, Chromium/Safari-first no-JS placement, documented) and **C** (do
|
|
49
|
+
`Dialog2` now since it sidesteps anchoring, park `Menu2`/`Popup2` for **B**). Either way, `Menu2`
|
|
50
|
+
should be built on a `Popup2` primitive the same way `Menu` is built on `Popup`, and both reuse the
|
|
51
|
+
existing surface/panel classes so the open overlay stays pixel-identical to today's.
|
|
52
|
+
|
|
53
|
+
The key input needed: **which browsers must php-svelte support with JS disabled?** If it's
|
|
54
|
+
Chromium/Safari, go **A**. If Firefox-no-JS matters, go **B**/**C**.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spaethtech/svelte-ui",
|
|
3
|
-
"version": "0.21.1-dev.
|
|
3
|
+
"version": "0.21.1-dev.124.7b5c577",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/spaethtech/svelte-ui.git"
|
|
@@ -205,6 +205,10 @@
|
|
|
205
205
|
"types": "./dist/components/DatePicker.svelte.d.ts",
|
|
206
206
|
"svelte": "./dist/components/DatePicker.svelte"
|
|
207
207
|
},
|
|
208
|
+
"./date-picker2": {
|
|
209
|
+
"types": "./dist/components/DatePicker2.svelte.d.ts",
|
|
210
|
+
"svelte": "./dist/components/DatePicker2.svelte"
|
|
211
|
+
},
|
|
208
212
|
"./time-spinner": {
|
|
209
213
|
"types": "./dist/components/TimeSpinner.svelte.d.ts",
|
|
210
214
|
"svelte": "./dist/components/TimeSpinner.svelte"
|