@human-kit/ui 1.0.0-beta.0 → 1.0.0-beta.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.
- package/README.md +2 -0
- package/dist/FOCUS_STATE_CONTRACT.md +1 -0
- package/dist/accordion/root/accordion-root.svelte +15 -3
- package/dist/accordion/root/context.svelte.js +4 -4
- package/dist/accordion/types.d.ts +9 -2
- package/dist/autocomplete/list/autocomplete-list.svelte.d.ts +6 -0
- package/dist/calendar/root/context.svelte.js +8 -2
- package/dist/checkbox/root/checkbox-root.svelte +28 -11
- package/dist/checkbox/root/checkbox-root.svelte.d.ts +13 -0
- package/dist/clock/root/create-time-selection-state.svelte.d.ts +5 -0
- package/dist/clock/root/create-time-selection-state.svelte.js +113 -10
- package/dist/clock/root/wheel-options.d.ts +7 -3
- package/dist/clock/root/wheel-options.js +7 -15
- package/dist/clock/wheel-column/clock-wheel-column.svelte +10 -2
- package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +2 -1
- package/dist/collapsible/root/collapsible-root.svelte +9 -4
- package/dist/collapsible/types.d.ts +9 -0
- package/dist/combobox/input/combobox-input.svelte +12 -1
- package/dist/combobox/list/combobox-listbox.svelte +93 -1
- package/dist/combobox/list/combobox-listbox.svelte.d.ts +20 -0
- package/dist/combobox/root/combobox.svelte +118 -45
- package/dist/combobox/root/combobox.svelte.d.ts +11 -0
- package/dist/combobox/root/context.d.ts +12 -0
- package/dist/combobox/status/README.md +2 -2
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte +14 -2
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +7 -0
- package/dist/combobox/tags/combobox-tags.svelte +5 -2
- package/dist/combobox/tags/combobox-tags.svelte.d.ts +2 -0
- package/dist/combobox/trigger/combobox-trigger.svelte +4 -1
- package/dist/datepicker/README.md +3 -2
- package/dist/datepicker/root/date-picker-root.svelte +38 -2
- package/dist/datepicker/root/date-picker-root.svelte.d.ts +2 -0
- package/dist/datepicker/root/draft-evaluation.d.ts +7 -0
- package/dist/datepicker/root/draft-evaluation.js +2 -2
- package/dist/daterangepicker/root/date-range-picker-root.svelte +19 -1
- package/dist/daterangepicker/root/date-range-picker-root.svelte.d.ts +2 -0
- package/dist/dialog/README.md +9 -1
- package/dist/dialog/close/dialog-close.svelte +57 -0
- package/dist/dialog/close/dialog-close.svelte.d.ts +19 -0
- package/dist/dialog/content/dialog-content.svelte +2 -0
- package/dist/dialog/description/dialog-description.svelte +46 -0
- package/dist/dialog/description/dialog-description.svelte.d.ts +20 -0
- package/dist/dialog/index.d.ts +9 -0
- package/dist/dialog/index.js +3 -0
- package/dist/dialog/index.parts.d.ts +3 -0
- package/dist/dialog/index.parts.js +3 -0
- package/dist/dialog/root/context.d.ts +8 -0
- package/dist/dialog/root/dialog-root.svelte +58 -16
- package/dist/dialog/root/dialog-root.svelte.d.ts +10 -3
- package/dist/dialog/root/dialog-stack.d.ts +6 -22
- package/dist/dialog/root/dialog-stack.js +4 -33
- package/dist/dialog/title/dialog-title.svelte +43 -0
- package/dist/dialog/title/dialog-title.svelte.d.ts +21 -0
- package/dist/drawer/README.md +111 -0
- package/dist/drawer/body/drawer-body.svelte +47 -0
- package/dist/drawer/body/drawer-body.svelte.d.ts +32 -0
- package/dist/drawer/close/drawer-close.svelte +52 -0
- package/dist/drawer/close/drawer-close.svelte.d.ts +20 -0
- package/dist/drawer/content/drawer-content.svelte +597 -0
- package/dist/drawer/content/drawer-content.svelte.d.ts +28 -0
- package/dist/drawer/description/drawer-description.svelte +40 -0
- package/dist/drawer/description/drawer-description.svelte.d.ts +20 -0
- package/dist/drawer/indent/drawer-indent-background.svelte +36 -0
- package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +17 -0
- package/dist/drawer/indent/drawer-indent.svelte +59 -0
- package/dist/drawer/indent/drawer-indent.svelte.d.ts +32 -0
- package/dist/drawer/index.d.ts +49 -0
- package/dist/drawer/index.js +25 -0
- package/dist/drawer/index.parts.d.ts +14 -0
- package/dist/drawer/index.parts.js +15 -0
- package/dist/drawer/overlay/drawer-overlay.svelte +67 -0
- package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +12 -0
- package/dist/drawer/portal/drawer-portal.svelte +57 -0
- package/dist/drawer/portal/drawer-portal.svelte.d.ts +13 -0
- package/dist/drawer/root/context.d.ts +81 -0
- package/dist/drawer/root/context.js +20 -0
- package/dist/drawer/root/drawer-root.svelte +333 -0
- package/dist/drawer/root/drawer-root.svelte.d.ts +77 -0
- package/dist/drawer/root/drawer-stack.svelte.d.ts +73 -0
- package/dist/drawer/root/drawer-stack.svelte.js +113 -0
- package/dist/drawer/root/handle.svelte.d.ts +39 -0
- package/dist/drawer/root/handle.svelte.js +64 -0
- package/dist/drawer/root/keyboard-context.d.ts +13 -0
- package/dist/drawer/root/keyboard-context.js +8 -0
- package/dist/drawer/root/presence-context.d.ts +22 -0
- package/dist/drawer/root/presence-context.js +8 -0
- package/dist/drawer/root/snap-points.d.ts +68 -0
- package/dist/drawer/root/snap-points.js +120 -0
- package/dist/drawer/root/starting-style.svelte.d.ts +18 -0
- package/dist/drawer/root/starting-style.svelte.js +38 -0
- package/dist/drawer/root/types.d.ts +36 -0
- package/dist/drawer/root/types.js +1 -0
- package/dist/drawer/root/viewport-context.d.ts +2 -0
- package/dist/drawer/root/viewport-context.js +16 -0
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte +143 -0
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +22 -0
- package/dist/drawer/title/drawer-title.svelte +37 -0
- package/dist/drawer/title/drawer-title.svelte.d.ts +21 -0
- package/dist/drawer/trigger/drawer-trigger.svelte +90 -0
- package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +41 -0
- package/dist/drawer/viewport/drawer-viewport.svelte +69 -0
- package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +15 -0
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +88 -0
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +29 -0
- package/dist/hooks/use-virtual-focus.svelte.d.ts +9 -0
- package/dist/hooks/use-virtual-focus.svelte.js +7 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/listbox/item/listbox-item.svelte +8 -1
- package/dist/listbox/root/context.d.ts +30 -0
- package/dist/listbox/root/context.js +10 -0
- package/dist/listbox/root/listbox.svelte +291 -8
- package/dist/listbox/root/listbox.svelte.d.ts +35 -2
- package/dist/menu/content/menu-content.svelte +3 -1
- package/dist/menu/overlay/menu-overlay.svelte +1 -1
- package/dist/numberfield/root/number-field-root.svelte +2 -1
- package/dist/popover/content/popover-content.svelte +1 -1
- package/dist/popover/overlay/popover-overlay.svelte +1 -1
- package/dist/popover/root/popover-root.svelte +23 -11
- package/dist/popover/root/popover-root.svelte.d.ts +10 -2
- package/dist/primitives/floating.d.ts +7 -0
- package/dist/primitives/floating.js +6 -2
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/keyboard-navigation.js +3 -1
- package/dist/primitives/layer-stack.d.ts +29 -0
- package/dist/primitives/layer-stack.js +35 -0
- package/dist/primitives/list-virtualizer.d.ts +75 -0
- package/dist/primitives/list-virtualizer.js +59 -0
- package/dist/primitives/scroll-lock.d.ts +23 -3
- package/dist/primitives/scroll-lock.js +122 -9
- package/dist/primitives/swipe-gesture.d.ts +126 -0
- package/dist/primitives/swipe-gesture.js +351 -0
- package/dist/primitives/text.d.ts +8 -0
- package/dist/primitives/text.js +13 -0
- package/dist/switch/root/switch-root.svelte +23 -9
- package/dist/switch/root/switch-root.svelte.d.ts +9 -2
- package/dist/table/body/table-body.svelte +84 -9
- package/dist/table/cell/table-cell.svelte +1 -3
- package/dist/table/column/table-column.svelte +5 -1
- package/dist/table/column-resizer/table-column-resizer.svelte +1 -5
- package/dist/table/interactive-cell/table-interactive-cell.svelte +1 -3
- package/dist/table/root/context.svelte.js +99 -49
- package/dist/table/row/table-row.svelte +7 -7
- package/dist/table/sort-trigger/table-sort-trigger.svelte +5 -1
- package/dist/table/types.d.ts +6 -0
- package/dist/tabs/root/tabs-root.svelte +20 -6
- package/dist/tabs/types.d.ts +9 -0
- package/dist/timepicker/root/time-picker-root.svelte +11 -0
- package/dist/timepicker/root/time-picker-root.svelte.d.ts +2 -0
- package/dist/toggle-group/root/context.svelte.js +11 -4
- package/dist/toggle-group/root/toggle-group-root.svelte +19 -4
- package/dist/toggle-group/types.d.ts +9 -0
- package/dist/tree/root/context.svelte.js +6 -0
- package/dist/tree/root/tree-root.svelte +22 -8
- package/dist/tree/types.d.ts +13 -0
- package/package.json +227 -224
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@ Accessible, reusable UI components for **Svelte 5**.
|
|
|
5
5
|
Built with Svelte 5 runes, typed end to end, and shipped as native ESM with
|
|
6
6
|
per-component subpath exports so bundlers only include what you import.
|
|
7
7
|
|
|
8
|
+
**[Documentation and live demos → ui.human-kit.com](https://ui.human-kit.com)**
|
|
9
|
+
|
|
8
10
|
## Installation
|
|
9
11
|
|
|
10
12
|
```bash
|
|
@@ -56,6 +56,7 @@ The following components implement this contract:
|
|
|
56
56
|
|
|
57
57
|
- **Popover** — trigger + content, restore focus on close.
|
|
58
58
|
- **Dialog** — trigger + overlay/content, nested stack support.
|
|
59
|
+
- **Drawer** — trigger + overlay/content, shares the modal layer stack with Dialog. Restore also covers the `swipe` close reason (resolves to `pointer`), and retries the trigger focus after `ariaHideOutside` lifts `inert`.
|
|
59
60
|
- **DatePicker** — segment spinbuttons, trigger, popover (calendar).
|
|
60
61
|
- **TimePicker** — segment spinbuttons, trigger, popover (scrollable columns). Follows the same contract as DatePicker.
|
|
61
62
|
- **Calendar** — grid cells with roving tabindex.
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
id,
|
|
10
10
|
value = $bindable(),
|
|
11
11
|
defaultValue,
|
|
12
|
+
controlledValue = false,
|
|
12
13
|
onChange,
|
|
13
14
|
selectionMode = 'single',
|
|
14
15
|
disabled: disabledProp = false,
|
|
@@ -22,7 +23,10 @@
|
|
|
22
23
|
...restProps
|
|
23
24
|
}: AccordionRootProps = $props();
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
// Controlled-ness is NOT inferred from `value` being defined: `bind:value={items}` and
|
|
27
|
+
// `value={items}` are indistinguishable at runtime, so inferring it silently broke
|
|
28
|
+
// every `bind:value`. It is opt-in via `controlledValue` instead.
|
|
29
|
+
const isControlled = untrack(() => controlledValue);
|
|
26
30
|
const instanceId = untrack(() => id) ?? generatedId;
|
|
27
31
|
|
|
28
32
|
let rootRef: HTMLDivElement | null = $state(null);
|
|
@@ -31,7 +35,8 @@
|
|
|
31
35
|
createAccordionContext({
|
|
32
36
|
instanceId,
|
|
33
37
|
isControlled,
|
|
34
|
-
|
|
38
|
+
// `value` seeds the initial state whenever it is supplied, bound or not.
|
|
39
|
+
initialValue: untrack(() => value) ?? untrack(() => defaultValue),
|
|
35
40
|
selectionMode: (() => selectionMode)(),
|
|
36
41
|
isDisabled: (() => disabledProp)(),
|
|
37
42
|
orientation: (() => orientation)(),
|
|
@@ -75,8 +80,15 @@
|
|
|
75
80
|
accordion.setLoop(loop);
|
|
76
81
|
});
|
|
77
82
|
|
|
83
|
+
// Whether to adopt an incoming `value` is a separate question from who owns the state,
|
|
84
|
+
// so it is latched at init off the prop rather than off `controlledValue`: a parent
|
|
85
|
+
// that supplies `value` drives the accordion, bound or not. Latched, not reactive —
|
|
86
|
+
// re-checking `value !== undefined` would switch this on the moment our own write-back
|
|
87
|
+
// defines it, and the component would then re-adopt the echo of its own change.
|
|
88
|
+
const adoptsValueProp = untrack(() => value !== undefined);
|
|
89
|
+
|
|
78
90
|
$effect(() => {
|
|
79
|
-
if (!
|
|
91
|
+
if (!adoptsValueProp) return;
|
|
80
92
|
accordion.setOpenValues(value);
|
|
81
93
|
});
|
|
82
94
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
|
-
import { SvelteMap } from 'svelte/reactivity';
|
|
2
|
+
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
3
3
|
import { asCommand } from '../../internal/as-command.js';
|
|
4
4
|
const ACCORDION_CONTEXT_KEY = Symbol('accordion');
|
|
5
5
|
function normalizeIdSegment(value) {
|
|
@@ -9,7 +9,7 @@ function valuesMatch(left, right) {
|
|
|
9
9
|
return Object.is(left, right);
|
|
10
10
|
}
|
|
11
11
|
function normalizeValues(values, selectionMode, order = []) {
|
|
12
|
-
const normalized = new
|
|
12
|
+
const normalized = new SvelteSet();
|
|
13
13
|
if (selectionMode === 'single') {
|
|
14
14
|
const orderedValue = order.find((orderedItem) => (values ?? []).some((candidate) => valuesMatch(candidate, orderedItem)));
|
|
15
15
|
const fallbackValue = (values ?? []).find((candidate) => !order.some((orderedItem) => valuesMatch(candidate, orderedItem)));
|
|
@@ -138,7 +138,7 @@ export function createAccordionContext(options) {
|
|
|
138
138
|
function reconcileOpen(changedValue, changeOptions) {
|
|
139
139
|
if (isControlled)
|
|
140
140
|
return;
|
|
141
|
-
const nextValues = new
|
|
141
|
+
const nextValues = new SvelteSet(openValues);
|
|
142
142
|
let removedValue;
|
|
143
143
|
for (const openValue of openValues) {
|
|
144
144
|
const registeredItem = items.get(openValue);
|
|
@@ -228,7 +228,7 @@ export function createAccordionContext(options) {
|
|
|
228
228
|
if (isItemDisabled(value))
|
|
229
229
|
return null;
|
|
230
230
|
const isValueOpen = openValues.has(value);
|
|
231
|
-
const nextValues = new
|
|
231
|
+
const nextValues = new SvelteSet(openValues);
|
|
232
232
|
if (selectionMode === 'single') {
|
|
233
233
|
if (isValueOpen) {
|
|
234
234
|
if (disallowEmptySelection)
|
|
@@ -3,10 +3,17 @@ import type { HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
|
3
3
|
import type { AccordionContext, AccordionOrientation, AccordionSelectionMode, AccordionValue } from './root/context.svelte';
|
|
4
4
|
export type { AccordionContext, AccordionOrientation, AccordionSelectionMode, AccordionValue } from './root/context.svelte';
|
|
5
5
|
export type AccordionRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
6
|
-
/**
|
|
6
|
+
/** List of open item values. Two-way by default — use `bind:value`. */
|
|
7
7
|
value?: AccordionValue[];
|
|
8
|
-
/** Initially open item values when
|
|
8
|
+
/** Initially open item values, for when `value` is not supplied. */
|
|
9
9
|
defaultValue?: AccordionValue[];
|
|
10
|
+
/**
|
|
11
|
+
* Opt into fully controlled state: the component stops writing back to `value` and
|
|
12
|
+
* only reports through `onChange`, so the parent can reject a change by not flowing
|
|
13
|
+
* the new value back down. Off by default, because `bind:value` — the common case —
|
|
14
|
+
* needs the write-back to work at all.
|
|
15
|
+
*/
|
|
16
|
+
controlledValue?: boolean;
|
|
10
17
|
/** Called with the new list of open item values after a user toggle. */
|
|
11
18
|
onChange?: (value: AccordionValue[]) => void;
|
|
12
19
|
/** Whether one (`'single'`) or several (`'multiple'`) panels can be open at once. */
|
|
@@ -9,7 +9,9 @@ declare function $$render<T extends object = object>(): {
|
|
|
9
9
|
selectionMode?: "single" | "multiple";
|
|
10
10
|
value?: Iterable<string | number>;
|
|
11
11
|
defaultValue?: Iterable<string | number>;
|
|
12
|
+
controlledValue?: boolean;
|
|
12
13
|
children?: Snippet<[]> | Snippet<[object]> | undefined;
|
|
14
|
+
header?: Snippet;
|
|
13
15
|
class?: string;
|
|
14
16
|
id?: string;
|
|
15
17
|
'aria-label'?: string;
|
|
@@ -17,6 +19,10 @@ declare function $$render<T extends object = object>(): {
|
|
|
17
19
|
disableFocusHandling?: boolean;
|
|
18
20
|
loop?: boolean;
|
|
19
21
|
typeahead?: boolean;
|
|
22
|
+
virtualizer?: {
|
|
23
|
+
rowHeight?: number;
|
|
24
|
+
overscan?: number;
|
|
25
|
+
} | undefined;
|
|
20
26
|
} & {
|
|
21
27
|
context?: ListBoxContext;
|
|
22
28
|
element?: HTMLElement;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/* eslint-disable svelte/prefer-svelte-reactivity --
|
|
2
|
+
* The Map/Set instances below are transient collections rebuilt inside `$derived`
|
|
3
|
+
* getters. Svelte forbids mutating a reactive collection (SvelteMap/SvelteSet)
|
|
4
|
+
* inside a derived (state_unsafe_mutation), and reactivity here is already driven
|
|
5
|
+
* by a version signal + reassignment — so plain Map/Set is intentional and correct.
|
|
6
|
+
*/
|
|
1
7
|
import { getContext, setContext } from 'svelte';
|
|
2
8
|
import { asCommand } from '../../internal/as-command.js';
|
|
3
9
|
import { addDays, addMonths, buildMonthGrid, compareDates, formatCalendarDate, formatMonthHeading, getTodayUtcDate, getWeekdayLabels, isValidCalendarDateValue, parseCalendarDate, resolveFirstDayOfWeek, startOfMonth } from './date-utils';
|
|
@@ -745,9 +751,9 @@ export function createCalendarContext(options) {
|
|
|
745
751
|
break;
|
|
746
752
|
case 'Enter':
|
|
747
753
|
case ' ':
|
|
748
|
-
// Legacy key value emitted by some older browsers/IMEs; kept in sync
|
|
749
|
-
// with the body-cell press-state handling, which accepts it too.
|
|
750
754
|
case 'Spacebar':
|
|
755
|
+
// 'Spacebar' is a legacy key value emitted by some older browsers/IMEs;
|
|
756
|
+
// kept in sync with the body-cell press-state handling, which accepts it too.
|
|
751
757
|
event.preventDefault();
|
|
752
758
|
setFocusVisible(true);
|
|
753
759
|
if (selectionMode === 'range' &&
|
|
@@ -27,10 +27,23 @@
|
|
|
27
27
|
value?: string;
|
|
28
28
|
/** Associates the hidden input with a form by id. */
|
|
29
29
|
form?: string;
|
|
30
|
+
/** Checked state. Two-way by default — use `bind:checked`. */
|
|
30
31
|
checked?: boolean;
|
|
32
|
+
/** Initial checked state, for when `checked` is not supplied. */
|
|
31
33
|
defaultChecked?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Opt into fully controlled `checked`: the component stops writing back to the prop
|
|
36
|
+
* and only reports through `onCheckedChange`, so the parent can reject a change by
|
|
37
|
+
* not flowing the new value back down. Off by default, because `bind:checked` —
|
|
38
|
+
* the common case — needs the write-back to work at all.
|
|
39
|
+
*/
|
|
40
|
+
controlledChecked?: boolean;
|
|
41
|
+
/** Indeterminate state. Two-way by default — use `bind:indeterminate`. */
|
|
32
42
|
indeterminate?: boolean;
|
|
43
|
+
/** Initial indeterminate state, for when `indeterminate` is not supplied. */
|
|
33
44
|
defaultIndeterminate?: boolean;
|
|
45
|
+
/** Opt into fully controlled `indeterminate`. See `controlledChecked`. */
|
|
46
|
+
controlledIndeterminate?: boolean;
|
|
34
47
|
onCheckedChange?: (checked: boolean) => void;
|
|
35
48
|
onIndeterminateChange?: (indeterminate: boolean) => void;
|
|
36
49
|
disabled?: boolean;
|
|
@@ -88,8 +101,10 @@
|
|
|
88
101
|
form,
|
|
89
102
|
checked = $bindable(),
|
|
90
103
|
defaultChecked = false,
|
|
104
|
+
controlledChecked = false,
|
|
91
105
|
indeterminate = $bindable(),
|
|
92
106
|
defaultIndeterminate = false,
|
|
107
|
+
controlledIndeterminate = false,
|
|
93
108
|
onCheckedChange,
|
|
94
109
|
onIndeterminateChange,
|
|
95
110
|
disabled = false,
|
|
@@ -149,23 +164,25 @@
|
|
|
149
164
|
}
|
|
150
165
|
});
|
|
151
166
|
|
|
152
|
-
// Controlled-ness is
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
if (!
|
|
167
|
+
// Controlled-ness is NOT inferred from the props being defined: `bind:checked={value}`
|
|
168
|
+
// and `checked={value}` are indistinguishable at runtime, so inferring it silently
|
|
169
|
+
// broke every `bind:checked` seeded with `false`. It is opt-in per prop instead.
|
|
170
|
+
// Write the initial state back so `bind:` parents see the resolved default. Read
|
|
171
|
+
// untracked: this is a deliberate one-time seed at init, not a reactive mirror.
|
|
172
|
+
if (!untrack(() => controlledChecked)) {
|
|
158
173
|
checked = initialState === 'checked';
|
|
159
174
|
}
|
|
160
175
|
|
|
161
|
-
if (!
|
|
176
|
+
if (!untrack(() => controlledIndeterminate)) {
|
|
162
177
|
indeterminate = initialState === 'indeterminate';
|
|
163
178
|
}
|
|
164
179
|
|
|
180
|
+
// The prop wins whenever it is supplied — that covers both `bind:` and a plain
|
|
181
|
+
// value — and the internal state only carries the fully uncontrolled case.
|
|
165
182
|
const currentState = $derived.by(() =>
|
|
166
183
|
resolveState(
|
|
167
|
-
|
|
168
|
-
|
|
184
|
+
controlledChecked ? Boolean(checked) : (checked ?? checkedInternal),
|
|
185
|
+
controlledIndeterminate ? Boolean(indeterminate) : (indeterminate ?? indeterminateInternal)
|
|
169
186
|
)
|
|
170
187
|
);
|
|
171
188
|
|
|
@@ -184,12 +201,12 @@
|
|
|
184
201
|
const previousChecked = currentChecked;
|
|
185
202
|
const previousIndeterminate = currentIndeterminate;
|
|
186
203
|
|
|
187
|
-
if (!
|
|
204
|
+
if (!controlledChecked) {
|
|
188
205
|
checkedInternal = nextChecked;
|
|
189
206
|
checked = nextChecked;
|
|
190
207
|
}
|
|
191
208
|
|
|
192
|
-
if (!
|
|
209
|
+
if (!controlledIndeterminate) {
|
|
193
210
|
indeterminateInternal = nextIndeterminate;
|
|
194
211
|
indeterminate = nextIndeterminate;
|
|
195
212
|
}
|
|
@@ -7,10 +7,23 @@ type CheckboxRootProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'cla
|
|
|
7
7
|
value?: string;
|
|
8
8
|
/** Associates the hidden input with a form by id. */
|
|
9
9
|
form?: string;
|
|
10
|
+
/** Checked state. Two-way by default — use `bind:checked`. */
|
|
10
11
|
checked?: boolean;
|
|
12
|
+
/** Initial checked state, for when `checked` is not supplied. */
|
|
11
13
|
defaultChecked?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Opt into fully controlled `checked`: the component stops writing back to the prop
|
|
16
|
+
* and only reports through `onCheckedChange`, so the parent can reject a change by
|
|
17
|
+
* not flowing the new value back down. Off by default, because `bind:checked` —
|
|
18
|
+
* the common case — needs the write-back to work at all.
|
|
19
|
+
*/
|
|
20
|
+
controlledChecked?: boolean;
|
|
21
|
+
/** Indeterminate state. Two-way by default — use `bind:indeterminate`. */
|
|
12
22
|
indeterminate?: boolean;
|
|
23
|
+
/** Initial indeterminate state, for when `indeterminate` is not supplied. */
|
|
13
24
|
defaultIndeterminate?: boolean;
|
|
25
|
+
/** Opt into fully controlled `indeterminate`. See `controlledChecked`. */
|
|
26
|
+
controlledIndeterminate?: boolean;
|
|
14
27
|
onCheckedChange?: (checked: boolean) => void;
|
|
15
28
|
onIndeterminateChange?: (indeterminate: boolean) => void;
|
|
16
29
|
disabled?: boolean;
|
|
@@ -90,6 +90,11 @@ export type TimeSelectionState = {
|
|
|
90
90
|
* values entirely (TimePicker's historical policy, now applied to both); and
|
|
91
91
|
* externally provided values (controlled `value` prop or `defaultValue`) are
|
|
92
92
|
* normalized to `null` when malformed or out of range before being adopted.
|
|
93
|
+
* - Wheel selection is the one path that adjusts rather than rejects: a wheel
|
|
94
|
+
* option is offered whenever *some* in-range time still fits it, and picking
|
|
95
|
+
* it clamps the less significant segments onto the boundary (hour `17` under
|
|
96
|
+
* a `17:00` max commits `17:00`, not `null`). Without this the boundary hour
|
|
97
|
+
* was unreachable unless the minute already happened to be low enough.
|
|
93
98
|
* - `isEditable` differs: TimePicker also blocks mutations while `readonly`;
|
|
94
99
|
* Clock has no readonly concept and only checks `disabled`.
|
|
95
100
|
* - TimePicker layers a multi-digit typing buffer on top of this state via the
|
|
@@ -2,7 +2,24 @@ import { untrack } from 'svelte';
|
|
|
2
2
|
import { fromStore } from 'svelte/store';
|
|
3
3
|
import { useLocaleContextOptional } from '../../locale-provider/context';
|
|
4
4
|
import { buildWheelOptions } from './wheel-options';
|
|
5
|
-
import { buildTimePartsFromDraft, clampToStep, createEmptyTimePickerDraft, formatTimePickerValue, getRequiredSegments, getSegmentLabel, isSegmentValueEmpty, isTimeOutOfRange, isValidTimePickerValue, normalizeSegmentNumberInput, normalizeTimePickerValue, toDraftFromTimeValue } from './time-utils';
|
|
5
|
+
import { buildTimePartsFromDraft, clampToStep, createEmptyTimePickerDraft, formatTimePickerValue, getRequiredSegments, getSegmentLabel, isSegmentValueEmpty, isTimeOutOfRange, isValidTimePickerValue, normalizeSegmentNumberInput, normalizeTimePickerValue, parseTimePickerValue, toDraftFromTimeValue } from './time-utils';
|
|
6
|
+
/**
|
|
7
|
+
* Editable segments ordered from most to least significant. Range checks and
|
|
8
|
+
* boundary clamping both need to know which segments a given column is free to
|
|
9
|
+
* move: picking an hour may rewrite the minute, never the other way around.
|
|
10
|
+
*/
|
|
11
|
+
const SEGMENT_SIGNIFICANCE = [
|
|
12
|
+
'dayPeriod',
|
|
13
|
+
'hour',
|
|
14
|
+
'minute',
|
|
15
|
+
'second'
|
|
16
|
+
];
|
|
17
|
+
function getLessSignificantSegments(type) {
|
|
18
|
+
const index = SEGMENT_SIGNIFICANCE.indexOf(type);
|
|
19
|
+
if (index < 0)
|
|
20
|
+
return [];
|
|
21
|
+
return SEGMENT_SIGNIFICANCE.slice(index + 1);
|
|
22
|
+
}
|
|
6
23
|
/**
|
|
7
24
|
* Shared time-selection state used by both `Clock.Root` and `TimePicker.Root`.
|
|
8
25
|
*
|
|
@@ -20,6 +37,11 @@ import { buildTimePartsFromDraft, clampToStep, createEmptyTimePickerDraft, forma
|
|
|
20
37
|
* values entirely (TimePicker's historical policy, now applied to both); and
|
|
21
38
|
* externally provided values (controlled `value` prop or `defaultValue`) are
|
|
22
39
|
* normalized to `null` when malformed or out of range before being adopted.
|
|
40
|
+
* - Wheel selection is the one path that adjusts rather than rejects: a wheel
|
|
41
|
+
* option is offered whenever *some* in-range time still fits it, and picking
|
|
42
|
+
* it clamps the less significant segments onto the boundary (hour `17` under
|
|
43
|
+
* a `17:00` max commits `17:00`, not `null`). Without this the boundary hour
|
|
44
|
+
* was unreachable unless the minute already happened to be low enough.
|
|
23
45
|
* - `isEditable` differs: TimePicker also blocks mutations while `readonly`;
|
|
24
46
|
* Clock has no readonly concept and only checks `disabled`.
|
|
25
47
|
* - TimePicker layers a multi-digit typing buffer on top of this state via the
|
|
@@ -147,6 +169,11 @@ export function createTimeSelectionState(options) {
|
|
|
147
169
|
function setSegmentValue(type, nextValue) {
|
|
148
170
|
if (!options.isEditable())
|
|
149
171
|
return;
|
|
172
|
+
writeSegmentValue(type, nextValue);
|
|
173
|
+
commitFromDraft();
|
|
174
|
+
}
|
|
175
|
+
/** Normalizes and writes a segment into the draft without committing it. */
|
|
176
|
+
function writeSegmentValue(type, nextValue) {
|
|
150
177
|
options.onBeforeSegmentMutation?.(type);
|
|
151
178
|
if (type === 'dayPeriod') {
|
|
152
179
|
const normalized = nextValue.trim().toUpperCase();
|
|
@@ -187,7 +214,6 @@ export function createTimeSelectionState(options) {
|
|
|
187
214
|
segmentDraft.dayPeriod = 'AM';
|
|
188
215
|
}
|
|
189
216
|
}
|
|
190
|
-
commitFromDraft();
|
|
191
217
|
}
|
|
192
218
|
function commitFromDraft() {
|
|
193
219
|
const granularity = options.granularity();
|
|
@@ -219,15 +245,50 @@ export function createTimeSelectionState(options) {
|
|
|
219
245
|
: createEmptyTimePickerDraft();
|
|
220
246
|
options.onDraftReplaced?.();
|
|
221
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Pulls the segments below `changedType` onto the range boundary when the
|
|
250
|
+
* draft overshot it. Picking hour `17` under a `17:00` max leaves the minute
|
|
251
|
+
* on whatever it was (`17:30`); rather than refusing the commit, the minute
|
|
252
|
+
* moves to the boundary's own (`17:00`). Only runs when the boundary shares
|
|
253
|
+
* the segments at or above `changedType`, so it can never rewrite the
|
|
254
|
+
* selection the user just made.
|
|
255
|
+
*/
|
|
256
|
+
function clampDraftToRangeBoundary(changedType) {
|
|
257
|
+
const granularity = options.granularity();
|
|
258
|
+
const parts = buildTimePartsFromDraft(segmentDraft, granularity, resolvedHourCycle);
|
|
259
|
+
if (!parts)
|
|
260
|
+
return;
|
|
261
|
+
const candidate = formatTimePickerValue(parts, granularity);
|
|
262
|
+
const overshootsMax = isTimeOutOfRange(candidate, undefined, normalizedMaxValue, granularity);
|
|
263
|
+
const undershootsMin = isTimeOutOfRange(candidate, normalizedMinValue, undefined, granularity);
|
|
264
|
+
if (!overshootsMax && !undershootsMin)
|
|
265
|
+
return;
|
|
266
|
+
const boundary = overshootsMax ? normalizedMaxValue : normalizedMinValue;
|
|
267
|
+
if (!boundary)
|
|
268
|
+
return;
|
|
269
|
+
const boundaryParts = parseTimePickerValue(boundary);
|
|
270
|
+
if (!boundaryParts)
|
|
271
|
+
return;
|
|
272
|
+
// The hour is the only segment above `minute`/`second` that can differ here;
|
|
273
|
+
// if it does, the boundary belongs to another hour and its minutes say
|
|
274
|
+
// nothing about this one.
|
|
275
|
+
const lessSignificant = getLessSignificantSegments(changedType);
|
|
276
|
+
if (lessSignificant.includes('minute') && boundaryParts.hour !== parts.hour)
|
|
277
|
+
return;
|
|
278
|
+
for (const segment of lessSignificant) {
|
|
279
|
+
if (segment === 'minute')
|
|
280
|
+
segmentDraft.minute = String(boundaryParts.minute);
|
|
281
|
+
if (segment === 'second')
|
|
282
|
+
segmentDraft.second = String(boundaryParts.second);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
222
285
|
function selectWheelValue(type, optionValue) {
|
|
223
286
|
if (!options.isEditable())
|
|
224
287
|
return;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
setSegmentValue(type, optionValue);
|
|
230
|
-
}
|
|
288
|
+
const nextValue = type === 'dayPeriod' ? optionValue.toUpperCase() : optionValue;
|
|
289
|
+
writeSegmentValue(type, nextValue);
|
|
290
|
+
clampDraftToRangeBoundary(type);
|
|
291
|
+
commitFromDraft();
|
|
231
292
|
}
|
|
232
293
|
function getSelectedWheelValue(type) {
|
|
233
294
|
const selected = getSegmentValue(type);
|
|
@@ -248,6 +309,22 @@ export function createTimeSelectionState(options) {
|
|
|
248
309
|
return null;
|
|
249
310
|
return formatTimePickerValue(parts, granularity);
|
|
250
311
|
};
|
|
312
|
+
// An option is out of range only when EVERY time it can still produce is out
|
|
313
|
+
// of range. Testing the single candidate built from the current draft would
|
|
314
|
+
// disable the boundary option whenever a less significant segment happens to
|
|
315
|
+
// overshoot — with max `17:00` and the minute sitting on `30`, hour `17` would
|
|
316
|
+
// read as `17:30` and never become selectable. Comparing the earliest/latest
|
|
317
|
+
// time the option spans keeps the boundary reachable; `selectWheelValue`
|
|
318
|
+
// clamps the less significant segments when the option is committed.
|
|
319
|
+
const isOptionOutOfRange = (partial) => {
|
|
320
|
+
const earliest = getCandidateFromPartial(fillLessSignificant(type, partial, 'earliest'));
|
|
321
|
+
const latest = getCandidateFromPartial(fillLessSignificant(type, partial, 'latest'));
|
|
322
|
+
if (!earliest || !latest)
|
|
323
|
+
return false;
|
|
324
|
+
const startsAfterMax = isTimeOutOfRange(earliest, undefined, normalizedMaxValue, granularity);
|
|
325
|
+
const endsBeforeMin = isTimeOutOfRange(latest, normalizedMinValue, undefined, granularity);
|
|
326
|
+
return startsAfterMax || endsBeforeMin;
|
|
327
|
+
};
|
|
251
328
|
return buildWheelOptions({
|
|
252
329
|
type,
|
|
253
330
|
granularity,
|
|
@@ -256,11 +333,37 @@ export function createTimeSelectionState(options) {
|
|
|
256
333
|
minuteStep: options.minuteStep(),
|
|
257
334
|
secondStep: options.secondStep(),
|
|
258
335
|
hasRangeBounds,
|
|
259
|
-
|
|
260
|
-
isOutOfRange: (candidate) => isTimeOutOfRange(candidate, normalizedMinValue, normalizedMaxValue, granularity),
|
|
336
|
+
isPartialOutOfRange: isOptionOutOfRange,
|
|
261
337
|
locale: resolvedLocale
|
|
262
338
|
});
|
|
263
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Fills the segments below `type` with the lowest / highest value they can
|
|
342
|
+
* take, so the caller can measure the whole span an option covers. In the
|
|
343
|
+
* 12-hour cycle the lowest hour is `12` (midnight / noon), not `1`.
|
|
344
|
+
*/
|
|
345
|
+
function fillLessSignificant(type, partial, edge) {
|
|
346
|
+
const filled = { ...partial };
|
|
347
|
+
for (const segment of getLessSignificantSegments(type)) {
|
|
348
|
+
if (segment === 'hour') {
|
|
349
|
+
filled.hour =
|
|
350
|
+
edge === 'earliest'
|
|
351
|
+
? resolvedHourCycle === 12
|
|
352
|
+
? '12'
|
|
353
|
+
: '0'
|
|
354
|
+
: resolvedHourCycle === 12
|
|
355
|
+
? '11'
|
|
356
|
+
: '23';
|
|
357
|
+
}
|
|
358
|
+
else if (segment === 'minute') {
|
|
359
|
+
filled.minute = edge === 'earliest' ? '0' : '59';
|
|
360
|
+
}
|
|
361
|
+
else if (segment === 'second') {
|
|
362
|
+
filled.second = edge === 'earliest' ? '0' : '59';
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return filled;
|
|
366
|
+
}
|
|
264
367
|
function getSegmentLabelByType(type) {
|
|
265
368
|
return getSegmentLabel(type, resolvedLocale);
|
|
266
369
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TimePickerDraft, type TimePickerEditableSegmentType, type TimePickerGranularity, type TimePickerHourCycle
|
|
1
|
+
import { type TimePickerDraft, type TimePickerEditableSegmentType, type TimePickerGranularity, type TimePickerHourCycle } from './time-utils';
|
|
2
2
|
export type WheelOption = {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|
|
@@ -12,7 +12,11 @@ export declare function buildWheelOptions(params: {
|
|
|
12
12
|
minuteStep: number;
|
|
13
13
|
secondStep: number;
|
|
14
14
|
hasRangeBounds: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Whether fixing this one segment leaves no in-range time at all. Receives the
|
|
17
|
+
* partial draft for the option; the caller decides how much freedom the
|
|
18
|
+
* remaining segments have (see `create-time-selection-state`).
|
|
19
|
+
*/
|
|
20
|
+
isPartialOutOfRange: (partial: Partial<TimePickerDraft>) => boolean;
|
|
17
21
|
locale?: string;
|
|
18
22
|
}): WheelOption[];
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { getLocalizedDayPeriod } from './time-utils';
|
|
2
2
|
export function buildWheelOptions(params) {
|
|
3
|
-
const { type, hourCycle, hourStep, minuteStep, secondStep, hasRangeBounds,
|
|
3
|
+
const { type, hourCycle, hourStep, minuteStep, secondStep, hasRangeBounds, isPartialOutOfRange, locale } = params;
|
|
4
4
|
const options = [];
|
|
5
5
|
if (type === 'dayPeriod') {
|
|
6
6
|
for (const option of ['AM', 'PM']) {
|
|
7
|
-
const disabled = hasRangeBounds
|
|
8
|
-
? (() => {
|
|
9
|
-
const candidate = getCandidateFromPartial({ dayPeriod: option });
|
|
10
|
-
return candidate ? isOutOfRange(candidate) : false;
|
|
11
|
-
})()
|
|
12
|
-
: false;
|
|
7
|
+
const disabled = hasRangeBounds ? isPartialOutOfRange({ dayPeriod: option }) : false;
|
|
13
8
|
options.push({
|
|
14
9
|
value: option,
|
|
15
10
|
label: locale ? getLocalizedDayPeriod(locale, option) : option,
|
|
@@ -45,14 +40,11 @@ export function buildWheelOptions(params) {
|
|
|
45
40
|
for (let current = min; current <= max; current += step) {
|
|
46
41
|
const valueString = String(current);
|
|
47
42
|
const disabled = hasRangeBounds
|
|
48
|
-
? (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
:
|
|
52
|
-
|
|
53
|
-
: { second: valueString });
|
|
54
|
-
return candidate ? isOutOfRange(candidate) : false;
|
|
55
|
-
})()
|
|
43
|
+
? isPartialOutOfRange(type === 'hour'
|
|
44
|
+
? { hour: valueString }
|
|
45
|
+
: type === 'minute'
|
|
46
|
+
? { minute: valueString }
|
|
47
|
+
: { second: valueString })
|
|
56
48
|
: false;
|
|
57
49
|
options.push({
|
|
58
50
|
value: valueString,
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
| 'onclick'
|
|
32
32
|
> & {
|
|
33
33
|
type: ClockEditableSegmentType;
|
|
34
|
-
|
|
34
|
+
/** Receives the option and whether it is the column's selected value. */
|
|
35
|
+
children?: Snippet<[TimePickerWheelOption, boolean]>;
|
|
35
36
|
class?: string;
|
|
36
37
|
'aria-label'?: string;
|
|
37
38
|
};
|
|
@@ -202,6 +203,13 @@
|
|
|
202
203
|
const fallbackIndex = findClosestEnabledIndex(nextIndex, direction);
|
|
203
204
|
if (fallbackIndex >= 0 && fallbackIndex !== nextIndex) {
|
|
204
205
|
lastCenteredIndex = fallbackIndex;
|
|
206
|
+
// The wheel re-centres on the fallback, so the value has to follow it.
|
|
207
|
+
// Leaving it behind desynced the column from the committed time: the
|
|
208
|
+
// item under the axis read `16` while the value stayed on `15`.
|
|
209
|
+
const fallbackOption = options[fallbackIndex];
|
|
210
|
+
if (fallbackOption && selectedValue !== fallbackOption.value) {
|
|
211
|
+
clock.selectWheelValue(type, fallbackOption.value);
|
|
212
|
+
}
|
|
205
213
|
return fallbackIndex;
|
|
206
214
|
}
|
|
207
215
|
return null;
|
|
@@ -512,7 +520,7 @@
|
|
|
512
520
|
>
|
|
513
521
|
{#each options as option, index (option.value)}
|
|
514
522
|
{#if children}
|
|
515
|
-
{@render children(option)}
|
|
523
|
+
{@render children(option, selectedValue === option.value)}
|
|
516
524
|
{:else}
|
|
517
525
|
<TimePickerWheelItem
|
|
518
526
|
{type}
|
|
@@ -8,7 +8,8 @@ type TimePickerWheelOption = {
|
|
|
8
8
|
};
|
|
9
9
|
type TimePickerWheelColumnProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'role' | 'tabindex' | 'aria-label' | 'onkeydown' | 'onfocusin' | 'onfocusout' | 'onmousedown' | 'onclick'> & {
|
|
10
10
|
type: ClockEditableSegmentType;
|
|
11
|
-
|
|
11
|
+
/** Receives the option and whether it is the column's selected value. */
|
|
12
|
+
children?: Snippet<[TimePickerWheelOption, boolean]>;
|
|
12
13
|
class?: string;
|
|
13
14
|
'aria-label'?: string;
|
|
14
15
|
};
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
id,
|
|
10
10
|
open: openProp = $bindable(),
|
|
11
11
|
defaultOpen = false,
|
|
12
|
+
controlledOpen = false,
|
|
12
13
|
onOpenChange,
|
|
13
14
|
disabled = false,
|
|
14
15
|
children,
|
|
@@ -18,18 +19,22 @@
|
|
|
18
19
|
...restProps
|
|
19
20
|
}: CollapsibleRootProps = $props();
|
|
20
21
|
|
|
21
|
-
const isControlled = untrack(() => openProp !== undefined);
|
|
22
22
|
const instanceId = untrack(() => id) ?? generatedId;
|
|
23
23
|
|
|
24
24
|
let rootRef: HTMLDivElement | null = $state(null);
|
|
25
25
|
let internalOpen = $state(untrack(() => defaultOpen));
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// `open` wins whenever it is supplied — that covers both `bind:open` and a plain
|
|
28
|
+
// `open={...}` — and the internal state only carries the fully uncontrolled case.
|
|
29
|
+
// Controlled-ness is NOT inferred from `open` being defined: `bind:open={value}` and
|
|
30
|
+
// `open={value}` are indistinguishable at runtime, so inferring it silently broke
|
|
31
|
+
// every `bind:open` seeded with `false`. It is opt-in via `controlledOpen` instead.
|
|
32
|
+
const isOpen = $derived(controlledOpen ? Boolean(openProp) : (openProp ?? internalOpen));
|
|
28
33
|
|
|
29
34
|
function setOpen(next: boolean) {
|
|
30
35
|
if (disabled || next === isOpen) return;
|
|
31
|
-
if (!
|
|
32
|
-
//
|
|
36
|
+
if (!controlledOpen) {
|
|
37
|
+
// Apply the change and keep `bind:open` in sync.
|
|
33
38
|
internalOpen = next;
|
|
34
39
|
openProp = next;
|
|
35
40
|
}
|
|
@@ -3,8 +3,17 @@ import type { HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
|
3
3
|
import type { CollapsibleContext } from './root/context.js';
|
|
4
4
|
export type { CollapsibleContext } from './root/context.js';
|
|
5
5
|
export type CollapsibleRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
6
|
+
/** Open state. Two-way by default — use `bind:open`. */
|
|
6
7
|
open?: boolean;
|
|
8
|
+
/** Initial open state, for when `open` is not supplied. */
|
|
7
9
|
defaultOpen?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Opt into fully controlled state: the component stops writing back to `open` and
|
|
12
|
+
* only reports through `onOpenChange`, so the parent can reject a change by not
|
|
13
|
+
* flowing the new value back down. Off by default, because `bind:open` — the common
|
|
14
|
+
* case — needs the write-back to work at all.
|
|
15
|
+
*/
|
|
16
|
+
controlledOpen?: boolean;
|
|
8
17
|
onOpenChange?: (open: boolean) => void;
|
|
9
18
|
disabled?: boolean;
|
|
10
19
|
children?: Snippet;
|
|
@@ -115,6 +115,14 @@
|
|
|
115
115
|
}
|
|
116
116
|
</script>
|
|
117
117
|
|
|
118
|
+
<!--
|
|
119
|
+
`autocomplete="new-password"` where "off" is what you would expect: Chrome ignores "off"
|
|
120
|
+
on a field it has classified as part of an address form, so a combobox called "País" got
|
|
121
|
+
the browser's saved-addresses dropdown *over* its own option list. "new-password" is the
|
|
122
|
+
one value Chromium honours as "never autofill this", and on a text input it shows no
|
|
123
|
+
password UI of its own. The `data-*` attributes are the equivalent opt-out for the common
|
|
124
|
+
password managers. Consumers can still override it through `restProps`.
|
|
125
|
+
-->
|
|
118
126
|
<Input
|
|
119
127
|
bind:element={inputRef}
|
|
120
128
|
type="text"
|
|
@@ -131,7 +139,10 @@
|
|
|
131
139
|
aria-label={ariaLabel}
|
|
132
140
|
aria-labelledby={ariaLabelledby}
|
|
133
141
|
aria-describedby={ariaDescribedby}
|
|
134
|
-
autocomplete="
|
|
142
|
+
autocomplete="new-password"
|
|
143
|
+
data-1p-ignore
|
|
144
|
+
data-lpignore="true"
|
|
145
|
+
data-form-type="other"
|
|
135
146
|
value={ctx.displayValue}
|
|
136
147
|
disabled={ctx.isDisabled}
|
|
137
148
|
readonly={ctx.isReadOnly}
|