@vantageos/mosaic 0.2.2 → 0.3.0-alpha.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 +181 -0
- package/dist/Alert.schema-BQsZGG6P.d.cts +41 -0
- package/dist/Alert.schema-BQsZGG6P.d.ts +41 -0
- package/dist/ConfirmDialog-B3CQQGmJ.d.cts +34 -0
- package/dist/ConfirmDialog-B3CQQGmJ.d.ts +34 -0
- package/dist/Skeleton.schema-BO0ca2UX.d.cts +135 -0
- package/dist/Skeleton.schema-BO0ca2UX.d.ts +135 -0
- package/dist/Tabs.schema-BzcEyeq8.d.cts +79 -0
- package/dist/Tabs.schema-BzcEyeq8.d.ts +79 -0
- package/dist/artifacts.cjs +20 -2
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +20 -2
- package/dist/artifacts.js.map +1 -1
- package/dist/confirmation.cjs +44 -2
- package/dist/confirmation.cjs.map +1 -1
- package/dist/confirmation.d.cts +34 -1
- package/dist/confirmation.d.ts +34 -1
- package/dist/confirmation.js +41 -3
- package/dist/confirmation.js.map +1 -1
- package/dist/display.cjs +145 -2
- package/dist/display.cjs.map +1 -1
- package/dist/display.d.cts +1 -0
- package/dist/display.d.ts +1 -0
- package/dist/display.js +140 -3
- package/dist/display.js.map +1 -1
- package/dist/forms.cjs +1412 -0
- package/dist/forms.cjs.map +1 -0
- package/dist/forms.d.cts +159 -0
- package/dist/forms.d.ts +159 -0
- package/dist/forms.js +1331 -0
- package/dist/forms.js.map +1 -0
- package/dist/index-CwXVgtGb.d.cts +917 -0
- package/dist/index-CwXVgtGb.d.ts +917 -0
- package/dist/index.cjs +188 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +177 -3
- package/dist/index.js.map +1 -1
- package/dist/input.cjs +19 -0
- package/dist/input.cjs.map +1 -1
- package/dist/input.d.cts +4 -34
- package/dist/input.d.ts +4 -34
- package/dist/input.js +18 -1
- package/dist/input.js.map +1 -1
- package/dist/media.cjs +20 -2
- package/dist/media.cjs.map +1 -1
- package/dist/media.js +20 -2
- package/dist/media.js.map +1 -1
- package/dist/preact/confirmation.d.ts +85 -1
- package/dist/preact/confirmation.js +263 -0
- package/dist/preact/confirmation.js.map +1 -1
- package/dist/preact/display.d.ts +240 -1
- package/dist/preact/display.js +366 -0
- package/dist/preact/display.js.map +1 -1
- package/dist/preact/forms.d.ts +875 -0
- package/dist/preact/forms.js +1323 -0
- package/dist/preact/forms.js.map +1 -0
- package/dist/preact/input.d.ts +88 -1
- package/dist/preact/input.js +194 -0
- package/dist/preact/input.js.map +1 -1
- package/dist/progress.cjs +20 -2
- package/dist/progress.cjs.map +1 -1
- package/dist/progress.js +20 -2
- package/dist/progress.js.map +1 -1
- package/dist/react/confirmation.cjs +267 -0
- package/dist/react/confirmation.cjs.map +1 -1
- package/dist/react/confirmation.d.cts +21 -1
- package/dist/react/confirmation.d.ts +21 -1
- package/dist/react/confirmation.js +263 -0
- package/dist/react/confirmation.js.map +1 -1
- package/dist/react/display.cjs +372 -0
- package/dist/react/display.cjs.map +1 -1
- package/dist/react/display.d.cts +112 -1
- package/dist/react/display.d.ts +112 -1
- package/dist/react/display.js +362 -0
- package/dist/react/display.js.map +1 -1
- package/dist/react/forms.cjs +1384 -0
- package/dist/react/forms.cjs.map +1 -0
- package/dist/react/forms.d.cts +5 -0
- package/dist/react/forms.d.ts +5 -0
- package/dist/react/forms.js +1323 -0
- package/dist/react/forms.js.map +1 -0
- package/dist/react/input.cjs +197 -0
- package/dist/react/input.cjs.map +1 -1
- package/dist/react/input.d.cts +13 -1
- package/dist/react/input.d.ts +13 -1
- package/dist/react/input.js +194 -0
- package/dist/react/input.js.map +1 -1
- package/package.json +73 -49
- package/registry.yaml +154 -1
package/dist/forms.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { M as MosaicFormMode, F as FieldErrorShape, I as InputType, a as MultiSelectOption, S as SelectOption } from './index-CwXVgtGb.js';
|
|
2
|
+
export { C as Checkbox, b as CheckboxPropsSchema, c as CheckboxPropsValidated, D as DEFAULT_TEXTAREA_ROWS, E as ErrorDisplay, d as ErrorDisplayPropsSchema, e as FieldArray, f as FieldArrayPropsSchema, g as FieldErrorShapeSchema, h as FormField, i as FormFieldPropsSchema, j as FormProvider, k as FormProviderPropsSchema, l as Input, m as InputPropsSchema, n as InputPropsValidated, o as InputTypeSchema, p as MosaicFormModeSchema, q as MultiSelect, r as MultiSelectOptionSchema, s as MultiSelectPropsSchema, R as RadioGroup, t as RadioGroupOption, u as RadioGroupOptionSchema, v as RadioGroupPropsSchema, w as RadioGroupPropsValidated, x as RadioOrientation, y as Select, z as SelectOptionSchema, A as SelectPropsSchema, B as SelectPropsValidated, G as SubmitButton, H as SubmitButtonPropsSchema, T as Textarea, J as TextareaPropsSchema, K as TextareaPropsValidated, U as UseFieldArrayOptionsSchema, L as UseMosaicFormOptions, N as UseMosaicFormOptionsSchema, O as UseMosaicFormReturn, P as buildAddAriaLabel, Q as buildListAriaLabel, V as buildRemoveAriaLabel, W as clampToMaxLength, X as computeAutoResizeHeight, Y as findFirstEnabledIndex, Z as findLastEnabledIndex, _ as findNextEnabledIndex, $ as findSelectedIndex, a0 as getGroupClasses, a1 as getGroupLabelId, a2 as getNavKeys, a3 as getOptionDescriptionId, a4 as getOptionLabelId, a5 as getOptionRowClasses, a6 as getRadioControlClasses, a7 as getRovingTabIndex, a8 as isActivationKey, a9 as nextFocusIndexAfterRemove, aa as resolveAriaChecked, ab as resolveDescribedBy, ac as resolveRows, ad as useFieldArray, ae as useMosaicForm, af as useMosaicFormContext, ag as validateCheckboxProps, ah as validateOptions, ai as validateRadioGroupProps, aj as validateSelectProps, ak as validateSubmitButtonProps, al as validateTextareaProps } from './index-CwXVgtGb.js';
|
|
3
|
+
import 'react-hook-form';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import 'react/jsx-runtime';
|
|
6
|
+
import 'react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Map Mosaic public mode → react-hook-form `mode` config value.
|
|
10
|
+
*
|
|
11
|
+
* RHF accepts the same three strings (`"onBlur" | "onChange" | "onSubmit"`)
|
|
12
|
+
* but a future Mosaic mode could be aliased here (e.g. `"realtime"` →
|
|
13
|
+
* `"onChange"`). Keeping the mapping in pure logic makes the hook itself
|
|
14
|
+
* trivial and unit-testable without a renderer.
|
|
15
|
+
*/
|
|
16
|
+
declare function toRhfMode(mode: MosaicFormMode): "onBlur" | "onChange" | "onSubmit";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Shared error messages for the FormProvider runtime layer.
|
|
20
|
+
*/
|
|
21
|
+
declare const FORM_PROVIDER_CONTEXT_MISSING = "useMosaicFormContext must be used inside <FormProvider>. Wrap your tree with <FormProvider form={...}> from @vantageos/mosaic/{react,preact}/forms.";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Pure helpers for FormField. Currently a placeholder for future
|
|
25
|
+
* cross-runtime logic (e.g. ARIA id generation, error aggregation).
|
|
26
|
+
*/
|
|
27
|
+
declare function buildFieldId(formName: string | undefined, fieldName: string): string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Pure formatter shared by React + Preact runtimes.
|
|
31
|
+
*
|
|
32
|
+
* Priority order:
|
|
33
|
+
* 1. `error.message` set by Zod/RHF → win (explicit wins).
|
|
34
|
+
* 2. `messageMap[error.type]` → consumer-controlled i18n fallback.
|
|
35
|
+
* 3. Generic fallback string ("Invalid value").
|
|
36
|
+
*/
|
|
37
|
+
declare function formatErrorMessage(error: FieldErrorShape | undefined, messageMap: Record<string, string> | undefined): string | undefined;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Pure state machine for SubmitButton, shared by React + Preact runtimes.
|
|
41
|
+
*
|
|
42
|
+
* | isValid | isSubmitting | disabled | loading |
|
|
43
|
+
* |---------|--------------|----------|---------|
|
|
44
|
+
* | false | false | true | false |
|
|
45
|
+
* | false | true | true | true |
|
|
46
|
+
* | true | false | false | false |
|
|
47
|
+
* | true | true | true | true |
|
|
48
|
+
*
|
|
49
|
+
* `loading` reflects the submit-in-flight state regardless of validity, so
|
|
50
|
+
* consumers can show a spinner even if downstream validation rejects.
|
|
51
|
+
*/
|
|
52
|
+
declare function computeSubmitButtonState(input: {
|
|
53
|
+
isValid: boolean;
|
|
54
|
+
isSubmitting: boolean;
|
|
55
|
+
}): {
|
|
56
|
+
disabled: boolean;
|
|
57
|
+
loading: boolean;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Pure helpers for Input. Runtime-agnostic — shared between React and Preact
|
|
62
|
+
* runtimes via the `src/components/forms/` co-location pattern (Standard §18.2).
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Build the deterministic input element id from form name + field name.
|
|
67
|
+
* Used to wire `<label htmlFor>`, `aria-describedby` and the error element id.
|
|
68
|
+
*
|
|
69
|
+
* Mirrors `buildFieldId` from `FormField.logic.ts` but namespaced for Input so
|
|
70
|
+
* future primitives (Textarea, Select) can compose their own id conventions.
|
|
71
|
+
*/
|
|
72
|
+
declare function buildInputId(formName: string | undefined, fieldName: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* `aria-describedby` value — the id of the error element, only emitted when an
|
|
75
|
+
* error exists. Otherwise undefined (omit the attribute entirely).
|
|
76
|
+
*/
|
|
77
|
+
declare function buildErrorDescribedBy(inputId: string, hasError: boolean): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Map our public `type` prop to the HTML `type` attribute. Currently a 1:1
|
|
80
|
+
* passthrough — the indirection exists so future types (e.g. `search`,
|
|
81
|
+
* `tel`) can be widened without touching the runtime components.
|
|
82
|
+
*/
|
|
83
|
+
declare function resolveHtmlType(type: InputType | undefined): InputType;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns the list of options that are still available for selection.
|
|
87
|
+
* Filters out options already present in `selected` so they don't appear
|
|
88
|
+
* twice in the dropdown.
|
|
89
|
+
*/
|
|
90
|
+
declare function getAvailableOptions(options: ReadonlyArray<MultiSelectOption>, selected: ReadonlyArray<string>): MultiSelectOption[];
|
|
91
|
+
/**
|
|
92
|
+
* Returns the matching `MultiSelectOption` records for the currently selected
|
|
93
|
+
* values, preserving the order of `selected`. Unknown values are silently
|
|
94
|
+
* dropped (graceful — schema may have shrunk under the field).
|
|
95
|
+
*/
|
|
96
|
+
declare function getSelectedOptions(options: ReadonlyArray<MultiSelectOption>, selected: ReadonlyArray<string>): MultiSelectOption[];
|
|
97
|
+
/**
|
|
98
|
+
* Search filter applied when `searchable=true`. Case-insensitive substring
|
|
99
|
+
* match on both `label` and `value`. Empty query returns the input as-is.
|
|
100
|
+
*/
|
|
101
|
+
declare function filterBySearch(options: ReadonlyArray<MultiSelectOption>, query: string): MultiSelectOption[];
|
|
102
|
+
/**
|
|
103
|
+
* Adds a value to the selected list, enforcing `maxItems` (when set) and
|
|
104
|
+
* de-duplicating. Returns the same array reference when the value is already
|
|
105
|
+
* present OR the cap is reached — callers can compare identity to detect
|
|
106
|
+
* the no-op.
|
|
107
|
+
*/
|
|
108
|
+
declare function addValue(current: ReadonlyArray<string>, value: string, maxItems?: number): string[];
|
|
109
|
+
/**
|
|
110
|
+
* Removes a value from the selected list. Returns a fresh array even when
|
|
111
|
+
* the value is absent so callers always see a stable shape.
|
|
112
|
+
*/
|
|
113
|
+
declare function removeValue(current: ReadonlyArray<string>, value: string): string[];
|
|
114
|
+
/**
|
|
115
|
+
* True when the cap is reached. Used to gate further selections AND to
|
|
116
|
+
* announce the locked state to the dropdown trigger via `aria-disabled`
|
|
117
|
+
* semantics (the trigger itself stays focusable to preserve removal flows).
|
|
118
|
+
*/
|
|
119
|
+
declare function isAtMaxItems(current: ReadonlyArray<string>, maxItems: number | undefined): boolean;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Select.logic.ts — pure, framework-agnostic logic for the Select primitive.
|
|
123
|
+
* Shared between React 19 and Preact 10 runtimes.
|
|
124
|
+
*
|
|
125
|
+
* WCAG-AA Combobox-with-listbox-popup pattern (APG 2024):
|
|
126
|
+
* - Trigger: role=combobox + aria-haspopup=listbox + aria-expanded + aria-controls
|
|
127
|
+
* - Popup: role=listbox + aria-activedescendant pointing at active option
|
|
128
|
+
* - Option: role=option + aria-selected=true on the selected one
|
|
129
|
+
* - Keyboard:
|
|
130
|
+
* ArrowDown → next enabled option (wrap)
|
|
131
|
+
* ArrowUp → prev enabled option (wrap)
|
|
132
|
+
* Home → first enabled option
|
|
133
|
+
* End → last enabled option
|
|
134
|
+
* Enter → commit active option, close popup
|
|
135
|
+
* Esc → close popup, restore value, focus trigger
|
|
136
|
+
* Printable type-ahead → jump to first option whose label starts with the buffer
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Filters options by case-insensitive substring on `label`. Empty query → all.
|
|
141
|
+
* Disabled flags are preserved (they're still rendered, just not selectable).
|
|
142
|
+
*/
|
|
143
|
+
declare function filterOptions(options: SelectOption[], query: string): SelectOption[];
|
|
144
|
+
/**
|
|
145
|
+
* Finds the index of the option with `value`, or -1.
|
|
146
|
+
*/
|
|
147
|
+
declare function indexOfValue(options: SelectOption[], value: string | null | undefined): number;
|
|
148
|
+
/**
|
|
149
|
+
* Type-ahead: given a buffer string, find first option whose label starts with
|
|
150
|
+
* the buffer (case-insensitive). Skips disabled options.
|
|
151
|
+
*/
|
|
152
|
+
declare function findByTypeAhead(options: SelectOption[], buffer: string): number;
|
|
153
|
+
/**
|
|
154
|
+
* Resolves the label of the currently selected option for display in the trigger.
|
|
155
|
+
* Returns null when no value selected (caller shows placeholder).
|
|
156
|
+
*/
|
|
157
|
+
declare function resolveSelectedLabel(options: SelectOption[], value: string | null | undefined): string | null;
|
|
158
|
+
|
|
159
|
+
export { FORM_PROVIDER_CONTEXT_MISSING, FieldErrorShape, InputType, MosaicFormMode, MultiSelectOption, SelectOption, addValue, buildErrorDescribedBy, buildFieldId, buildInputId, computeSubmitButtonState, filterBySearch, filterOptions, findByTypeAhead, formatErrorMessage, getAvailableOptions, getSelectedOptions, indexOfValue, isAtMaxItems, removeValue, resolveHtmlType, resolveSelectedLabel, toRhfMode };
|