@cscfi/csc-ui 4.0.0-alpha.9 → 4.0.0-rc.2
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 +36 -2
- package/dist/csc-ui.js +22771 -14908
- package/dist/custom-elements.json +8943 -5632
- package/dist/docs/c-accordion/usage.md +60 -0
- package/dist/docs/c-accordion-item/usage.md +1 -0
- package/dist/docs/c-alert/usage.md +5 -5
- package/dist/docs/c-autocomplete/usage.md +156 -0
- package/dist/docs/c-badge/usage.md +50 -0
- package/dist/docs/c-breadcrumb/usage.md +104 -0
- package/dist/docs/c-breadcrumb-item/usage.md +1 -0
- package/dist/docs/c-button/usage.md +13 -0
- package/dist/docs/c-button-group/usage.md +16 -2
- package/dist/docs/c-card/usage.md +55 -0
- package/dist/docs/c-card-actions/usage.md +1 -0
- package/dist/docs/c-card-content/usage.md +1 -0
- package/dist/docs/c-card-title/usage.md +3 -0
- package/dist/docs/c-checkbox/usage.md +37 -5
- package/dist/docs/c-color-picker/usage.md +160 -0
- package/dist/docs/c-csc-logo/usage.md +25 -0
- package/dist/docs/c-data-table/usage.md +180 -0
- package/dist/docs/c-date-picker/usage.md +224 -0
- package/dist/docs/c-divider/usage.md +36 -0
- package/dist/docs/c-file-upload/usage.md +189 -0
- package/dist/docs/c-icon/usage.md +51 -0
- package/dist/docs/c-icon-button/usage.md +80 -0
- package/dist/docs/c-link/usage.md +45 -1
- package/dist/docs/c-list/usage.md +50 -0
- package/dist/docs/c-list-item/usage.md +1 -0
- package/dist/docs/c-list-item-title/usage.md +1 -0
- package/dist/docs/c-loader/usage.md +52 -1
- package/dist/docs/c-login-button/usage.md +1 -0
- package/dist/docs/c-login-buttons/usage.md +48 -0
- package/dist/docs/c-login-card/usage.md +45 -0
- package/dist/docs/c-login-card-actions/usage.md +1 -0
- package/dist/docs/c-login-card-content/usage.md +1 -0
- package/dist/docs/c-login-card-title/usage.md +3 -0
- package/dist/docs/c-main/usage.md +21 -1
- package/dist/docs/c-menu/usage.md +15 -0
- package/dist/docs/c-menu-item/usage.md +11 -0
- package/dist/docs/c-message/usage.md +56 -0
- package/dist/docs/c-modal/usage.md +18 -12
- package/dist/docs/c-navigation-button/usage.md +32 -0
- package/dist/docs/c-number-field/usage.md +114 -0
- package/dist/docs/c-option/usage.md +1 -0
- package/dist/docs/c-option-value/usage.md +1 -0
- package/dist/docs/c-otp-input/usage.md +95 -0
- package/dist/docs/c-page/usage.md +44 -0
- package/dist/docs/c-pagination/usage.md +69 -0
- package/dist/docs/c-popover/usage.md +1 -1
- package/dist/docs/c-progress-bar/usage.md +1 -1
- package/dist/docs/c-progress-circle/usage.md +1 -1
- package/dist/docs/c-radio/usage.md +9 -6
- package/dist/docs/c-radio-group/usage.md +5 -6
- package/dist/docs/c-select/usage.md +131 -0
- package/dist/docs/c-side-navigation/usage.md +70 -0
- package/dist/docs/c-side-navigation-item/usage.md +1 -0
- package/dist/docs/c-side-navigation-title/usage.md +1 -0
- package/dist/docs/c-slider/usage.md +78 -0
- package/dist/docs/c-spinner/usage.md +1 -1
- package/dist/docs/c-status/usage.md +46 -0
- package/dist/docs/c-step/usage.md +1 -0
- package/dist/docs/c-steps/usage.md +35 -0
- package/dist/docs/c-sub-navigation-item/usage.md +1 -0
- package/dist/docs/c-switch/usage.md +10 -3
- package/dist/docs/c-tab/usage.md +1 -0
- package/dist/docs/c-tab-buttons/usage.md +15 -0
- package/dist/docs/c-tab-item/usage.md +1 -0
- package/dist/docs/c-tab-items/usage.md +1 -0
- package/dist/docs/c-table/usage.md +1 -1
- package/dist/docs/c-tabs/usage.md +77 -0
- package/dist/docs/c-tag/usage.md +1 -0
- package/dist/docs/c-tags/usage.md +85 -0
- package/dist/docs/c-text-field/usage.md +109 -0
- package/dist/docs/c-time-picker/usage.md +170 -0
- package/dist/docs/c-toasts/usage.md +27 -3
- package/dist/docs/c-toolbar/usage.md +17 -0
- package/dist/docs/c-tree-select/usage.md +156 -0
- package/dist/floating-ui.dom-DvzxEaDJ.js +1292 -0
- package/dist/styles/css/tailwind-theme.css +2 -1
- package/dist/styles/css/tokens.css +609 -178
- package/dist/vscode.css-custom-data.json +556 -99
- package/dist/vscode.html-custom-data.json +1050 -480
- package/dist/web-types.json +3303 -1707
- package/dist-types/components/c-accordion/CAccordion.vue.d.ts +21 -25
- package/dist-types/components/c-accordion-item/CAccordionItem.vue.d.ts +13 -12
- package/dist-types/components/c-alert/CAlert.vue.d.ts +12 -17
- package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +124 -31
- package/dist-types/components/c-breadcrumb/CBreadcrumb.vue.d.ts +35 -0
- package/dist-types/components/c-breadcrumb/fit.d.ts +29 -0
- package/dist-types/components/c-breadcrumb-item/CBreadcrumbItem.vue.d.ts +31 -0
- package/dist-types/components/c-button/CButton.vue.d.ts +52 -63
- package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +16 -14
- package/dist-types/components/c-card/CCard.vue.d.ts +2 -3
- package/dist-types/components/c-card-actions/CCardActions.vue.d.ts +5 -7
- package/dist-types/components/c-card-title/CCardTitle.vue.d.ts +11 -1
- package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +33 -52
- package/dist-types/components/c-color-picker/CColorPicker.vue.d.ts +189 -0
- package/dist-types/components/c-color-picker/colors.d.ts +66 -0
- package/dist-types/components/c-csc-logo/CCscLogo.vue.d.ts +1 -3
- package/dist-types/components/c-data-table/CDataTable.vue.d.ts +75 -51
- package/dist-types/components/c-date-picker/CDatePicker.vue.d.ts +277 -0
- package/dist-types/components/c-date-picker/dates.d.ts +119 -0
- package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +51 -8
- package/dist-types/components/c-file-upload/CFileUpload.vue.d.ts +204 -0
- package/dist-types/components/c-file-upload/files.d.ts +99 -0
- package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +23 -36
- package/dist-types/components/c-input/CInput.vue.d.ts +21 -43
- package/dist-types/components/c-link/CLink.vue.d.ts +6 -14
- package/dist-types/components/c-list/CList.vue.d.ts +4 -6
- package/dist-types/components/c-list-item/CListItem.vue.d.ts +14 -19
- package/dist-types/components/c-list-item-title/CListItemTitle.vue.d.ts +3 -2
- package/dist-types/components/c-loader/CLoader.vue.d.ts +13 -29
- package/dist-types/components/c-login-button/CLoginButton.vue.d.ts +9 -9
- package/dist-types/components/c-login-card/CLoginCard.vue.d.ts +11 -16
- package/dist-types/components/c-login-card-actions/CLoginCardActions.vue.d.ts +5 -7
- package/dist-types/components/c-login-card-title/CLoginCardTitle.vue.d.ts +11 -1
- package/dist-types/components/c-main/CMain.vue.d.ts +12 -5
- package/dist-types/components/c-menu/CMenu.vue.d.ts +17 -16
- package/dist-types/components/c-menu-item/CMenuItem.vue.d.ts +27 -35
- package/dist-types/components/c-message/CMessage.vue.d.ts +5 -15
- package/dist-types/components/c-modal/CModal.vue.d.ts +3 -3
- package/dist-types/components/c-navigation-button/CNavigationButton.vue.d.ts +20 -1
- package/dist-types/components/c-number-field/CNumberField.vue.d.ts +169 -0
- package/dist-types/components/c-number-field/numbers.d.ts +58 -0
- package/dist-types/components/c-option/COption.vue.d.ts +1 -1
- package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +16 -30
- package/dist-types/components/c-page/CPage.vue.d.ts +2 -3
- package/dist-types/components/c-pagination/CPagination.vue.d.ts +56 -26
- package/dist-types/components/c-popover/CPopover.vue.d.ts +11 -7
- package/dist-types/components/c-progress-bar/CProgressBar.vue.d.ts +10 -14
- package/dist-types/components/c-progress-circle/CProgressCircle.vue.d.ts +7 -7
- package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +11 -8
- package/dist-types/components/c-select/CSelect.vue.d.ts +119 -35
- package/dist-types/components/c-side-navigation/CSideNavigation.vue.d.ts +10 -18
- package/dist-types/components/c-side-navigation-item/CSideNavigationItem.vue.d.ts +22 -14
- package/dist-types/components/c-slider/CSlider.vue.d.ts +29 -73
- package/dist-types/components/c-spinner/CSpinner.vue.d.ts +4 -8
- package/dist-types/components/c-status/CStatus.vue.d.ts +8 -9
- package/dist-types/components/c-step/CStep.vue.d.ts +6 -4
- package/dist-types/components/c-steps/CSteps.vue.d.ts +3 -7
- package/dist-types/components/c-sub-navigation-item/CSubNavigationItem.vue.d.ts +23 -17
- package/dist-types/components/c-switch/CSwitch.vue.d.ts +17 -30
- package/dist-types/components/c-tab/CTab.vue.d.ts +11 -28
- package/dist-types/components/c-tab-buttons/CTabButtons.vue.d.ts +11 -13
- package/dist-types/components/c-tab-item/CTabItem.vue.d.ts +4 -5
- package/dist-types/components/c-tab-items/CTabItems.vue.d.ts +5 -4
- package/dist-types/components/c-table/CTable.vue.d.ts +7 -7
- package/dist-types/components/c-tabs/CTabs.vue.d.ts +13 -20
- package/dist-types/components/c-tag/CTag.vue.d.ts +22 -21
- package/dist-types/components/c-tags/CTags.vue.d.ts +9 -10
- package/dist-types/components/c-text-field/CTextField.vue.d.ts +74 -77
- package/dist-types/components/c-time-picker/CTimePicker.vue.d.ts +205 -0
- package/dist-types/components/c-time-picker/times.d.ts +82 -0
- package/dist-types/components/c-toast/CToast.vue.d.ts +3 -4
- package/dist-types/components/c-toast/swipe.d.ts +40 -0
- package/dist-types/components/c-toasts/CToasts.vue.d.ts +14 -16
- package/dist-types/components/c-toolbar/CToolbar.vue.d.ts +10 -1
- package/dist-types/components/c-tooltip/CTooltip.vue.d.ts +12 -8
- package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +257 -0
- package/dist-types/index.d.ts +41 -32
- package/dist-types/registry.d.ts +9 -0
- package/dist-types/shared/FieldMessage.vue.d.ts +8 -5
- package/dist-types/shared/PanelHeadingRow.vue.d.ts +13 -0
- package/dist-types/shared/SelectionIndicator.vue.d.ts +21 -0
- package/dist-types/shared/TypedField.vue.d.ts +48 -0
- package/dist-types/shared/appDefaults.d.ts +75 -0
- package/dist-types/shared/defineElement.d.ts +1 -0
- package/dist-types/shared/inputMask.d.ts +106 -0
- package/dist-types/shared/lightDismiss.d.ts +35 -0
- package/dist-types/shared/modalStack.d.ts +4 -3
- package/dist-types/shared/navigationDrawer.d.ts +4 -0
- package/dist-types/shared/optionLabel.d.ts +18 -0
- package/dist-types/shared/pageLock.d.ts +26 -0
- package/dist-types/shared/peekCap.d.ts +35 -0
- package/dist-types/shared/popoverChain.d.ts +13 -10
- package/dist-types/shared/positionArea.d.ts +9 -4
- package/dist-types/shared/reducedMotion.d.ts +10 -0
- package/dist-types/shared/selectAll.d.ts +29 -0
- package/dist-types/shared/splitMatches.d.ts +18 -0
- package/dist-types/shared/useAnchoredPanel.d.ts +107 -0
- package/dist-types/shared/useControlAttrs.d.ts +8 -0
- package/dist-types/shared/useDesignatedTrigger.d.ts +5 -4
- package/dist-types/shared/useFallbackPosition.d.ts +71 -0
- package/dist-types/shared/useHostEmit.d.ts +38 -0
- package/dist-types/shared/useIdReferences.d.ts +39 -0
- package/dist-types/shared/useKeyboardModality.d.ts +7 -0
- package/dist-types/shared/useNarrowViewport.d.ts +19 -0
- package/dist-types/shared/useScrollStrip.d.ts +39 -0
- package/dist-types/shared/useStatusAnnouncer.d.ts +33 -0
- package/dist-types/shared/useTypedField.d.ts +108 -0
- package/dist-types/shared/valueEvents.d.ts +41 -0
- package/dist-types/shared/visualViewport.d.ts +51 -0
- package/dist-types/tag-name-map.d.ts +1572 -672
- package/dist-types/theme/applyTheme.d.ts +6 -6
- package/dist-types/theme/chart-data.d.ts +51 -0
- package/dist-types/theme/ramp.d.ts +38 -0
- package/dist-types/theme/themeMode.d.ts +51 -0
- package/dist-types/types.d.ts +7 -11
- package/package.json +32 -21
- package/dist/css-anchor-positioning-fn-RTxo68pt.js +0 -6447
- package/dist/docs/c-toast/usage.md +0 -1
- package/dist-types/shared/anchorPolyfill.d.ts +0 -24
- package/dist-types/shared/emitModelValue.d.ts +0 -37
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ARIA attributes that hold element ids, and the property that holds the
|
|
3
|
+
* elements themselves (ARIA element reflection).
|
|
4
|
+
*/
|
|
5
|
+
export declare const ID_REFERENCES: {
|
|
6
|
+
readonly 'aria-activedescendant': "ariaActiveDescendantElement";
|
|
7
|
+
readonly 'aria-controls': "ariaControlsElements";
|
|
8
|
+
readonly 'aria-describedby': "ariaDescribedByElements";
|
|
9
|
+
readonly 'aria-details': "ariaDetailsElements";
|
|
10
|
+
readonly 'aria-errormessage': "ariaErrorMessageElements";
|
|
11
|
+
readonly 'aria-flowto': "ariaFlowToElements";
|
|
12
|
+
readonly 'aria-labelledby': "ariaLabelledByElements";
|
|
13
|
+
readonly 'aria-owns': "ariaOwnsElements";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Hand the host's ARIA id references (`aria-labelledby`, `aria-describedby`,
|
|
17
|
+
* `aria-controls`, …) to the element that carries the component's role.
|
|
18
|
+
*
|
|
19
|
+
* An id resolves only in its own tree, so the host's ids, written in the page,
|
|
20
|
+
* name nothing inside the shadow root (defineElement keeps them on the host).
|
|
21
|
+
* An element in a shadow root may still reference elements of the trees
|
|
22
|
+
* around it through ARIA element reflection, so the ids are resolved here, in
|
|
23
|
+
* the host's tree, and the target gets the elements. The component's own ids
|
|
24
|
+
* on the target (a group's label, a combobox's listbox) resolve in the
|
|
25
|
+
* target's tree and come first.
|
|
26
|
+
*
|
|
27
|
+
* Setting a reflected property blanks the content attribute to `''`, and an
|
|
28
|
+
* attribute write — Vue patching the component's own ids — clears the
|
|
29
|
+
* elements again, so the references are re-applied after every render, with
|
|
30
|
+
* the component's raw ids remembered per target. They are also re-applied
|
|
31
|
+
* one frame after mount, for a referenced element parsed after the host, on
|
|
32
|
+
* a host attribute change (defineElement re-renders), and on focus, for one
|
|
33
|
+
* rendered later. When the host's attribute goes, the target gets its own
|
|
34
|
+
* ids back.
|
|
35
|
+
*
|
|
36
|
+
* @param target The element that carries the component's role, or a selector
|
|
37
|
+
* for it in the shadow root.
|
|
38
|
+
*/
|
|
39
|
+
export declare const useIdReferences: (target: (() => Element | null | undefined) | string) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track the host's keyboard modality for the lifetime of the current effect
|
|
3
|
+
* scope. Returns `focusOptions`, which adds `focusVisible: true` to a script
|
|
4
|
+
* focus under keyboard modality and otherwise leaves the browser to decide —
|
|
5
|
+
* never `focusVisible: false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useKeyboardModality: (host: HTMLElement | null | undefined) => ((options?: FocusOptions) => FocusOptions);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrow viewport (CONTEXT.md "Narrow viewport", ADR-0050): the one shared
|
|
3
|
+
* predicate under which a value-selection field opens a **fullscreen panel**
|
|
4
|
+
* instead of an anchored one. Measured on the window, never on a component's
|
|
5
|
+
* own box — the panel fills the viewport, so only the viewport is relevant.
|
|
6
|
+
* The 760px threshold is c-dropdown's Stencil-era media query, kept so
|
|
7
|
+
* existing `c-select` consumers see no behaviour change.
|
|
8
|
+
*/
|
|
9
|
+
import { type Ref } from 'vue';
|
|
10
|
+
/** The media query every fullscreen-panel switch evaluates. */
|
|
11
|
+
export declare const NARROW_VIEWPORT_QUERY = "(max-width: 760px)";
|
|
12
|
+
/** One-off read; `false` where there is no window (SSR). */
|
|
13
|
+
export declare const isNarrowViewport: () => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A live `Ref` that follows the media query. Registers its listener for the
|
|
16
|
+
* lifetime of the current effect scope (a component's setup, or an
|
|
17
|
+
* `effectScope()` in a spec); with no scope the listener stays for the page.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useNarrowViewport: () => Readonly<Ref<boolean>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll strip: a single-row list that scrolls sideways when it is wider
|
|
3
|
+
* than its box — the tab strip of `c-tab-buttons` (CONTEXT.md "Tab
|
|
4
|
+
* buttons"). Built on a native horizontal scroll container with its
|
|
5
|
+
* scrollbar hidden, so touch panning, momentum and keyboard focus
|
|
6
|
+
* scrolling come from the browser; this composable adds what a bare
|
|
7
|
+
* scroller lacks: overflow state for edge arrows, an arrow step, mouse
|
|
8
|
+
* drag, a vertical-wheel translation and a `reveal` that brings one child
|
|
9
|
+
* into view without scrolling the page.
|
|
10
|
+
*/
|
|
11
|
+
import type { Ref } from 'vue';
|
|
12
|
+
export interface ScrollStrip {
|
|
13
|
+
/** Scroll back by half the visible width. */
|
|
14
|
+
back(): void;
|
|
15
|
+
/** True while the strip can scroll back (its start is out of view). */
|
|
16
|
+
canBack: Ref<boolean>;
|
|
17
|
+
/** True while the strip can scroll forward (its end is out of view). */
|
|
18
|
+
canForward: Ref<boolean>;
|
|
19
|
+
/** Scroll forward by half the visible width. */
|
|
20
|
+
forward(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Mouse drag scrolling: bind to the scroller's `pointerdown`. Touch and
|
|
23
|
+
* pen pan natively and are ignored here. A drag that moved swallows the
|
|
24
|
+
* `click` it would otherwise end in.
|
|
25
|
+
*/
|
|
26
|
+
onPointerDown(event: PointerEvent): void;
|
|
27
|
+
/**
|
|
28
|
+
* Translate a vertical wheel into horizontal scrolling while the strip
|
|
29
|
+
* overflows: bind to the scroller's `wheel`.
|
|
30
|
+
*/
|
|
31
|
+
onWheel(event: WheelEvent): void;
|
|
32
|
+
/** True while the content is wider than the scroller. */
|
|
33
|
+
overflowing: Ref<boolean>;
|
|
34
|
+
/** Scroll the strip just enough to bring `el` fully into view. */
|
|
35
|
+
reveal(el: Element | null | undefined): void;
|
|
36
|
+
/** Re-read the overflow state (after content changed size). */
|
|
37
|
+
update(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare const useScrollStrip: (scroller: Ref<HTMLElement | null>) => ScrollStrip;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounced polite live region for a component's status text — the
|
|
3
|
+
* announcer behind the visually hidden `aria-live="polite" aria-atomic="true"`
|
|
4
|
+
* region a value-selection field renders (`c-autocomplete`, `c-tree-select`).
|
|
5
|
+
*
|
|
6
|
+
* The 1400 ms debounce is the cadence every list panel in the library uses
|
|
7
|
+
* (`c-dropdown` / `c-select` keep their own copies for now — `set()` is the
|
|
8
|
+
* seam for a later refit): a screen reader must not hear every keystroke's
|
|
9
|
+
* intermediate count, only where the user came to rest. `announce()` takes a
|
|
10
|
+
* *compose* thunk rather than a string on purpose — it runs when the timer
|
|
11
|
+
* fires, so it reads the state current *then* (a fetch landing during the
|
|
12
|
+
* debounce is announced correctly).
|
|
13
|
+
*
|
|
14
|
+
* The region itself stays a template snippet in the consumer: it has no
|
|
15
|
+
* `part` and no slot, so a shared SFC would add an analyzer-scanned import
|
|
16
|
+
* and a child instance for no contract gain.
|
|
17
|
+
*/
|
|
18
|
+
import { type Ref } from 'vue';
|
|
19
|
+
export interface StatusAnnouncer {
|
|
20
|
+
/** Schedule an announcement. `compose` runs when the debounce fires, so it reads the state current *then*; every call restarts the timer. */
|
|
21
|
+
announce(compose: () => string): void;
|
|
22
|
+
/** Drop a pending announcement (also runs on unmount). */
|
|
23
|
+
cancel(): void;
|
|
24
|
+
/** Write immediately, dropping any pending announcement. */
|
|
25
|
+
set(text: string): void;
|
|
26
|
+
/** The live text; bind as the content of the `aria-live="polite" aria-atomic="true"` region. */
|
|
27
|
+
text: Readonly<Ref<string>>;
|
|
28
|
+
}
|
|
29
|
+
export interface UseStatusAnnouncerOptions {
|
|
30
|
+
/** Debounce before a scheduled announcement lands, in ms. Default 1400. */
|
|
31
|
+
delay?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const useStatusAnnouncer: ({ delay, }?: UseStatusAnnouncerOptions) => StatusAnnouncer;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed half of a picker whose value field holds editable text
|
|
3
|
+
* (ADR-0057, ADR-0058, ADR-0059): one input, or a start and an end input in
|
|
4
|
+
* one field box under `range`. Text is masked while typed and read by the
|
|
5
|
+
* codec only on Enter or blur; text that names no usable value is kept as
|
|
6
|
+
* typed and flags **bad input** (CONTEXT.md). Programmatic values re-sync the
|
|
7
|
+
* text and never emit; commits emit through `emitModelChange`, and a panel
|
|
8
|
+
* drag reports its moves through `moveValue` and one `settleValue` (ADR-0070).
|
|
9
|
+
*
|
|
10
|
+
* Generic over the value's codec, so `c-date-picker`, `c-time-picker` and
|
|
11
|
+
* `c-color-picker` share one commit model. The anatomy lives in `TypedField.vue`, which binds
|
|
12
|
+
* the element refs returned here.
|
|
13
|
+
*/
|
|
14
|
+
import { type Ref } from 'vue';
|
|
15
|
+
import { type MaskSlot } from './inputMask';
|
|
16
|
+
export interface TypedFieldCodec {
|
|
17
|
+
/** The committed value shown as text under `pattern`. */
|
|
18
|
+
format(value: string, pattern: string): string;
|
|
19
|
+
/** A parsed value that can still not be committed (disabled, out of range) — bad input. */
|
|
20
|
+
isUsable(value: string): boolean;
|
|
21
|
+
/** Whether a value set from outside is one this field holds (anything else is "no value"). */
|
|
22
|
+
isValue(value: unknown): value is string;
|
|
23
|
+
/** Typed text read under `pattern`; `null` when it names no value. */
|
|
24
|
+
parse(text: string, pattern: string): null | string;
|
|
25
|
+
}
|
|
26
|
+
export type TypedFieldEnd = 'end' | 'start';
|
|
27
|
+
export interface TypedFieldEnds {
|
|
28
|
+
end: null | string;
|
|
29
|
+
start: null | string;
|
|
30
|
+
}
|
|
31
|
+
/** The text committed from the field, as typed: both ends' texts under `range`. */
|
|
32
|
+
export type TypedFieldText = {
|
|
33
|
+
end: string;
|
|
34
|
+
start: string;
|
|
35
|
+
} | string;
|
|
36
|
+
export interface UseTypedFieldOptions {
|
|
37
|
+
/** The inputs' accessible name: the label, else the host's `aria-label`. */
|
|
38
|
+
accessibleName: () => string | undefined;
|
|
39
|
+
codec: TypedFieldCodec;
|
|
40
|
+
/** The custom element host: the model events dispatch from it. */
|
|
41
|
+
host: HTMLElement | null;
|
|
42
|
+
/** The field label (props.label). */
|
|
43
|
+
label: () => string;
|
|
44
|
+
/** Whether the label rests on top of the field (the resolved app default). */
|
|
45
|
+
labelOnTop: Readonly<Ref<boolean>>;
|
|
46
|
+
/** The typing mask derived from `pattern`; without one, typing is free. */
|
|
47
|
+
mask?: Readonly<Ref<MaskSlot[]>>;
|
|
48
|
+
/** The end inputs' accessible names under `range`. */
|
|
49
|
+
names: () => {
|
|
50
|
+
end: string;
|
|
51
|
+
start: string;
|
|
52
|
+
};
|
|
53
|
+
/** Alt+↓ in an input, after committing its text: open the panel. */
|
|
54
|
+
onOpenRequest: () => void;
|
|
55
|
+
/** Fired on every commit of typed text, as typed — the host's `change:text`. */
|
|
56
|
+
onTextCommit: (text: TypedFieldText) => void;
|
|
57
|
+
/** The display and parse pattern. */
|
|
58
|
+
pattern: Readonly<Ref<string>>;
|
|
59
|
+
/** The consumer's placeholder (props.placeholder). */
|
|
60
|
+
placeholder: () => string;
|
|
61
|
+
/** Whether the field holds a start and an end. */
|
|
62
|
+
range: Readonly<Ref<boolean>>;
|
|
63
|
+
/** What a committed range with its start after its end becomes: swapped, or kept as typed. */
|
|
64
|
+
reversed: 'keep' | 'swap';
|
|
65
|
+
/** The host's `value` prop. */
|
|
66
|
+
value: () => unknown;
|
|
67
|
+
}
|
|
68
|
+
export declare const useTypedField: (options: UseTypedFieldOptions) => {
|
|
69
|
+
anchor: import("vue").ShallowRef<HTMLElement | null, HTMLElement | null>;
|
|
70
|
+
badEnd: Ref<boolean, boolean>;
|
|
71
|
+
badInput: import("vue").ComputedRef<boolean>;
|
|
72
|
+
badStart: Ref<boolean, boolean>;
|
|
73
|
+
commitAll: () => void;
|
|
74
|
+
commitText: (end: TypedFieldEnd) => void;
|
|
75
|
+
commitValue: (next: TypedFieldEnds) => void;
|
|
76
|
+
endInput: import("vue").ShallowRef<HTMLInputElement | null, HTMLInputElement | null>;
|
|
77
|
+
ends: Ref<{
|
|
78
|
+
end: null | string;
|
|
79
|
+
start: null | string;
|
|
80
|
+
}, TypedFieldEnds | {
|
|
81
|
+
end: null | string;
|
|
82
|
+
start: null | string;
|
|
83
|
+
}>;
|
|
84
|
+
endText: Ref<string, string>;
|
|
85
|
+
field: import("vue").ShallowRef<HTMLElement | null, HTMLElement | null>;
|
|
86
|
+
focused: Ref<boolean, boolean>;
|
|
87
|
+
hasContent: import("vue").ComputedRef<boolean>;
|
|
88
|
+
hasText: import("vue").ComputedRef<boolean>;
|
|
89
|
+
inputLabel: (end: TypedFieldEnd) => string | undefined;
|
|
90
|
+
inputOf: (end: TypedFieldEnd) => HTMLInputElement | null;
|
|
91
|
+
lastInput: Ref<TypedFieldEnd, TypedFieldEnd>;
|
|
92
|
+
moveValue: (next: TypedFieldEnds) => void;
|
|
93
|
+
onClear: (event?: Event) => void;
|
|
94
|
+
onFocusOut: (event: FocusEvent) => void;
|
|
95
|
+
onKeyDown: (end: TypedFieldEnd, event: KeyboardEvent) => void;
|
|
96
|
+
onTextInput: (end: TypedFieldEnd, event: Event) => void;
|
|
97
|
+
placeholder: import("vue").ComputedRef<string | undefined>;
|
|
98
|
+
range: Readonly<Ref<boolean, boolean>>;
|
|
99
|
+
settleValue: () => void;
|
|
100
|
+
showSeparator: import("vue").ComputedRef<boolean>;
|
|
101
|
+
startInput: import("vue").ShallowRef<HTMLInputElement | null, HTMLInputElement | null>;
|
|
102
|
+
startText: Ref<string, string>;
|
|
103
|
+
startWidth: import("vue").ComputedRef<{
|
|
104
|
+
width: string;
|
|
105
|
+
} | undefined>;
|
|
106
|
+
};
|
|
107
|
+
/** The state `TypedField.vue` renders. */
|
|
108
|
+
export type TypedField = ReturnType<typeof useTypedField>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value events of a value control (CONTEXT.md "Value events", ADR-0075),
|
|
3
|
+
* with native `<input>` timing: `input` (no detail) and `update:value` (the
|
|
4
|
+
* value) on every value change, `change` (the value) on every **commit** —
|
|
5
|
+
* Enter or leaving the field for typed text, each pick in a list or panel,
|
|
6
|
+
* the release that ends a drag. None of them leaves the host but `input`,
|
|
7
|
+
* which bubbles as a native one does; `change` stays on the host so a field
|
|
8
|
+
* inside an accordion or a modal never reaches the container's own `change`.
|
|
9
|
+
*
|
|
10
|
+
* Each helper first mirrors the value onto the host's own `value` property:
|
|
11
|
+
* `v-model` on a custom element compiles to Vue's native `vModelText`, which
|
|
12
|
+
* reads `el.value` inside its `input` listener.
|
|
13
|
+
*
|
|
14
|
+
* IMPORTANT: writing `host.value` re-enters the component's `props.value`
|
|
15
|
+
* watch. That watch must only re-sync internal state and visuals — it must
|
|
16
|
+
* NEVER call a helper here (or otherwise emit), or it loops with v-model. Call
|
|
17
|
+
* these ONLY from user-interaction handlers, never from a value watcher.
|
|
18
|
+
*
|
|
19
|
+
* Declare the events a helper dispatches in the component's event map; the
|
|
20
|
+
* docs analyzer enforces it for every caller.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* A value the control settles on by itself, not by an interaction — a
|
|
24
|
+
* `<c-option selected>` seeding an empty field: the host's `value` only, and
|
|
25
|
+
* no event. A bound `v-model` does not learn it, so a bound value is
|
|
26
|
+
* initialised in the model instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare const seedModelValue: (host: HTMLElement | null, value: unknown) => void;
|
|
29
|
+
/**
|
|
30
|
+
* A change not yet committed (a keystroke, one move of a drag): `update:value`
|
|
31
|
+
* and `input`, no `change`. The commit follows as one `emitModelSettled`, as a
|
|
32
|
+
* native range input fires `input` per move and `change` on release.
|
|
33
|
+
*/
|
|
34
|
+
export declare const emitModelInput: (host: HTMLElement | null, value: unknown) => void;
|
|
35
|
+
/** The `change` that commits what `emitModelInput` reported. */
|
|
36
|
+
export declare const emitModelSettled: (host: HTMLElement | null, value: unknown) => void;
|
|
37
|
+
/**
|
|
38
|
+
* A change that is also its commit (a pick, a toggle): `update:value` and
|
|
39
|
+
* `input`, then `change`, in a native control's order.
|
|
40
|
+
*/
|
|
41
|
+
export declare const emitModelChange: (host: HTMLElement | null, value: unknown) => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual viewport tracking for the **fullscreen panel** (CONTEXT.md,
|
|
3
|
+
* ADR-0050). Two layers. The *surface* — the panel element itself,
|
|
4
|
+
* `position: fixed; inset: 0` — spans the layout viewport, which the
|
|
5
|
+
* on-screen keyboard overlays but never shrinks, so it covers everything
|
|
6
|
+
* visible whatever the keyboard does. The *content box* inside it (heading
|
|
7
|
+
* row, search input, list) follows `visualViewport` — the only API that sees
|
|
8
|
+
* the iOS keyboard — so it ends above the keyboard. A late or wrong box then
|
|
9
|
+
* shows more surface, never the page. Both fullscreen implementations (the
|
|
10
|
+
* anchored-panel composable and `c-dropdown`'s dialog) go through this one
|
|
11
|
+
* helper while they are open.
|
|
12
|
+
*/
|
|
13
|
+
/** Stop following the visual viewport. Idempotent. */
|
|
14
|
+
export type StopTracking = () => void;
|
|
15
|
+
/** The visible box, in CSS px relative to the layout viewport. */
|
|
16
|
+
export interface ViewportBox {
|
|
17
|
+
height: number;
|
|
18
|
+
left: number;
|
|
19
|
+
top: number;
|
|
20
|
+
width: number;
|
|
21
|
+
}
|
|
22
|
+
/** The current visual viewport box; `null` where the API is missing (then the content box fills the surface). */
|
|
23
|
+
export declare const readVisualViewport: () => null | ViewportBox;
|
|
24
|
+
/**
|
|
25
|
+
* Report the visual viewport's box now and on every resize / scroll of it
|
|
26
|
+
* (the keyboard opening and closing, the address bar collapsing, the browser
|
|
27
|
+
* panning a focused input into view). With no API the callback runs once
|
|
28
|
+
* with `null` and nothing is listened to.
|
|
29
|
+
*/
|
|
30
|
+
export declare const trackVisualViewport: (onBox: (box: null | ViewportBox) => void) => StopTracking;
|
|
31
|
+
/**
|
|
32
|
+
* Inline declarations that make a top-layer element the surface: the layout
|
|
33
|
+
* viewport's box. Overrides the UA popover / dialog defaults (`inset: 0` is
|
|
34
|
+
* theirs too, but with fit-content sizing and auto margins).
|
|
35
|
+
*/
|
|
36
|
+
export declare const FULLSCREEN_SURFACE_STYLE = "position:fixed;inset:0;margin:0;width:auto;height:auto;";
|
|
37
|
+
/**
|
|
38
|
+
* Inline declarations placing the content box inside the surface on the
|
|
39
|
+
* visual viewport's box; with no box (no API) it fills the surface.
|
|
40
|
+
*/
|
|
41
|
+
export declare const contentBoxStyle: (box: null | ViewportBox) => string;
|
|
42
|
+
/**
|
|
43
|
+
* `FULLSCREEN_SURFACE_STYLE` written straight onto an element's inline style,
|
|
44
|
+
* for a surface whose placement is imperative (`c-dropdown`'s dialog). Margins
|
|
45
|
+
* are left to its classes.
|
|
46
|
+
*/
|
|
47
|
+
export declare const applyFullscreenSurface: (el: HTMLElement) => void;
|
|
48
|
+
/** `contentBoxStyle(box)` written straight onto an element's inline style. */
|
|
49
|
+
export declare const applyContentBox: (el: HTMLElement, box: null | ViewportBox) => void;
|
|
50
|
+
/** Remove exactly what `applyContentBox` set. */
|
|
51
|
+
export declare const clearContentBox: (el: HTMLElement) => void;
|