@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,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input masks (CONTEXT.md "Input mask"; ADR-0059): conform typed text to a
|
|
3
|
+
* pattern as it is typed. One engine behind `c-text-field`'s `mask` and
|
|
4
|
+
* `c-date-picker`'s `format`.
|
|
5
|
+
*
|
|
6
|
+
* A mask compiles to a list of slots. A **token** slot takes one to `max`
|
|
7
|
+
* characters its `accepts` predicate allows — a `c-text-field` token takes
|
|
8
|
+
* exactly one; a date part takes one or two digits, and closes early on a
|
|
9
|
+
* typed separator or a first digit no longer value can start. A **literal**
|
|
10
|
+
* slot is a fixed character, inserted lazily: only when a later token
|
|
11
|
+
* character arrives, so an empty field stays `''` and Backspace behaves like
|
|
12
|
+
* plain text. A typed character that is the next literal (or one of its
|
|
13
|
+
* `aliases`) is consumed as that literal.
|
|
14
|
+
*
|
|
15
|
+
* A **word** slot takes one of a few words — a time's AM/PM period — typed
|
|
16
|
+
* by its first letters: once they name one word, the slot shows the whole
|
|
17
|
+
* word and closes. Its characters all count as typed, and a deleting edit
|
|
18
|
+
* that leaves a word partial clears it, so one Backspace removes it.
|
|
19
|
+
*
|
|
20
|
+
* An **optional section** (`[…]`, trailing only) holds optional slots: its
|
|
21
|
+
* tokens take zero or one character (`min: 0`) and its literals are marked
|
|
22
|
+
* `optional`. Completeness and the mask guide count required slots only.
|
|
23
|
+
*/
|
|
24
|
+
export interface MaskResult {
|
|
25
|
+
/** The caret position in `text`. */
|
|
26
|
+
caret: number;
|
|
27
|
+
/** Whether every required token slot is filled. */
|
|
28
|
+
complete: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* What the mask still asks for after `text` — the **mask guide**: each
|
|
31
|
+
* unfilled required token drawn as `_`, literals as themselves; optional
|
|
32
|
+
* slots are never drawn. `''` once complete.
|
|
33
|
+
*/
|
|
34
|
+
rest: string;
|
|
35
|
+
/** The conformed text. */
|
|
36
|
+
text: string;
|
|
37
|
+
/** Per character of `text`: whether it fills a token slot (not a literal). */
|
|
38
|
+
tokenAt: boolean[];
|
|
39
|
+
/** Only the characters filling token slots. */
|
|
40
|
+
unmasked: string;
|
|
41
|
+
}
|
|
42
|
+
export type MaskSlot = {
|
|
43
|
+
/** Other typed characters that stand for this literal. */
|
|
44
|
+
aliases?: string;
|
|
45
|
+
kind: 'literal';
|
|
46
|
+
/** Part of an optional section: never drawn in the guide, never appended. */
|
|
47
|
+
optional?: boolean;
|
|
48
|
+
text: string;
|
|
49
|
+
} | {
|
|
50
|
+
accepts: (ch: string) => boolean;
|
|
51
|
+
/** Closes the slot early once its characters so far are `value`. */
|
|
52
|
+
closesAfter?: (value: string) => boolean;
|
|
53
|
+
kind: 'token';
|
|
54
|
+
max: number;
|
|
55
|
+
/** `0` for an optional token. */
|
|
56
|
+
min: number;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'word';
|
|
59
|
+
/** The words the slot takes, matched case-insensitively and shown as written here. */
|
|
60
|
+
words: string[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Compile a `c-text-field` mask: `#` a digit, `A` a letter, `*` a letter or
|
|
64
|
+
* a digit, `\` escapes the next character, `[…]` wraps a trailing optional
|
|
65
|
+
* section; everything else is a literal. Returns `null` for a mask that
|
|
66
|
+
* breaks the section rules: a nested, unclosed or stray bracket, or anything
|
|
67
|
+
* but another section after the first one.
|
|
68
|
+
*/
|
|
69
|
+
export declare const compileMask: (pattern: string) => MaskSlot[] | null;
|
|
70
|
+
/** Say once per pattern, page-wide, that a mask was ignored as invalid. */
|
|
71
|
+
export declare const warnInvalidMask: (tag: string, pattern: string) => void;
|
|
72
|
+
/** Whether every token of a mask takes only digits (a numeric keyboard fits). */
|
|
73
|
+
export declare const isNumericMask: (pattern: string) => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Conform `text` to `slots`, mapping `caret` (a position in `text`) onto the
|
|
76
|
+
* result. Characters that fit no slot are dropped. `deleting` marks an edit
|
|
77
|
+
* that removed text: trailing literals are then trimmed, so Backspace never
|
|
78
|
+
* sticks on a separator. Otherwise literals that end the mask are appended
|
|
79
|
+
* once the last token is filled.
|
|
80
|
+
*/
|
|
81
|
+
export declare const conformMask: (slots: MaskSlot[], text: string, caret?: number, deleting?: boolean) => MaskResult;
|
|
82
|
+
/** Rewrites text to its conformed form, mapping a caret position onto it. */
|
|
83
|
+
export type Conformer<R extends ConformResult = ConformResult> = (text: string, caret?: number, deleting?: boolean) => R;
|
|
84
|
+
/** The part of a conform result the caret machinery needs. */
|
|
85
|
+
export interface ConformResult {
|
|
86
|
+
caret: number;
|
|
87
|
+
text: string;
|
|
88
|
+
/** Per character of `text`: whether it is typed content (not an inserted literal or separator). */
|
|
89
|
+
tokenAt: boolean[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Conform an `<input>` after a native `input` event: rewrite its text and
|
|
93
|
+
* caret in place and return the result. `previous` is the text shown before
|
|
94
|
+
* the edit — a Backspace (Delete) that only removed an inserted character (a
|
|
95
|
+
* literal, a group separator) removes the typed character before (after) it
|
|
96
|
+
* instead. Returns `null`, leaving the input untouched, during IME
|
|
97
|
+
* composition, or on a paste or drop when `skipPaste` is set (the date picker
|
|
98
|
+
* reads pasted text leniently instead).
|
|
99
|
+
*/
|
|
100
|
+
export declare const applyConform: <R extends ConformResult>(input: HTMLInputElement, event: Event, conform: Conformer<R>, previous: string, { skipPaste }?: {
|
|
101
|
+
skipPaste?: boolean | undefined;
|
|
102
|
+
}) => null | R;
|
|
103
|
+
/** `applyConform` over mask slots. */
|
|
104
|
+
export declare const applyMask: (input: HTMLInputElement, event: Event, slots: MaskSlot[], previous: string, options?: {
|
|
105
|
+
skipPaste?: boolean;
|
|
106
|
+
}) => MaskResult | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Light dismiss (CONTEXT.md "Light dismiss", ADR-0050): the platform's rule
|
|
3
|
+
* for closing a transient surface from the pointer, shared by every surface
|
|
4
|
+
* that implements dismissal itself — the anchored field panels
|
|
5
|
+
* (`useAnchoredPanel`), the popover chain and `c-menu`, all of which are
|
|
6
|
+
* `popover="manual"` and so get nothing from the browser.
|
|
7
|
+
*
|
|
8
|
+
* A native `popover="auto"` does not close on `pointerdown`: the browser
|
|
9
|
+
* remembers where the press landed and dismisses on the matching `pointerup`
|
|
10
|
+
* only when *both* fell outside. A touch scroll begins with a `pointerdown`
|
|
11
|
+
* and turns into `pointercancel`, never `pointerup`, so scrolling the page
|
|
12
|
+
* under an open surface leaves it open. The hand-rolled `pointerdown`
|
|
13
|
+
* listeners this module replaces closed the panel on the first touch of every
|
|
14
|
+
* scroll — the bug that made `c-tree-select` unusable on a phone.
|
|
15
|
+
*
|
|
16
|
+
* Listeners are capture-phase on `document`, like the ones they replace, so a
|
|
17
|
+
* consumer's `stopPropagation()` cannot hide an outside press from them.
|
|
18
|
+
*/
|
|
19
|
+
/** Detach the listeners `attachPointerPair` / `attachLightDismiss` installed. Idempotent. */
|
|
20
|
+
export type Detach = () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Report each completed primary-pointer press-and-release pair with both
|
|
23
|
+
* composed paths. A press that ends in `pointercancel` — a touch that became a
|
|
24
|
+
* scroll or a pan — is dropped, and a release with no press seen since attach
|
|
25
|
+
* (the gesture that opened the surface) is ignored.
|
|
26
|
+
*/
|
|
27
|
+
export declare const attachPointerPair: (onPair: (down: EventTarget[], up: EventTarget[]) => void) => Detach;
|
|
28
|
+
export interface LightDismissOptions {
|
|
29
|
+
/** True when a composed event path passes through the surface's own inside (host subtree, panel, designated trigger). */
|
|
30
|
+
isInside(path: EventTarget[]): boolean;
|
|
31
|
+
/** The press and its release both landed outside: close the surface. */
|
|
32
|
+
onDismiss(): void;
|
|
33
|
+
}
|
|
34
|
+
/** The single-surface case: dismiss when press and release both landed outside. */
|
|
35
|
+
export declare const attachLightDismiss: (options: LightDismissOptions) => Detach;
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* below the toast band,
|
|
14
14
|
* - **backdrop visibility**: exactly one backdrop — the active modal's — is
|
|
15
15
|
* visible at a time,
|
|
16
|
-
* - **inertness
|
|
17
|
-
* `
|
|
18
|
-
* -
|
|
16
|
+
* - **inertness** and **scroll lock**, delegated to the shared page lock
|
|
17
|
+
* (`pageLock.ts`, ADR-0050): everything outside the active modal is
|
|
18
|
+
* `inert` except `c-toasts`, and the document stops scrolling while the
|
|
19
|
+
* stack is non-empty,
|
|
19
20
|
* - **Escape routing** to the active modal only, and
|
|
20
21
|
* - **focus restore** to the element focused when each modal opened.
|
|
21
22
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The label of a slotted `<c-option>` — what a value-selection field shows
|
|
3
|
+
* for the option in its row, its closed field and its tags, and what
|
|
4
|
+
* `c-autocomplete`'s filter matches (ADR-0045).
|
|
5
|
+
*
|
|
6
|
+
* Resolution chain:
|
|
7
|
+
* 1. the option's `name` (the property, else the attribute — the element may
|
|
8
|
+
* not be upgraded yet when a parent reads it during mount);
|
|
9
|
+
* 2. else the text of its first `<c-option-value>`, the label region: it
|
|
10
|
+
* lets an option carry richer content (a description, an icon) that is
|
|
11
|
+
* not part of the label;
|
|
12
|
+
* 3. else the option's whole text content.
|
|
13
|
+
*
|
|
14
|
+
* Trimmed; an empty `name` counts as absent. Callers keep their own last
|
|
15
|
+
* resort (the raw value) so a label is never blank.
|
|
16
|
+
*/
|
|
17
|
+
export declare const optionValueElement: (option: Element) => Element | null;
|
|
18
|
+
export declare const optionLabel: (option: HTMLElement) => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page lock (ADR-0014, ADR-0050): library-owned modality for surfaces that
|
|
3
|
+
* must own the page without entering the browser's modal top layer — which
|
|
4
|
+
* would inert the toasts. While any holder is registered, everything outside
|
|
5
|
+
* the *active* holder's host is `inert` (a `c-toasts` anywhere stays
|
|
6
|
+
* interactive) and document scroll is locked.
|
|
7
|
+
*
|
|
8
|
+
* Holders form a stack; the most recently locked host is the active one. The
|
|
9
|
+
* modal stack pushes each opening `c-modal` here, and a **fullscreen panel**
|
|
10
|
+
* pushes its field's host — so a select opened inside a modal on a phone
|
|
11
|
+
* inerts the modal's other content along with the page, and closing it hands
|
|
12
|
+
* the page back to the modal. Consumer-set `inert` is never touched.
|
|
13
|
+
*/
|
|
14
|
+
/** True while `host` holds the lock (active or below another holder). */
|
|
15
|
+
export declare const isPageLockedBy: (host: HTMLElement) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Register `host` as the active holder: everything outside it goes inert and
|
|
18
|
+
* the document stops scrolling. Idempotent for a host already holding.
|
|
19
|
+
*/
|
|
20
|
+
export declare const lockPage: (host: HTMLElement) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Release `host` (idempotent). The next holder down, if any, becomes active
|
|
23
|
+
* and the inert set is re-derived for it; with no holder left the page is
|
|
24
|
+
* fully interactive and scrolls again.
|
|
25
|
+
*/
|
|
26
|
+
export declare const unlockPage: (host: HTMLElement) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The peek (CONTEXT.md, ADR-0043).
|
|
3
|
+
*
|
|
4
|
+
* A transient list panel — the menu and submenu panels, `c-dropdown`'s
|
|
5
|
+
* listbox, `c-autocomplete`'s options list — hides its scrollbar. In its
|
|
6
|
+
* place an overflowing list must end at an item row's midpoint: the
|
|
7
|
+
* half-visible row is the one cue that more rows follow. This module computes
|
|
8
|
+
* that cap from the real row boxes, so mixed-height menus (items, labels,
|
|
9
|
+
* dividers) and taller slotted option rows cut correctly.
|
|
10
|
+
*/
|
|
11
|
+
export interface PeekCapOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Upper bound for the list's `max-height`, in px. `Infinity` for none.
|
|
14
|
+
* `applyPeekCap` defaults it to the list's stylesheet `max-height`.
|
|
15
|
+
*/
|
|
16
|
+
ceiling?: number;
|
|
17
|
+
/** Full rows shown before the peek. `0` (or less): no row cap. */
|
|
18
|
+
itemsPerPage?: number;
|
|
19
|
+
/** Item rows in visual order — only these can be the peek row. */
|
|
20
|
+
rows: readonly HTMLElement[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The `max-height` (px) that ends `list` at a row midpoint, or `null` when
|
|
24
|
+
* the content fits and needs no cap. Rows are located relative to the list's
|
|
25
|
+
* scroll content (rect deltas plus `scrollTop`), so the result is independent
|
|
26
|
+
* of the panel's positioning scheme and of any cap currently applied.
|
|
27
|
+
*/
|
|
28
|
+
export declare const peekCap: (list: HTMLElement, { ceiling, itemsPerPage, rows }: PeekCapOptions) => null | number;
|
|
29
|
+
/**
|
|
30
|
+
* Write the peek cap as the list's inline `max-height` (cleared when no cap
|
|
31
|
+
* is needed). Without `ceiling` the list's stylesheet `max-height` (e.g.
|
|
32
|
+
* `max-h-[80vh]`, or a consumer's `::part()` override) is the ceiling; the
|
|
33
|
+
* inline value is cleared first so that stylesheet value is what gets read.
|
|
34
|
+
*/
|
|
35
|
+
export declare const applyPeekCap: (list: HTMLElement, options: PeekCapOptions) => void;
|
|
@@ -7,16 +7,19 @@
|
|
|
7
7
|
* - **Escape** peels the innermost popover only, one per press. The listener
|
|
8
8
|
* is capture-phase and calls `preventDefault()`, so an enclosing
|
|
9
9
|
* `c-modal`'s bubble-phase controller sees the claimed key and does not
|
|
10
|
-
* close itself (ADR-0014). Known pre-existing limitation: a `c-menu
|
|
11
|
-
* inside a popover listens on its own
|
|
12
|
-
* capture listener — that Escape closes
|
|
13
|
-
* popover owned its own capture listener.
|
|
14
|
-
* - **
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
10
|
+
* close itself (ADR-0014). Known pre-existing limitation: a `c-menu`, or a
|
|
11
|
+
* `c-breadcrumb`'s fold panel, open inside a popover listens on its own
|
|
12
|
+
* host (bubble), i.e. *after* this capture listener — that Escape closes
|
|
13
|
+
* both, exactly as it did when each popover owned its own capture listener.
|
|
14
|
+
* - **Light dismiss** (CONTEXT.md, ADR-0050) closes every popover that does
|
|
15
|
+
* not *logically* contain the pointer gesture. A press and its release are
|
|
16
|
+
* paired (`lightDismiss.ts` — a press alone, the start of every touch
|
|
17
|
+
* scroll, closes nothing); from the innermost down, everything above the
|
|
18
|
+
* deepest member whose own inside (host subtree, panel, designated
|
|
19
|
+
* trigger) contains either composed path is closed. Containment is
|
|
20
|
+
* logical, not DOM ancestry — a popover whose host lives elsewhere still
|
|
21
|
+
* shields its ancestors, because ancestry is recorded in the chain itself,
|
|
22
|
+
* not re-derived from the DOM.
|
|
20
23
|
* - **Opening** a popover whose trigger sits inside an open member joins the
|
|
21
24
|
* chain below it; one whose trigger is elsewhere replaces the chain.
|
|
22
25
|
* Siblings therefore never coexist.
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import type { CPlacement } from '../types';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* A panel's placement relative to its anchor: the side, and `-start`/`-end`
|
|
3
|
+
* to align their edges on the cross axis. Private: c-menu, c-popover and
|
|
4
|
+
* c-tooltip each own a public alias of it (`CMenuPosition`, …).
|
|
5
|
+
*/
|
|
6
|
+
export type Placement = 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top';
|
|
7
|
+
/**
|
|
8
|
+
* `Placement` → CSS `position-area`, shared by the anchor-positioned overlay
|
|
4
9
|
* components (`c-menu`, `c-tooltip`, `c-popover`; ADR-0008). Native flip/shift
|
|
5
10
|
* comes from each component's `position-try-fallbacks` escape-hatch rule.
|
|
6
11
|
*/
|
|
7
|
-
export declare const POSITION_AREA: Record<
|
|
12
|
+
export declare const POSITION_AREA: Record<Placement, string>;
|
|
8
13
|
/**
|
|
9
14
|
* The logical axis of a placement's side — the axis the trigger→panel gap
|
|
10
15
|
* margin is applied on (both sides, so the gap survives the position-try
|
|
11
16
|
* flip fallbacks).
|
|
12
17
|
*/
|
|
13
|
-
export declare const placementAxis: (position:
|
|
18
|
+
export declare const placementAxis: (position: Placement) => "block" | "inline";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OS-level reduced-motion preference (CONTEXT.md "Reduced motion",
|
|
3
|
+
* ADR-0057). CSS motion honours it from the shared utility sheet; this is the
|
|
4
|
+
* read for motion a script drives — the ripple, smooth strip scrolling, the
|
|
5
|
+
* tabs indicator, the modal keyframes. Read at the moment of use, not once at
|
|
6
|
+
* mount, so a preference toggled while the page is open is picked up.
|
|
7
|
+
*
|
|
8
|
+
* Returns false where `matchMedia` is missing (SSR, a bare test runtime).
|
|
9
|
+
*/
|
|
10
|
+
export declare const prefersReducedMotion: () => boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The select-all row (CONTEXT.md, ADR-0046): the selection maths `c-select`
|
|
3
|
+
* and `c-autocomplete` share in `multiple` mode.
|
|
4
|
+
*
|
|
5
|
+
* `listed` is the enabled options currently in the list, in list order —
|
|
6
|
+
* every option in c-select, the current matches in c-autocomplete; callers
|
|
7
|
+
* filter disabled options out first. Duplicate option values collapse in the
|
|
8
|
+
* Set maths, exactly as they do when a single row is toggled.
|
|
9
|
+
*/
|
|
10
|
+
/** `c-select` ↔ `c-dropdown` `index` contract: the select-all row is highlighted. */
|
|
11
|
+
export declare const SELECT_ALL_INDEX = -1;
|
|
12
|
+
export interface SelectAllListedOption {
|
|
13
|
+
label: string;
|
|
14
|
+
value: number | string;
|
|
15
|
+
}
|
|
16
|
+
export type SelectAllState = 'all' | 'none' | 'some';
|
|
17
|
+
/** What the row's indicator shows: none, some (indeterminate) or all listed selected. */
|
|
18
|
+
export declare const selectAllState: (listed: readonly (number | string)[], selected: ReadonlySet<number | string>) => SelectAllState;
|
|
19
|
+
/**
|
|
20
|
+
* The next selection after the row is activated. Every listed option already
|
|
21
|
+
* selected → drop the listed values (the others keep their order); otherwise
|
|
22
|
+
* append the unselected listed options in list order (selection order,
|
|
23
|
+
* ADR-0044). `added` / `removed` let a caller keep per-value bookkeeping.
|
|
24
|
+
*/
|
|
25
|
+
export declare const toggleAllValues: <T>(current: readonly T[], listed: readonly SelectAllListedOption[], valueOf: (v: T) => number | string, make: (o: SelectAllListedOption) => T) => {
|
|
26
|
+
added: SelectAllListedOption[];
|
|
27
|
+
next: T[];
|
|
28
|
+
removed: (number | string)[];
|
|
29
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split a label into the runs that equal the query and the runs between them
|
|
3
|
+
* — the shape `c-autocomplete`'s match marking renders as text and
|
|
4
|
+
* `<mark part="match">` nodes (ADR-0045).
|
|
5
|
+
*
|
|
6
|
+
* The query is matched literally (regex metacharacters escaped — the 3.x
|
|
7
|
+
* implementation built an unescaped RegExp and threw on `c++` or `(`) and
|
|
8
|
+
* case-insensitively via the `i` flag on the original string, so indices never
|
|
9
|
+
* drift the way a lowercased `indexOf` can when case mapping changes a
|
|
10
|
+
* string's length. Every occurrence is marked, left to right, without
|
|
11
|
+
* overlap; adjacent occurrences yield adjacent marks. An empty query yields
|
|
12
|
+
* one plain run (or nothing for empty text).
|
|
13
|
+
*/
|
|
14
|
+
export interface MatchSegment {
|
|
15
|
+
match: boolean;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const splitMatches: (text: string, query: string) => MatchSegment[];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchored field panel (CONTEXT.md "Autocomplete", "Tree select", "Top
|
|
3
|
+
* layer", "Fullscreen panel"; ADR-0008, ADR-0009, ADR-0047, ADR-0050): the
|
|
4
|
+
* lifecycle shared by the value-selection fields that keep a readonly value
|
|
5
|
+
* field in place and open a native popover panel — `c-autocomplete`,
|
|
6
|
+
* `c-tree-select` and `c-date-picker` (whose field is editable and whose
|
|
7
|
+
* calendar keeps its own width: `matchWidth: false`, ADR-0058). One panel, two layouts: **anchored** under the field, or
|
|
8
|
+
* — on a **narrow viewport** — a **fullscreen panel** covering the viewport.
|
|
9
|
+
*
|
|
10
|
+
* What it owns:
|
|
11
|
+
* - the anchor. CSS anchor names are tree-scoped, so the consumer wraps its
|
|
12
|
+
* value field in a shadow-DOM box carrying `anchor-name`; `anchorStyle`
|
|
13
|
+
* supplies that declaration and `panelStyle` the matching
|
|
14
|
+
* `position-anchor` / `position-area` plus the panel width pinned to the
|
|
15
|
+
* anchor's rect on open;
|
|
16
|
+
* - the field-box pull-back. The anchor wrapper spans the whole inner
|
|
17
|
+
* `c-input`, INCLUDING its hint / error message area (reserved unless
|
|
18
|
+
* `hide-details` is set), the gap above it and an on-top label. The
|
|
19
|
+
* panel must sit flush against the field box itself — the same 0px every
|
|
20
|
+
* dropdown keeps (`c-select`'s listbox, `c-menu`'s default `distance`) —
|
|
21
|
+
* so on open the distance from the anchor's bottom edge to the field
|
|
22
|
+
* box's bottom edge is measured and pulled back with a negative
|
|
23
|
+
* block-start margin, and the distance from the anchor's top edge to the
|
|
24
|
+
* field box's top edge is published as `--_c-field-panel-top-offset` for
|
|
25
|
+
* the consumer's flipped-above `@position-try` rules;
|
|
26
|
+
* - the fullscreen layout: chosen at `open()` from the `fullscreen`
|
|
27
|
+
* predicate and kept for the whole open (crossing the threshold while open
|
|
28
|
+
* closes the panel). The panel drops anchor positioning and becomes the
|
|
29
|
+
* surface — `position: fixed; inset: 0`, the layout viewport, which the
|
|
30
|
+
* on-screen keyboard overlays but never shrinks — while the card inside it
|
|
31
|
+
* follows the *visual* viewport (`visualViewport` resize / scroll while
|
|
32
|
+
* open; `cardStyle`), so the heading row and search input stay above the
|
|
33
|
+
* keyboard and the page never shows beside them. The page behind it is
|
|
34
|
+
* locked (`pageLock.ts`: inert except toasts, no document scroll);
|
|
35
|
+
* - open / close through `showPopover()` / `hidePopover()` on a
|
|
36
|
+
* `popover="manual"` panel, with the native `toggle` event as the single
|
|
37
|
+
* source of truth for `isOpen` (browser-initiated closes included);
|
|
38
|
+
* - light dismiss (CONTEXT.md "Light dismiss", ADR-0050): a press and its
|
|
39
|
+
* release both outside the host close the panel; a press alone — the
|
|
40
|
+
* start of every touch scroll — never does (`lightDismiss.ts`);
|
|
41
|
+
* - focus return to the value field on `close(true)`;
|
|
42
|
+
* - the Floating UI placement on an anchored open without native anchor
|
|
43
|
+
* positioning (Firefox 140 ESR; ADR-0056).
|
|
44
|
+
*
|
|
45
|
+
* What stays in the consumer: the `@position-try --c-field-panel-above` /
|
|
46
|
+
* `--c-field-panel-above-left` flip rules and `position-try-fallbacks` —
|
|
47
|
+
* per-shadow-root escape-hatch CSS (ADR-0007; each element type has its own
|
|
48
|
+
* adopted sheet, so the block is copy-identical in every consumer) — the
|
|
49
|
+
* fullscreen `tv` variant (the panel paints the surface, the card sheds its
|
|
50
|
+
* anchored chrome, the list takes the rest, the heading row) and the open
|
|
51
|
+
* sequence (peek cap, focus, highlight seed, announcement), run from
|
|
52
|
+
* `onOpened` synchronously inside the `toggle` handler. State that must be in
|
|
53
|
+
* place before the first keystroke reaches the panel — a search input's
|
|
54
|
+
* query reset — goes in `onOpening` instead: `toggle` is a queued task, so a
|
|
55
|
+
* key typed into a panel focused on open can land before it.
|
|
56
|
+
*/
|
|
57
|
+
import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
58
|
+
/**
|
|
59
|
+
* The `anchor-name` every anchored field panel uses. Anchor names are
|
|
60
|
+
* tree-scoped, so one name serves every consumer's shadow root.
|
|
61
|
+
*/
|
|
62
|
+
export declare const FIELD_PANEL_ANCHOR = "--c-field-panel-anchor";
|
|
63
|
+
export interface AnchoredPanel {
|
|
64
|
+
/** Inline style for the anchor wrapper: `anchor-name: --c-field-panel-anchor`. */
|
|
65
|
+
anchorStyle: string;
|
|
66
|
+
/** Inline style for the card inside the panel: empty while anchored; fullscreen — the visual viewport's box inside the surface (the whole surface with no API). */
|
|
67
|
+
cardStyle: ComputedRef<string>;
|
|
68
|
+
/** Hide the panel; `returnFocus` moves focus to `returnFocusTo` once the `toggle` event confirms the close. */
|
|
69
|
+
close(returnFocus?: boolean): void;
|
|
70
|
+
/** Open state — written only by the native `toggle` event (single source of truth, browser-initiated closes included). */
|
|
71
|
+
isOpen: Readonly<Ref<boolean>>;
|
|
72
|
+
/** The layout of the current open, fixed at `open()` for its whole duration; `'anchored'` — the resting shape, no heading row — while closed. */
|
|
73
|
+
layout: ComputedRef<PanelLayout>;
|
|
74
|
+
/** Bind as the panel's `@toggle` handler. */
|
|
75
|
+
onToggle(event: Event): void;
|
|
76
|
+
/** Choose the layout, measure (anchored: the anchor width and the field box's offsets from the anchor's edges), then `showPopover()`. */
|
|
77
|
+
open(): void;
|
|
78
|
+
/** Inline style for the panel: anchored — `position-anchor`, `position-area: bottom span-right`, `inset: auto`, the pinned width, the field-box pull-back and `--_c-field-panel-top-offset`; fullscreen — the surface, the layout viewport's box. */
|
|
79
|
+
panelStyle: ComputedRef<string>;
|
|
80
|
+
}
|
|
81
|
+
/** The two layouts one field panel takes (CONTEXT.md "Fullscreen panel"). */
|
|
82
|
+
export type PanelLayout = 'anchored' | 'fullscreen';
|
|
83
|
+
export interface UseAnchoredPanelOptions {
|
|
84
|
+
/** Shadow-DOM wrapper around the value field; carries `anchor-name`, and its rect pins the panel width. */
|
|
85
|
+
anchor: Readonly<Ref<HTMLElement | null>>;
|
|
86
|
+
/** `open()` is a no-op while this returns true (the field's `disabled`). */
|
|
87
|
+
disabled?: () => boolean;
|
|
88
|
+
/** The inner `c-input` host: the offsets between its field box (`.c-input__slot`) and the anchor's edges are pulled back so the panel sits flush against the field box. */
|
|
89
|
+
field: Readonly<Ref<HTMLElement | null>>;
|
|
90
|
+
/** Open as a fullscreen panel while true — the shared narrow-viewport predicate (`useNarrowViewport`). Absent: always anchored. */
|
|
91
|
+
fullscreen?: Readonly<Ref<boolean>>;
|
|
92
|
+
/** The custom element host: light dismiss keeps gestures whose composed path includes it; it is what the page lock keeps interactive. */
|
|
93
|
+
host: HTMLElement | null;
|
|
94
|
+
/** Pin the anchored panel's width to the anchor's (default `true`). `false` lets the card size the panel — a calendar keeps its own width whatever the field's. */
|
|
95
|
+
matchWidth?: boolean;
|
|
96
|
+
/** Runs inside the native `toggle` handler once closed, before focus returns. */
|
|
97
|
+
onClosed?: () => void;
|
|
98
|
+
/** Runs inside the native `toggle` handler once open, after the fallback positioning / page lock and the dismiss listener — the consumer's open sequence goes here. */
|
|
99
|
+
onOpened?: () => void;
|
|
100
|
+
/** Runs inside `open()` right before `showPopover()`, only when the panel really opens — the reset of state a keystroke may already change before `toggle` fires (a search input's query). */
|
|
101
|
+
onOpening?: () => void;
|
|
102
|
+
/** The `popover="manual"` panel element. */
|
|
103
|
+
panel: Readonly<Ref<HTMLElement | null>>;
|
|
104
|
+
/** Receives focus when the panel closes via `close(true)`. */
|
|
105
|
+
returnFocusTo: MaybeRefOrGetter<HTMLElement | null | undefined>;
|
|
106
|
+
}
|
|
107
|
+
export declare const useAnchoredPanel: (options: UseAnchoredPanelOptions) => AnchoredPanel;
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
* cannot reference an `anchor-name` on an outer-tree element. Instead the
|
|
11
11
|
* component keeps a *proxy anchor* — an inert, fixed-position box in its own
|
|
12
12
|
* shadow root carrying the anchor name — and this composable pins it over
|
|
13
|
-
* the designated trigger's rect while the panel is open (a rAF loop
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* the designated trigger's rect while the panel is open (a rAF loop).
|
|
14
|
+
* `position-area` placement and the `position-try-fallbacks` flip/shift keep
|
|
15
|
+
* working unchanged; only the measurement is JS. Without native anchor
|
|
16
|
+
* positioning the proxy is unused: Floating UI places the panel against the
|
|
17
|
+
* designated element directly (`useFallbackPosition`, ADR-0056).
|
|
17
18
|
*/
|
|
18
19
|
import { type Ref } from 'vue';
|
|
19
20
|
export interface DesignatedTriggerHandle {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchored-panel positioning for browsers without CSS anchor positioning
|
|
3
|
+
* (Firefox 140 ESR; ADR-0056).
|
|
4
|
+
*
|
|
5
|
+
* The overlay components place their top-layer panels with native CSS anchor
|
|
6
|
+
* positioning — `anchor-name` / `position-anchor` / `position-area` plus a
|
|
7
|
+
* `position-try-fallbacks` chain. A browser without the feature drops those
|
|
8
|
+
* declarations, so this composable computes the same placement with
|
|
9
|
+
* `@floating-ui/dom` instead: the preferred placement, then the component's
|
|
10
|
+
* fallback chain in the native order (first one that fits wins, the preferred
|
|
11
|
+
* one when none fits), the gap as an offset. When even the chosen placement
|
|
12
|
+
* overflows, the panel is shifted back inside the viewport on both axes, as a
|
|
13
|
+
* native `position-area` box is kept inside its containing block — a panel
|
|
14
|
+
* larger than the viewport starts at its top/left edge. The clamp applies to
|
|
15
|
+
* the margin box natively, so the gap pads the viewport on the placement's
|
|
16
|
+
* axis. The result is a style string the
|
|
17
|
+
* component appends to its panel style — never written to `el.style` directly,
|
|
18
|
+
* which Vue's next `:style` patch would wipe.
|
|
19
|
+
*
|
|
20
|
+
* On a browser with native support every method is a no-op and `style` stays
|
|
21
|
+
* empty, so the native path is untouched — unless the panel is `scripted`,
|
|
22
|
+
* placed this way in every browser. Floating UI is imported lazily, and
|
|
23
|
+
* preloaded at setup where it will be needed so the first open does not wait
|
|
24
|
+
* on it.
|
|
25
|
+
*
|
|
26
|
+
* Each consumer's `fallbacks` mirror its `position-try-fallbacks` rule; keep
|
|
27
|
+
* the two in step.
|
|
28
|
+
*/
|
|
29
|
+
import { type Ref } from 'vue';
|
|
30
|
+
import type { Placement as PanelPlacement } from './positionArea';
|
|
31
|
+
type Side = 'bottom' | 'left' | 'right' | 'top';
|
|
32
|
+
/** True when the browser positions anchors without this fallback. */
|
|
33
|
+
export declare const supportsAnchorPositioning: () => boolean;
|
|
34
|
+
/** The `flip-block` try-tactic: mirror across the block axis. */
|
|
35
|
+
export declare const flipBlock: (placement: PanelPlacement) => PanelPlacement;
|
|
36
|
+
/** The `flip-inline` try-tactic: mirror across the inline axis. */
|
|
37
|
+
export declare const flipInline: (placement: PanelPlacement) => PanelPlacement;
|
|
38
|
+
/**
|
|
39
|
+
* `position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline`
|
|
40
|
+
* — the chain of `c-menu`, `c-tooltip` and `c-popover` — from `placement`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const flipChain: (placement: PanelPlacement) => PanelPlacement[];
|
|
43
|
+
export interface FallbackPosition {
|
|
44
|
+
/** Start positioning — call once the panel is open. */
|
|
45
|
+
start(): void;
|
|
46
|
+
/** Stop tracking — call when the panel closes. */
|
|
47
|
+
stop(): void;
|
|
48
|
+
/** Declarations to append to the panel's inline style; empty with native support. */
|
|
49
|
+
style: Readonly<Ref<string>>;
|
|
50
|
+
}
|
|
51
|
+
export interface UseFallbackPositionOptions {
|
|
52
|
+
/** Ordered fallback placements, mirroring the panel's `position-try-fallbacks`. */
|
|
53
|
+
fallbacks: (placement: PanelPlacement) => PanelPlacement[];
|
|
54
|
+
/** The `popover` panel. */
|
|
55
|
+
floating: Readonly<Ref<HTMLElement | null>>;
|
|
56
|
+
/** The trigger→panel gap in px on the resolved placement's side (negative pulls the panel in). */
|
|
57
|
+
gap: (side: Side) => number;
|
|
58
|
+
/** The preferred placement (the inline `position-area`). */
|
|
59
|
+
placement: () => PanelPlacement;
|
|
60
|
+
/** The element the panel sits against. */
|
|
61
|
+
reference: () => Element | null | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Place the panel with Floating UI in every browser, even where anchors are
|
|
64
|
+
* positioned natively: a submenu, anchored inside the menu's own top-layer
|
|
65
|
+
* panel, is left behind by Safari's native positioning once the page
|
|
66
|
+
* scrolls.
|
|
67
|
+
*/
|
|
68
|
+
scripted?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export declare const useFallbackPosition: (options: UseFallbackPositionOptions) => FallbackPosition;
|
|
71
|
+
export {};
|
|
@@ -1 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed host-event dispatch — the single dispatch path for component events.
|
|
3
|
+
*
|
|
4
|
+
* Each component declares an **event map** interface (event name → `detail`
|
|
5
|
+
* type, `void` for detail-less events) with JSDoc per member, and dispatches
|
|
6
|
+
* only through this helper:
|
|
7
|
+
*
|
|
8
|
+
* /** Events dispatched by `<c-tag>`. *\/
|
|
9
|
+
* interface CTagEvents {
|
|
10
|
+
* /** Fired when the close button is activated. *\/
|
|
11
|
+
* close: void;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* const emit = useHostEmit<CTagEvents>();
|
|
15
|
+
* emit('close');
|
|
16
|
+
*
|
|
17
|
+
* The event map is simultaneously the runtime contract (names and detail
|
|
18
|
+
* types are compile-checked here) and the source the docs analyzer reads for
|
|
19
|
+
* the manifest's events section — an event missing from the map cannot be
|
|
20
|
+
* dispatched, so the docs cannot drift.
|
|
21
|
+
*
|
|
22
|
+
* Events are dispatched as raw `CustomEvent`s, NOT via Vue's `emit()`: the
|
|
23
|
+
* `defineCustomElement` emit wraps every payload into `detail: [...args]`
|
|
24
|
+
* (always an array), which breaks the historical `event.detail` contract
|
|
25
|
+
* consumers rely on.
|
|
26
|
+
*
|
|
27
|
+
* Events do not bubble by default; pass `{ bubbles: true, composed: true }`
|
|
28
|
+
* per call where an event must leave the component.
|
|
29
|
+
*
|
|
30
|
+
* Value controls dispatch their value events through `valueEvents.ts`
|
|
31
|
+
* instead (it also mirrors `host.value` for native v-model). Declare those
|
|
32
|
+
* events in the component's event map anyway — the docs analyzer enforces
|
|
33
|
+
* this for every caller.
|
|
34
|
+
*
|
|
35
|
+
* Every event name is all-lowercase (ADR-0017, ADR-0075; the strict
|
|
36
|
+
* analyzer fails any other): Vue's runtime hyphenates every v-on listener
|
|
37
|
+
* name, so a camelCase event is unreachable from a Vue template.
|
|
38
|
+
*/
|
|
1
39
|
export declare const useHostEmit: <EventMap extends object>() => <Name extends Extract<keyof EventMap, string>>(name: Name, ...rest: EventMap[Name] extends void ? [detail?: undefined, options?: EventInit] : [detail: EventMap[Name], options?: EventInit]) => void;
|