@proyecto-viviana/solidaria 0.2.2 → 0.2.3
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/autocomplete/createAutocomplete.d.ts +2 -2
- package/dist/autocomplete/createAutocomplete.d.ts.map +1 -1
- package/dist/index.js +233 -234
- package/dist/index.js.map +2 -2
- package/dist/index.ssr.js +233 -234
- package/dist/index.ssr.js.map +2 -2
- package/dist/interactions/PressEvent.d.ts +13 -10
- package/dist/interactions/PressEvent.d.ts.map +1 -1
- package/dist/interactions/createPress.d.ts.map +1 -1
- package/dist/interactions/index.d.ts +1 -1
- package/dist/interactions/index.d.ts.map +1 -1
- package/dist/select/createHiddenSelect.d.ts.map +1 -1
- package/dist/toolbar/createToolbar.d.ts.map +1 -1
- package/dist/tooltip/createTooltipTrigger.d.ts.map +1 -1
- package/package.json +9 -7
- package/src/autocomplete/createAutocomplete.ts +341 -0
- package/src/autocomplete/index.ts +9 -0
- package/src/breadcrumbs/createBreadcrumbs.ts +196 -0
- package/src/breadcrumbs/index.ts +8 -0
- package/src/button/createButton.ts +142 -0
- package/src/button/createToggleButton.ts +101 -0
- package/src/button/index.ts +4 -0
- package/src/button/types.ts +78 -0
- package/src/calendar/createCalendar.ts +138 -0
- package/src/calendar/createCalendarCell.ts +187 -0
- package/src/calendar/createCalendarGrid.ts +140 -0
- package/src/calendar/createRangeCalendar.ts +136 -0
- package/src/calendar/createRangeCalendarCell.ts +186 -0
- package/src/calendar/index.ts +34 -0
- package/src/checkbox/createCheckbox.ts +135 -0
- package/src/checkbox/createCheckboxGroup.ts +137 -0
- package/src/checkbox/createCheckboxGroupItem.ts +117 -0
- package/src/checkbox/createCheckboxGroupState.ts +193 -0
- package/src/checkbox/index.ts +13 -0
- package/src/color/createColorArea.ts +314 -0
- package/src/color/createColorField.ts +137 -0
- package/src/color/createColorSlider.ts +197 -0
- package/src/color/createColorSwatch.ts +40 -0
- package/src/color/createColorWheel.ts +208 -0
- package/src/color/index.ts +24 -0
- package/src/color/types.ts +116 -0
- package/src/combobox/createComboBox.ts +647 -0
- package/src/combobox/index.ts +6 -0
- package/src/combobox/intl/en-US.json +7 -0
- package/src/combobox/intl/es-ES.json +7 -0
- package/src/combobox/intl/index.ts +23 -0
- package/src/datepicker/createDateField.ts +154 -0
- package/src/datepicker/createDatePicker.ts +206 -0
- package/src/datepicker/createDateSegment.ts +229 -0
- package/src/datepicker/createTimeField.ts +154 -0
- package/src/datepicker/index.ts +28 -0
- package/src/dialog/createDialog.ts +120 -0
- package/src/dialog/index.ts +2 -0
- package/src/dialog/types.ts +19 -0
- package/src/disclosure/createDisclosure.ts +131 -0
- package/src/disclosure/createDisclosureGroup.ts +62 -0
- package/src/disclosure/index.ts +11 -0
- package/src/dnd/createDrag.ts +209 -0
- package/src/dnd/createDraggableCollection.ts +63 -0
- package/src/dnd/createDraggableItem.ts +243 -0
- package/src/dnd/createDrop.ts +321 -0
- package/src/dnd/createDroppableCollection.ts +293 -0
- package/src/dnd/createDroppableItem.ts +213 -0
- package/src/dnd/index.ts +47 -0
- package/src/dnd/types.ts +89 -0
- package/src/dnd/utils.ts +294 -0
- package/src/focus/FocusScope.tsx +408 -0
- package/src/focus/createAutoFocus.ts +321 -0
- package/src/focus/createFocusRestore.ts +313 -0
- package/src/focus/createVirtualFocus.ts +396 -0
- package/src/focus/index.ts +35 -0
- package/src/form/createFormReset.ts +51 -0
- package/src/form/createFormValidation.ts +224 -0
- package/src/form/index.ts +11 -0
- package/src/grid/GridKeyboardDelegate.ts +429 -0
- package/src/grid/createGrid.ts +261 -0
- package/src/grid/createGridCell.ts +182 -0
- package/src/grid/createGridRow.ts +153 -0
- package/src/grid/index.ts +18 -0
- package/src/grid/types.ts +133 -0
- package/src/gridlist/createGridList.ts +185 -0
- package/src/gridlist/createGridListItem.ts +180 -0
- package/src/gridlist/createGridListSelectionCheckbox.ts +59 -0
- package/src/gridlist/index.ts +16 -0
- package/src/gridlist/types.ts +81 -0
- package/src/i18n/NumberFormatter.ts +266 -0
- package/src/i18n/createCollator.ts +79 -0
- package/src/i18n/createDateFormatter.ts +83 -0
- package/src/i18n/createFilter.ts +131 -0
- package/src/i18n/createNumberFormatter.ts +52 -0
- package/src/i18n/createStringFormatter.ts +87 -0
- package/src/i18n/index.ts +40 -0
- package/src/i18n/locale.tsx +188 -0
- package/src/i18n/utils.ts +99 -0
- package/src/index.ts +670 -0
- package/src/interactions/FocusableProvider.tsx +44 -0
- package/src/interactions/PressEvent.ts +126 -0
- package/src/interactions/createFocus.ts +163 -0
- package/src/interactions/createFocusRing.ts +89 -0
- package/src/interactions/createFocusWithin.ts +206 -0
- package/src/interactions/createFocusable.ts +168 -0
- package/src/interactions/createHover.ts +254 -0
- package/src/interactions/createInteractionModality.ts +424 -0
- package/src/interactions/createKeyboard.ts +82 -0
- package/src/interactions/createLongPress.ts +174 -0
- package/src/interactions/createMove.ts +289 -0
- package/src/interactions/createPress.ts +834 -0
- package/src/interactions/index.ts +78 -0
- package/src/label/createField.ts +145 -0
- package/src/label/createLabel.ts +117 -0
- package/src/label/createLabels.ts +50 -0
- package/src/label/index.ts +19 -0
- package/src/landmark/createLandmark.ts +377 -0
- package/src/landmark/index.ts +8 -0
- package/src/link/createLink.ts +182 -0
- package/src/link/index.ts +1 -0
- package/src/listbox/createListBox.ts +269 -0
- package/src/listbox/createOption.ts +151 -0
- package/src/listbox/index.ts +12 -0
- package/src/live-announcer/announce.ts +322 -0
- package/src/live-announcer/index.ts +9 -0
- package/src/menu/createMenu.ts +396 -0
- package/src/menu/createMenuItem.ts +149 -0
- package/src/menu/createMenuTrigger.ts +88 -0
- package/src/menu/index.ts +18 -0
- package/src/meter/createMeter.ts +75 -0
- package/src/meter/index.ts +1 -0
- package/src/numberfield/createNumberField.ts +268 -0
- package/src/numberfield/index.ts +5 -0
- package/src/overlays/ariaHideOutside.ts +219 -0
- package/src/overlays/createInteractOutside.ts +149 -0
- package/src/overlays/createModal.tsx +202 -0
- package/src/overlays/createOverlay.ts +155 -0
- package/src/overlays/createOverlayTrigger.ts +85 -0
- package/src/overlays/createPreventScroll.ts +266 -0
- package/src/overlays/index.ts +44 -0
- package/src/popover/calculatePosition.ts +766 -0
- package/src/popover/createOverlayPosition.ts +356 -0
- package/src/popover/createPopover.ts +170 -0
- package/src/popover/index.ts +24 -0
- package/src/progress/createProgressBar.ts +128 -0
- package/src/progress/index.ts +5 -0
- package/src/radio/createRadio.ts +287 -0
- package/src/radio/createRadioGroup.ts +189 -0
- package/src/radio/createRadioGroupState.ts +201 -0
- package/src/radio/index.ts +23 -0
- package/src/searchfield/createSearchField.ts +186 -0
- package/src/searchfield/index.ts +2 -0
- package/src/select/createHiddenSelect.tsx +236 -0
- package/src/select/createSelect.ts +395 -0
- package/src/select/index.ts +14 -0
- package/src/selection/createTypeSelect.ts +201 -0
- package/src/selection/index.ts +6 -0
- package/src/separator/createSeparator.ts +82 -0
- package/src/separator/index.ts +6 -0
- package/src/slider/createSlider.ts +349 -0
- package/src/slider/index.ts +2 -0
- package/src/ssr/index.tsx +370 -0
- package/src/switch/createSwitch.ts +70 -0
- package/src/switch/index.ts +1 -0
- package/src/table/createTable.ts +526 -0
- package/src/table/createTableCell.ts +147 -0
- package/src/table/createTableColumnHeader.ts +115 -0
- package/src/table/createTableHeaderRow.ts +40 -0
- package/src/table/createTableRow.ts +155 -0
- package/src/table/createTableRowGroup.ts +32 -0
- package/src/table/createTableSelectAllCheckbox.ts +73 -0
- package/src/table/createTableSelectionCheckbox.ts +59 -0
- package/src/table/index.ts +30 -0
- package/src/table/types.ts +165 -0
- package/src/tabs/createTabs.ts +472 -0
- package/src/tabs/index.ts +14 -0
- package/src/tag/createTag.ts +194 -0
- package/src/tag/createTagGroup.ts +154 -0
- package/src/tag/index.ts +12 -0
- package/src/textfield/createTextField.ts +198 -0
- package/src/textfield/index.ts +5 -0
- package/src/toast/createToast.ts +118 -0
- package/src/toast/createToastRegion.ts +100 -0
- package/src/toast/index.ts +11 -0
- package/src/toggle/createToggle.ts +223 -0
- package/src/toggle/createToggleState.ts +94 -0
- package/src/toggle/index.ts +7 -0
- package/src/toolbar/createToolbar.ts +369 -0
- package/src/toolbar/index.ts +6 -0
- package/src/tooltip/createTooltip.ts +79 -0
- package/src/tooltip/createTooltipTrigger.ts +222 -0
- package/src/tooltip/index.ts +6 -0
- package/src/tree/createTree.ts +246 -0
- package/src/tree/createTreeItem.ts +233 -0
- package/src/tree/createTreeSelectionCheckbox.ts +68 -0
- package/src/tree/index.ts +16 -0
- package/src/tree/types.ts +87 -0
- package/src/utils/createDescription.ts +137 -0
- package/src/utils/dom.ts +327 -0
- package/src/utils/env.ts +54 -0
- package/src/utils/events.ts +106 -0
- package/src/utils/filterDOMProps.ts +116 -0
- package/src/utils/focus.ts +151 -0
- package/src/utils/geometry.ts +115 -0
- package/src/utils/globalListeners.ts +142 -0
- package/src/utils/index.ts +80 -0
- package/src/utils/mergeProps.ts +52 -0
- package/src/utils/platform.ts +52 -0
- package/src/utils/reactivity.ts +36 -0
- package/src/utils/textSelection.ts +114 -0
- package/src/visually-hidden/createVisuallyHidden.ts +124 -0
- package/src/visually-hidden/index.ts +6 -0
- package/dist/index.jsx +0 -15845
- package/dist/index.jsx.map +0 -7
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// FocusScope
|
|
2
|
+
export {
|
|
3
|
+
FocusScope,
|
|
4
|
+
useFocusManager,
|
|
5
|
+
type FocusScopeProps,
|
|
6
|
+
type FocusManager,
|
|
7
|
+
type FocusManagerOptions,
|
|
8
|
+
} from './FocusScope';
|
|
9
|
+
|
|
10
|
+
// Focus Restoration
|
|
11
|
+
export {
|
|
12
|
+
createFocusRestore,
|
|
13
|
+
pushFocusStack,
|
|
14
|
+
popFocusStack,
|
|
15
|
+
getFocusStackLength,
|
|
16
|
+
clearFocusStack,
|
|
17
|
+
type FocusRestoreOptions,
|
|
18
|
+
type FocusRestoreResult,
|
|
19
|
+
} from './createFocusRestore';
|
|
20
|
+
|
|
21
|
+
// Virtual Focus
|
|
22
|
+
export {
|
|
23
|
+
createVirtualFocus,
|
|
24
|
+
type VirtualFocusOptions,
|
|
25
|
+
type VirtualFocusResult,
|
|
26
|
+
} from './createVirtualFocus';
|
|
27
|
+
|
|
28
|
+
// Auto Focus
|
|
29
|
+
export {
|
|
30
|
+
createAutoFocus,
|
|
31
|
+
clearAutoFocusQueue,
|
|
32
|
+
getAutoFocusQueueLength,
|
|
33
|
+
type AutoFocusOptions,
|
|
34
|
+
type AutoFocusResult,
|
|
35
|
+
} from './createAutoFocus';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createFormReset - Handles form reset events for form fields.
|
|
3
|
+
*
|
|
4
|
+
* Resets the field value to its default when the containing form is reset.
|
|
5
|
+
* Port of @react-aria/utils useFormReset.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { type Accessor, createEffect, onCleanup } from 'solid-js';
|
|
9
|
+
|
|
10
|
+
export interface FormResetOptions<T> {
|
|
11
|
+
/** The default value to reset to. */
|
|
12
|
+
defaultValue: T;
|
|
13
|
+
/** Function to set the current value. */
|
|
14
|
+
onReset: (value: T) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Listens for form reset events and resets the field value to its default.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* createFormReset(
|
|
23
|
+
* () => inputRef,
|
|
24
|
+
* { label: 'Default' },
|
|
25
|
+
* (value) => state.setSelectedKey(value.key)
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function createFormReset<T>(
|
|
30
|
+
ref: Accessor<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | undefined>,
|
|
31
|
+
defaultValue: T,
|
|
32
|
+
onReset: (value: T) => void
|
|
33
|
+
): void {
|
|
34
|
+
createEffect(() => {
|
|
35
|
+
const element = ref();
|
|
36
|
+
if (!element) return;
|
|
37
|
+
|
|
38
|
+
const form = element.form;
|
|
39
|
+
if (!form) return;
|
|
40
|
+
|
|
41
|
+
const handleReset = () => {
|
|
42
|
+
onReset(defaultValue);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
form.addEventListener('reset', handleReset);
|
|
46
|
+
|
|
47
|
+
onCleanup(() => {
|
|
48
|
+
form.removeEventListener('reset', handleReset);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createFormValidation hook for solidaria
|
|
3
|
+
*
|
|
4
|
+
* Connects form validation state to native HTML form validation.
|
|
5
|
+
* Handles the invalid event, form reset, and focus management.
|
|
6
|
+
*
|
|
7
|
+
* Port of react-aria's useFormValidation.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { type Accessor, createEffect, onCleanup } from 'solid-js';
|
|
11
|
+
import {
|
|
12
|
+
type FormValidationState,
|
|
13
|
+
type ValidationResult,
|
|
14
|
+
} from '@proyecto-viviana/solid-stately';
|
|
15
|
+
import { setInteractionModality } from '../interactions/createInteractionModality';
|
|
16
|
+
|
|
17
|
+
// ============================================
|
|
18
|
+
// TYPES
|
|
19
|
+
// ============================================
|
|
20
|
+
|
|
21
|
+
export type ValidatableElement =
|
|
22
|
+
| HTMLInputElement
|
|
23
|
+
| HTMLTextAreaElement
|
|
24
|
+
| HTMLSelectElement;
|
|
25
|
+
|
|
26
|
+
export type ValidationBehavior = 'aria' | 'native';
|
|
27
|
+
|
|
28
|
+
export interface FormValidationProps {
|
|
29
|
+
/** Validation behavior: 'aria' for realtime, 'native' for on submit. */
|
|
30
|
+
validationBehavior?: ValidationBehavior;
|
|
31
|
+
/** Custom focus function to call on validation error. */
|
|
32
|
+
focus?: () => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ============================================
|
|
36
|
+
// HELPERS
|
|
37
|
+
// ============================================
|
|
38
|
+
|
|
39
|
+
function getValidity(input: ValidatableElement): ValidityState {
|
|
40
|
+
// Create a snapshot of the validity state (the native object is live)
|
|
41
|
+
const validity = input.validity;
|
|
42
|
+
return {
|
|
43
|
+
badInput: validity.badInput,
|
|
44
|
+
customError: validity.customError,
|
|
45
|
+
patternMismatch: validity.patternMismatch,
|
|
46
|
+
rangeOverflow: validity.rangeOverflow,
|
|
47
|
+
rangeUnderflow: validity.rangeUnderflow,
|
|
48
|
+
stepMismatch: validity.stepMismatch,
|
|
49
|
+
tooLong: validity.tooLong,
|
|
50
|
+
tooShort: validity.tooShort,
|
|
51
|
+
typeMismatch: validity.typeMismatch,
|
|
52
|
+
valueMissing: validity.valueMissing,
|
|
53
|
+
valid: validity.valid,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getNativeValidity(input: ValidatableElement): ValidationResult {
|
|
58
|
+
return {
|
|
59
|
+
isInvalid: !input.validity.valid,
|
|
60
|
+
validationDetails: getValidity(input),
|
|
61
|
+
validationErrors: input.validationMessage ? [input.validationMessage] : [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getFirstInvalidInput(form: HTMLFormElement): ValidatableElement | null {
|
|
66
|
+
for (let i = 0; i < form.elements.length; i++) {
|
|
67
|
+
const element = form.elements[i] as ValidatableElement;
|
|
68
|
+
if (!element.validity.valid) {
|
|
69
|
+
return element;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ============================================
|
|
76
|
+
// HOOK
|
|
77
|
+
// ============================================
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Connects form validation state to a native HTML form input.
|
|
81
|
+
*
|
|
82
|
+
* This hook:
|
|
83
|
+
* - Sets custom validity on the native input based on validation state
|
|
84
|
+
* - Handles the 'invalid' event to commit validation and focus the first invalid input
|
|
85
|
+
* - Handles form reset to clear validation state
|
|
86
|
+
* - Handles input change to commit validation
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```tsx
|
|
90
|
+
* function MyTextField(props) {
|
|
91
|
+
* let inputRef: HTMLInputElement | undefined;
|
|
92
|
+
*
|
|
93
|
+
* const validationState = createFormValidationState({
|
|
94
|
+
* value: props.value,
|
|
95
|
+
* validate: props.validate,
|
|
96
|
+
* validationBehavior: 'native',
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* createFormValidation(
|
|
100
|
+
* { validationBehavior: 'native' },
|
|
101
|
+
* validationState,
|
|
102
|
+
* () => inputRef
|
|
103
|
+
* );
|
|
104
|
+
*
|
|
105
|
+
* return (
|
|
106
|
+
* <input
|
|
107
|
+
* ref={inputRef}
|
|
108
|
+
* value={props.value}
|
|
109
|
+
* aria-invalid={validationState.displayValidation().isInvalid || undefined}
|
|
110
|
+
* />
|
|
111
|
+
* );
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export function createFormValidation(
|
|
116
|
+
props: FormValidationProps,
|
|
117
|
+
state: FormValidationState,
|
|
118
|
+
ref: Accessor<ValidatableElement | undefined>
|
|
119
|
+
): void {
|
|
120
|
+
const validationBehavior = () => props.validationBehavior ?? 'aria';
|
|
121
|
+
const focus = () => props.focus;
|
|
122
|
+
|
|
123
|
+
// Track whether we should ignore form reset (for React-like programmatic resets)
|
|
124
|
+
let isIgnoredReset = false;
|
|
125
|
+
|
|
126
|
+
// Set custom validity on the native input
|
|
127
|
+
createEffect(() => {
|
|
128
|
+
const input = ref();
|
|
129
|
+
if (
|
|
130
|
+
validationBehavior() === 'native' &&
|
|
131
|
+
input &&
|
|
132
|
+
!input.disabled
|
|
133
|
+
) {
|
|
134
|
+
const realtimeValidation = state.realtimeValidation();
|
|
135
|
+
const errorMessage = realtimeValidation.isInvalid
|
|
136
|
+
? realtimeValidation.validationErrors.join(' ') || 'Invalid value.'
|
|
137
|
+
: '';
|
|
138
|
+
input.setCustomValidity(errorMessage);
|
|
139
|
+
|
|
140
|
+
// Prevent default tooltip for validation message
|
|
141
|
+
if (!input.hasAttribute('title')) {
|
|
142
|
+
input.title = '';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Update validation with native validity if not already invalid
|
|
146
|
+
if (!realtimeValidation.isInvalid) {
|
|
147
|
+
state.updateValidation(getNativeValidity(input));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Set up event listeners
|
|
153
|
+
createEffect(() => {
|
|
154
|
+
const input = ref();
|
|
155
|
+
if (!input) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const form = input.form;
|
|
160
|
+
|
|
161
|
+
// Handle invalid event
|
|
162
|
+
const onInvalid = (e: Event) => {
|
|
163
|
+
// Only commit validation if we are not already displaying one
|
|
164
|
+
if (!state.displayValidation().isInvalid) {
|
|
165
|
+
state.commitValidation();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Auto focus the first invalid input in a form
|
|
169
|
+
if (!e.defaultPrevented && form && getFirstInvalidInput(form) === input) {
|
|
170
|
+
const focusFn = focus();
|
|
171
|
+
if (focusFn) {
|
|
172
|
+
focusFn();
|
|
173
|
+
} else {
|
|
174
|
+
input.focus();
|
|
175
|
+
}
|
|
176
|
+
// Always show focus ring
|
|
177
|
+
setInteractionModality('keyboard');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Prevent default browser error UI
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Handle change event
|
|
185
|
+
const onChange = () => {
|
|
186
|
+
state.commitValidation();
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// Handle form reset
|
|
190
|
+
const onReset = () => {
|
|
191
|
+
if (!isIgnoredReset) {
|
|
192
|
+
state.resetValidation();
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// Patch form.reset to detect programmatic resets
|
|
197
|
+
let originalReset: (() => void) | undefined;
|
|
198
|
+
if (form) {
|
|
199
|
+
originalReset = form.reset.bind(form);
|
|
200
|
+
form.reset = () => {
|
|
201
|
+
// Ignore programmatic resets outside user events
|
|
202
|
+
isIgnoredReset =
|
|
203
|
+
!window.event ||
|
|
204
|
+
(window.event.type === 'message' &&
|
|
205
|
+
window.event.target instanceof MessagePort);
|
|
206
|
+
originalReset?.();
|
|
207
|
+
isIgnoredReset = false;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
input.addEventListener('invalid', onInvalid);
|
|
212
|
+
input.addEventListener('change', onChange);
|
|
213
|
+
form?.addEventListener('reset', onReset);
|
|
214
|
+
|
|
215
|
+
onCleanup(() => {
|
|
216
|
+
input.removeEventListener('invalid', onInvalid);
|
|
217
|
+
input.removeEventListener('change', onChange);
|
|
218
|
+
form?.removeEventListener('reset', onReset);
|
|
219
|
+
if (form && originalReset) {
|
|
220
|
+
form.reset = originalReset;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|