@mintplayer/web-components 2.15.0 → 2.17.0
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/accordion/index.mjs +5 -5
- package/calendar/index.mjs +1 -1
- package/carousel/index.mjs +57 -143
- package/charts/core/index.mjs +30 -20
- package/charts/core/src/attributes.d.ts +18 -0
- package/charts/core/src/index.d.ts +2 -0
- package/charts/core/src/view-window.d.ts +46 -0
- package/charts/hierarchy/index.mjs +245 -256
- package/charts/hierarchy/src/components/mp-hierarchy-chart.d.ts +1 -3
- package/charts/sparkline/index.mjs +27 -26
- package/charts/trend/index.mjs +21 -20
- package/checkbox/index.mjs +1 -1
- package/checkbox/src/components/mp-checkbox.d.ts +1 -0
- package/chunks/attributes-L3eKsbdy.mjs +16 -0
- package/chunks/color-mode-warning-71FmlzWX.mjs +13 -0
- package/chunks/{form-check.styles-B0pxJ6YC.mjs → form-check.styles-DqvBnspm.mjs} +24 -3
- package/chunks/{mp-calendar.element-CJ8-t-Zn.mjs → mp-calendar.element-BIHS9SZZ.mjs} +11 -6
- package/chunks/{mp-checkbox-CzwS7Y_t.mjs → mp-checkbox-zV83gILn.mjs} +44 -36
- package/chunks/mp-datatable-eRpl7-2V.mjs +2238 -0
- package/chunks/{mp-datetime-picker.element-D1CiLbHm.mjs → mp-datetime-picker.element-Cxu5-qRE.mjs} +29 -32
- package/chunks/{mp-pagination-Dea75mD4.mjs → mp-pagination-hGy4dL7p.mjs} +9 -4
- package/chunks/{mp-radio-cL46sUA0.mjs → mp-radio-BhRVNdKp.mjs} +32 -28
- package/chunks/{mp-select-BNrbPwN4.mjs → mp-select-CgqYFvUj.mjs} +41 -26
- package/chunks/{mp-splitter-Ckn1kN4v.mjs → mp-splitter-DLehrw3Y.mjs} +144 -120
- package/chunks/{mp-timepicker.element-COZEUIoE.mjs → mp-timepicker.element-BiB9lkgc.mjs} +58 -45
- package/chunks/{mp-toggle-button-eo_aTQtu.mjs → mp-toggle-button-CaS9uYLE.mjs} +26 -24
- package/chunks/{mp-treeview-C8iltDbq.mjs → mp-treeview-CaMTDrvY.mjs} +51 -50
- package/chunks/{overlay-controller-D6agzzOI.mjs → overlay-controller-BHDagokg.mjs} +130 -70
- package/chunks/{id-DNZVAnGC.mjs → resource.service--lqLwEqk.mjs} +144 -206
- package/chunks/view-window-DGvFiDnW.mjs +263 -0
- package/code-snippet/index.mjs +70 -66
- package/code-snippet/src/hljs-loaders.generated.d.ts +1 -1
- package/custom-elements.json +65750 -0
- package/datatable/index.mjs +6 -5
- package/datatable/src/components/column-resize.d.ts +11 -0
- package/datatable/src/components/mp-datatable.d.ts +206 -1
- package/datatable/src/index.d.ts +3 -1
- package/datatable/src/types/column-def.d.ts +61 -0
- package/datatable/src/types/filter.d.ts +138 -0
- package/datatable/src/types/index.d.ts +3 -2
- package/datatable/src/types/labels.d.ts +58 -0
- package/datepicker/index.mjs +10 -9
- package/datetime-picker/index.mjs +1 -1
- package/datetime-picker/src/mp-datetime-picker.element.d.ts +3 -0
- package/dock/index.mjs +430 -463
- package/dock/src/components/mint-dock-manager.element.d.ts +25 -2
- package/dock/src/core/resize.d.ts +60 -0
- package/dropdown-menu/index.mjs +4 -2
- package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +6 -1
- package/dropdown-menu/src/index.d.ts +1 -1
- package/dropdown-menu/src/types/dropdown.d.ts +14 -1
- package/dropdown-menu/src/types/index.d.ts +1 -1
- package/file-manager/index.mjs +63 -61
- package/file-manager/src/components/mp-file-manager.d.ts +4 -3
- package/multi-range/index.mjs +56 -50
- package/multi-range/src/mint-multi-range.element.d.ts +4 -10
- package/multi-range/src/pointer-geometry.d.ts +31 -0
- package/navbar/index.mjs +89 -439
- package/overlay/index.mjs +5 -2
- package/overlay/src/index.d.ts +2 -0
- package/overlay/src/overlay-controller.d.ts +27 -14
- package/overlay/src/overlay-portal.d.ts +53 -0
- package/overlay/src/placement.d.ts +48 -0
- package/package.json +7 -1
- package/pagination/index.mjs +1 -1
- package/phone-input/index.mjs +44 -40
- package/phone-input/src/components/stack.d.ts +8 -0
- package/query-builder/index.mjs +418 -466
- package/query-builder/src/dnd/drag-controller.d.ts +12 -8
- package/query-builder/src/mp-query-builder.element.d.ts +5 -1
- package/query-builder/src/mp-query-condition.element.d.ts +1 -0
- package/radio/index.mjs +1 -1
- package/radio-group/index.mjs +1 -1
- package/ribbon/index.mjs +477 -498
- package/ribbon/src/core/band-text-color.d.ts +10 -0
- package/ribbon/src/core/key-tip-allocator.d.ts +10 -0
- package/ribbon/src/core/plan-reduce-steps.d.ts +62 -0
- package/ribbon/src/mp-ribbon.element.d.ts +0 -27
- package/scheduler/index.mjs +726 -711
- package/scheduler/src/components/mp-scheduler.d.ts +19 -3
- package/scheduler/src/drag/drag-manager.d.ts +1 -9
- package/scheduler/src/input/input-handler.d.ts +12 -2
- package/scheduler/src/utils/geometry.d.ts +39 -0
- package/scheduler/src/views/timeline-view.d.ts +0 -1
- package/scheduler-core/index.mjs +84 -71
- package/scheduler-core/src/services/resource.service.d.ts +0 -12
- package/scheduler-core/src/services/timeline.service.d.ts +0 -9
- package/select/index.mjs +1 -1
- package/select/src/components/mp-select.d.ts +1 -0
- package/signature-pad/index.mjs +21 -23
- package/signature-pad/src/canvas-point.d.ts +26 -0
- package/signature-pad/src/mp-signature-pad.element.d.ts +1 -7
- package/splitter/index.mjs +1 -1
- package/splitter/src/components/mp-splitter.d.ts +16 -0
- package/splitter/src/managers/index.d.ts +1 -0
- package/splitter/src/managers/rescale-panel-sizes.d.ts +14 -0
- package/swiper-core/index.mjs +2 -2
- package/theming/bs-theme-preboot.js +1 -0
- package/theming/color-mode.css +36 -0
- package/theming/index.d.ts +1 -0
- package/theming/index.mjs +327 -0
- package/theming/src/components/mp-theme-toggle.d.ts +71 -0
- package/theming/src/cookie.d.ts +31 -0
- package/theming/src/index.d.ts +5 -0
- package/theming/src/preboot.d.ts +1 -0
- package/theming/src/resolve.d.ts +36 -0
- package/theming/src/store.d.ts +27 -0
- package/theming/src/styles/theme-toggle.styles.d.ts +2 -0
- package/theming/src/testing/fake-broadcast-channel.d.ts +35 -0
- package/theming/src/toggle-modes.d.ts +23 -0
- package/tile-manager/index.mjs +252 -211
- package/tile-manager/src/components/mint-tile-manager.element.d.ts +8 -0
- package/tile-manager/src/utils/grid-geometry.d.ts +49 -0
- package/timeline/index.mjs +156 -164
- package/timeline/src/components/mp-timeline.d.ts +41 -7
- package/timepicker/index.mjs +7 -4
- package/timepicker/src/mp-time-list.element.d.ts +26 -0
- package/timepicker/src/mp-timepicker.element.d.ts +3 -0
- package/toggle-button/index.mjs +1 -1
- package/tree-select/index.mjs +21 -9
- package/treeview/index.mjs +1 -1
- package/treeview/src/components/mp-treeview.d.ts +6 -4
- package/chunks/color-DIeST-IS.mjs +0 -224
- package/chunks/mp-datatable-UJI8E73X.mjs +0 -1400
- package/datatable/src/styles/datatable.styles.d.ts +0 -2
- package/query-builder/src/mp-query-condition.element.template.d.ts +0 -2
package/overlay/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { O as e } from "../chunks/overlay-controller-
|
|
1
|
+
import { O as e, a as o, c as n, o as t } from "../chunks/overlay-controller-BHDagokg.mjs";
|
|
2
2
|
export {
|
|
3
|
-
e as OverlayController
|
|
3
|
+
e as OverlayController,
|
|
4
|
+
o as acquirePortal,
|
|
5
|
+
n as currentOverlayContainer,
|
|
6
|
+
t as openPaneCount
|
|
4
7
|
};
|
package/overlay/src/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { acquirePortal, currentOverlayContainer, openPaneCount } from './overlay-portal';
|
|
2
|
+
export type { PortalHandle } from './overlay-portal';
|
|
1
3
|
export { OverlayController } from './overlay-controller';
|
|
2
4
|
export type { OverlayControllerOptions, OverlayPosition, OverlayOriginX, OverlayOriginY, PanelWidth, ScrollStrategy, } from './overlay-controller';
|
|
@@ -91,6 +91,24 @@ export interface OverlayControllerOptions {
|
|
|
91
91
|
* - `string` — any CSS width value (`'50vw'`, `'fit-content'`, …)
|
|
92
92
|
*/
|
|
93
93
|
panelWidth?: PanelWidth;
|
|
94
|
+
/**
|
|
95
|
+
* Render the panel into a document-root overlay pane instead of leaving it
|
|
96
|
+
* where the host rendered it. Default: false, so every existing consumer is
|
|
97
|
+
* unaffected.
|
|
98
|
+
*
|
|
99
|
+
* A panel left in place is clipped by any `overflow: auto` ancestor and
|
|
100
|
+
* stacked against whatever `z-index` its neighbours use; a portalled one is
|
|
101
|
+
* neither. Use it when the panel opens from inside a scroll container, or
|
|
102
|
+
* when the host's ancestors belong to a consumer's application and so cannot
|
|
103
|
+
* be relied on to avoid establishing a fixed containing block.
|
|
104
|
+
*
|
|
105
|
+
* The controller does **not** render the panel — it never has. It acquires
|
|
106
|
+
* the pane before the host's update, so the host can render into
|
|
107
|
+
* {@link OverlayController.portalContainer} during that same update, and
|
|
108
|
+
* releases it on close. `panel()` must therefore resolve to an element inside
|
|
109
|
+
* that container while the overlay is open.
|
|
110
|
+
*/
|
|
111
|
+
portal?: boolean;
|
|
94
112
|
onOpen?: () => void;
|
|
95
113
|
onClose?: () => void;
|
|
96
114
|
}
|
|
@@ -160,10 +178,19 @@ export declare class OverlayController implements ReactiveController {
|
|
|
160
178
|
/** Inline `padding-right` we wrote on <body> to compensate for the
|
|
161
179
|
* disappearing scrollbar — captured so release() can restore exactly. */
|
|
162
180
|
private blockedBodyPaddingRight;
|
|
181
|
+
/** Live pane in the document-root container, when `options.portal` is set. */
|
|
182
|
+
private portalHandle;
|
|
163
183
|
constructor(host: ReactiveControllerHost & HTMLElement, options: OverlayControllerOptions);
|
|
164
184
|
hostConnected(): void;
|
|
165
185
|
hostDisconnected(): void;
|
|
166
186
|
get isOpen(): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* The document-root pane to render the panel into, or `null` when this
|
|
189
|
+
* overlay is closed or not portalled. Read it from the host's update so the
|
|
190
|
+
* panel exists by the time the controller positions it.
|
|
191
|
+
*/
|
|
192
|
+
get portalContainer(): HTMLElement | null;
|
|
193
|
+
private releasePortal;
|
|
167
194
|
/**
|
|
168
195
|
* Whether this overlay is the top-most dismissible layer — i.e. whether an
|
|
169
196
|
* Escape belongs to IT rather than to something opened on top of it.
|
|
@@ -221,8 +248,6 @@ export declare class OverlayController implements ReactiveController {
|
|
|
221
248
|
* anchor re-enters the viewport.
|
|
222
249
|
*/
|
|
223
250
|
position(): void;
|
|
224
|
-
/** True when the anchor's bounding rect lies entirely outside the viewport. */
|
|
225
|
-
private isAnchorOffscreen;
|
|
226
251
|
/**
|
|
227
252
|
* Apply the configured `panelWidth` strategy to the panel element. Called
|
|
228
253
|
* from `position()` before measurement so the position-pair fit check
|
|
@@ -234,18 +259,6 @@ export declare class OverlayController implements ReactiveController {
|
|
|
234
259
|
*/
|
|
235
260
|
private applyPanelWidth;
|
|
236
261
|
private isRtl;
|
|
237
|
-
/**
|
|
238
|
-
* Compute the (left, top) at which `panel` should be placed for a single
|
|
239
|
-
* position candidate. The candidate identifies which corner of the anchor
|
|
240
|
-
* to align which corner of the panel to, plus optional pixel offsets.
|
|
241
|
-
*/
|
|
242
|
-
private placeFor;
|
|
243
|
-
private anchorXFor;
|
|
244
|
-
private anchorYFor;
|
|
245
|
-
private panelXOffsetFor;
|
|
246
|
-
private panelYOffsetFor;
|
|
247
|
-
private fitsInViewport;
|
|
248
|
-
private clampToViewport;
|
|
249
262
|
private currentStrategy;
|
|
250
263
|
/**
|
|
251
264
|
* Wire scroll + resize listeners according to the active strategy. Called
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A document-root overlay container, in the spirit of `@angular/cdk/overlay`'s
|
|
3
|
+
* `OverlayContainer` — the DOM-ownership half that `OverlayController` has
|
|
4
|
+
* deliberately never had. The controller positions; this owns where the panel
|
|
5
|
+
* lives. They compose, and either works without the other.
|
|
6
|
+
*
|
|
7
|
+
* ## Why a panel would leave its own subtree
|
|
8
|
+
*
|
|
9
|
+
* A panel rendered in place is clipped by any `overflow: auto` ancestor and
|
|
10
|
+
* stacked against whatever `z-index` its neighbours happen to use. The house
|
|
11
|
+
* answer so far has been `position: fixed` plus a hand-picked `z-index` per
|
|
12
|
+
* component, which holds only while **no ancestor establishes a fixed
|
|
13
|
+
* containing block**. That rule is enforced by comments, and it is unenforceable
|
|
14
|
+
* outright when the ancestors belong to a consumer's application — as they do
|
|
15
|
+
* for a light-DOM component such as `mp-datatable`.
|
|
16
|
+
*
|
|
17
|
+
* Moving the panel to a container that is the last child of `<body>` removes
|
|
18
|
+
* both problems at once: nothing clips it, and panes stack in DOM order rather
|
|
19
|
+
* than by a number each component invented on its own.
|
|
20
|
+
*
|
|
21
|
+
* ## The invariant this file exists to protect
|
|
22
|
+
*
|
|
23
|
+
* **The container must never establish a containing block.** No `transform`,
|
|
24
|
+
* `filter`, `backdrop-filter`, `perspective`, `contain`, `will-change` or
|
|
25
|
+
* `container-type`. Any of those would make it the containing block for the
|
|
26
|
+
* `position: fixed` panes inside it, and every panel's viewport coordinates —
|
|
27
|
+
* written by `OverlayController` from `getBoundingClientRect()` — would be
|
|
28
|
+
* silently wrong. This is the one ancestor we control; `overlay-portal.spec.ts`
|
|
29
|
+
* asserts the computed style so a later edit cannot quietly reintroduce the trap.
|
|
30
|
+
*
|
|
31
|
+
* Measured (Chromium 151, Firefox 153, WebKit 26.5): with these styles a
|
|
32
|
+
* `position: fixed` child of a pane resolves against the viewport at exactly
|
|
33
|
+
* (0, 0), and 20 acquire/release cycles leave no orphaned nodes.
|
|
34
|
+
*/
|
|
35
|
+
/** A single pane inside the shared container. Release it when the panel closes. */
|
|
36
|
+
export interface PortalHandle {
|
|
37
|
+
/** The element to render the panel into. Positioned by `OverlayController`. */
|
|
38
|
+
readonly container: HTMLElement;
|
|
39
|
+
/** Removes the pane, and the shared container with it when this was the last one. */
|
|
40
|
+
release(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Acquires a pane in the shared document-root container.
|
|
44
|
+
*
|
|
45
|
+
* Returns `null` during SSR, where there is no document to attach to; callers
|
|
46
|
+
* fall back to rendering in place, which is correct for a non-interactive
|
|
47
|
+
* server render.
|
|
48
|
+
*/
|
|
49
|
+
export declare function acquirePortal(): PortalHandle | null;
|
|
50
|
+
/** Test seam: the live container, or null when nothing is open. */
|
|
51
|
+
export declare function currentOverlayContainer(): HTMLElement | null;
|
|
52
|
+
/** Test seam. */
|
|
53
|
+
export declare function openPaneCount(): number;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { OverlayPosition } from './overlay-controller';
|
|
2
|
+
/** The parts of an anchor's bounding rect the placement reads. */
|
|
3
|
+
export interface AnchorBox {
|
|
4
|
+
left: number;
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PanelSize {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
export interface Viewport {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
/** Minimum distance kept between the panel and every viewport edge. */
|
|
19
|
+
margin: number;
|
|
20
|
+
}
|
|
21
|
+
export interface Placement {
|
|
22
|
+
left: number;
|
|
23
|
+
top: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The (left, top) that aligns the candidate's panel corner with its anchor
|
|
27
|
+
* corner, plus the candidate's pixel offsets.
|
|
28
|
+
*/
|
|
29
|
+
export declare function placeFor(candidate: OverlayPosition, anchor: AnchorBox, panel: PanelSize, rtl: boolean): Placement;
|
|
30
|
+
/** True when the placed panel lies wholly inside the viewport's margins. */
|
|
31
|
+
export declare function fitsInViewport(placed: Placement, panel: PanelSize, viewport: Viewport): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Push a placement back inside the viewport's margins. A panel larger than
|
|
34
|
+
* the viewport pins to the start (top/left) margin.
|
|
35
|
+
*/
|
|
36
|
+
export declare function clampToViewport(placed: Placement, panel: PanelSize, viewport: Viewport): Placement;
|
|
37
|
+
/** True when the anchor's rect lies entirely outside the viewport. */
|
|
38
|
+
export declare function isAnchorOffscreen(rect: AnchorBox, viewport: Pick<Viewport, 'width' | 'height'>): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Walk (anchor x position) pairs in order and take the first placement that
|
|
41
|
+
* fits the viewport. When none fits, the last pair evaluated is the fallback.
|
|
42
|
+
* Either way the placement is clamped into the viewport. Null when there are
|
|
43
|
+
* no anchors or no positions to try.
|
|
44
|
+
*/
|
|
45
|
+
export declare function choosePlacement(anchors: readonly AnchorBox[], positions: readonly OverlayPosition[], panel: PanelSize, viewport: Viewport, rtl: boolean): {
|
|
46
|
+
anchorIndex: number;
|
|
47
|
+
placement: Placement;
|
|
48
|
+
} | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/web-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Framework-agnostic Lit web components for the @mintplayer/bootstrap design system. Consumed by @mintplayer/ng-bootstrap, @mintplayer/react-bootstrap, and @mintplayer/vue-bootstrap.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"./custom-elements.json": "./custom-elements.json",
|
|
27
27
|
"./package.json": "./package.json",
|
|
28
|
+
"./theming/bs-theme-preboot.js": "./theming/bs-theme-preboot.js",
|
|
29
|
+
"./theming/color-mode.css": "./theming/color-mode.css",
|
|
28
30
|
"./a11y": {
|
|
29
31
|
"types": "./a11y/index.d.ts",
|
|
30
32
|
"import": "./a11y/index.mjs"
|
|
@@ -181,6 +183,10 @@
|
|
|
181
183
|
"types": "./tab-control/index.d.ts",
|
|
182
184
|
"import": "./tab-control/index.mjs"
|
|
183
185
|
},
|
|
186
|
+
"./theming": {
|
|
187
|
+
"types": "./theming/index.d.ts",
|
|
188
|
+
"import": "./theming/index.mjs"
|
|
189
|
+
},
|
|
184
190
|
"./tile-manager": {
|
|
185
191
|
"types": "./tile-manager/index.d.ts",
|
|
186
192
|
"import": "./tile-manager/index.mjs"
|
package/pagination/index.mjs
CHANGED
package/phone-input/index.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import { unsafeCSS as b, LitElement as p, nothing as h, html as v } from "lit";
|
|
|
2
2
|
import { createRef as f, ref as m } from "lit/directives/ref.js";
|
|
3
3
|
import { unsafeHTML as C } from "lit/directives/unsafe-html.js";
|
|
4
4
|
import "../chunks/mp-input-group-CQ55efCq.mjs";
|
|
5
|
-
import "../chunks/mp-select-
|
|
5
|
+
import "../chunks/mp-select-CgqYFvUj.mjs";
|
|
6
6
|
import { c as g, b as $, l as k } from "../chunks/validation-ChktfuxI.mjs";
|
|
7
7
|
import { l as R } from "../chunks/all-flags-BtYcfgjy.mjs";
|
|
8
|
-
import { H as
|
|
9
|
-
import { a as
|
|
8
|
+
import { H as q } from "../chunks/host-aria-WSGs7SPQ.mjs";
|
|
9
|
+
import { a as w, e as L } from "../chunks/error-text-B45eDAt1.mjs";
|
|
10
10
|
import { F as U } from "../chunks/form-associated-BR-fUvZ1.mjs";
|
|
11
11
|
import { f as A } from "../chunks/form-control.styles-C3j87Sn3.mjs";
|
|
12
12
|
import { i as S } from "../chunks/invalid-feedback.styles-he0JYrJm.mjs";
|
|
@@ -68,41 +68,45 @@ mp-select[rich] ~ .addon .flag {
|
|
|
68
68
|
--mp-group-radius-bottom-end: 0;
|
|
69
69
|
}
|
|
70
70
|
}`), c = /\d/;
|
|
71
|
-
function _(
|
|
71
|
+
function _(o, t) {
|
|
72
72
|
let e = 0;
|
|
73
|
-
const s = Math.min(t,
|
|
74
|
-
for (let i = 0; i < s; i++) c.test(
|
|
73
|
+
const s = Math.min(t, o.length);
|
|
74
|
+
for (let i = 0; i < s; i++) c.test(o[i]) && e++;
|
|
75
75
|
return e;
|
|
76
76
|
}
|
|
77
|
-
function O(
|
|
77
|
+
function O(o, t) {
|
|
78
78
|
if (t <= 0) return 0;
|
|
79
79
|
let e = 0;
|
|
80
|
-
for (let s = 0; s <
|
|
81
|
-
if (c.test(
|
|
80
|
+
for (let s = 0; s < o.length; s++)
|
|
81
|
+
if (c.test(o[s]) && (e++, e === t))
|
|
82
82
|
return s + 1;
|
|
83
|
-
return
|
|
83
|
+
return o.length;
|
|
84
84
|
}
|
|
85
|
-
function x(
|
|
85
|
+
function x(o, t, e) {
|
|
86
86
|
let s = e === -1 ? t - 1 : t;
|
|
87
|
-
for (; s >= 0 && s <
|
|
88
|
-
if (c.test(
|
|
87
|
+
for (; s >= 0 && s < o.length; ) {
|
|
88
|
+
if (c.test(o[s])) return s;
|
|
89
89
|
s += e;
|
|
90
90
|
}
|
|
91
91
|
return -1;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
93
|
+
function a(o) {
|
|
94
|
+
return o.replace(/\D/g, "");
|
|
95
|
+
}
|
|
96
|
+
const T = 352;
|
|
97
|
+
function P(o) {
|
|
98
|
+
return o > 0 && o <= T;
|
|
95
99
|
}
|
|
96
100
|
let y = 0;
|
|
97
|
-
const
|
|
101
|
+
const I = (o) => o.replace(/[&<>"']/g, (t) => `&#${t.charCodeAt(0)};`);
|
|
98
102
|
class d extends U(p) {
|
|
99
103
|
constructor() {
|
|
100
|
-
super(...arguments), this._country = null, this._digits = "", this._rulesWanted = !1, this._rulesPending = Promise.resolve(), this._locale = null, this._preferred = [], this._only = null, this._placeholder = null, this._autocomplete = "tel-national", this._inputLabel = null, this._countryLabel = null, this._errorText = null, this._errorId = `mp-phone-input-${++y}-error`, this._dialId = `mp-phone-input-${y}-dial`, this._list = [], this._listKey = "", this._flagsRequested = !1, this._composing = !1, this._preEdit = null, this._inputRef = f(), this._selectRef = f(), this.hostAria = new
|
|
104
|
+
super(...arguments), this._country = null, this._digits = "", this._rulesWanted = !1, this._rulesPending = Promise.resolve(), this._locale = null, this._preferred = [], this._only = null, this._placeholder = null, this._autocomplete = "tel-national", this._inputLabel = null, this._countryLabel = null, this._errorText = null, this._errorId = `mp-phone-input-${++y}-error`, this._dialId = `mp-phone-input-${y}-dial`, this._list = [], this._listKey = "", this._flagsRequested = !1, this._composing = !1, this._preEdit = null, this._inputRef = f(), this._selectRef = f(), this.hostAria = new q(this, {
|
|
101
105
|
referenceTarget: () => this._inputRef.value ?? null,
|
|
102
|
-
describedByExtras: () =>
|
|
106
|
+
describedByExtras: () => w(this.renderRoot)
|
|
103
107
|
}), this.renderCountryOption = (t) => {
|
|
104
108
|
const e = this.countryList().find((i) => i.iso2 === t.value);
|
|
105
|
-
return e ? `<span class="flag-box" aria-hidden="true">${this._flags?.[e.iso2] ?? ""}</span><span class="rich-label" data-list-only>${
|
|
109
|
+
return e ? `<span class="flag-box" aria-hidden="true">${this._flags?.[e.iso2] ?? ""}</span><span class="rich-label" data-list-only>${I(e.name)}</span><span data-list-only>+${e.dialCode}</span><span data-closed-only>${e.iso2.toUpperCase()}</span>` : void 0;
|
|
106
110
|
}, this.onCountryPicked = (t) => {
|
|
107
111
|
t.stopPropagation();
|
|
108
112
|
const e = t.detail.value;
|
|
@@ -122,12 +126,12 @@ class d extends U(p) {
|
|
|
122
126
|
if (t.key !== "Backspace" && t.key !== "Delete") return;
|
|
123
127
|
const e = this._inputRef.value;
|
|
124
128
|
if (!e || e.selectionStart !== e.selectionEnd) return;
|
|
125
|
-
const s = e.selectionStart ?? 0, i = t.key === "Backspace" ? -1 : 1,
|
|
126
|
-
if (
|
|
129
|
+
const s = e.selectionStart ?? 0, i = t.key === "Backspace" ? -1 : 1, n = i === -1 ? e.value[s - 1] : e.value[s];
|
|
130
|
+
if (n === void 0 || /\d/.test(n)) return;
|
|
127
131
|
t.preventDefault();
|
|
128
132
|
const r = x(e.value, s, i);
|
|
129
133
|
if (r === -1) return;
|
|
130
|
-
const l = _(e.value, r), u =
|
|
134
|
+
const l = _(e.value, r), u = a(e.value);
|
|
131
135
|
this.#i(e, u.slice(0, l) + u.slice(l + 1), l);
|
|
132
136
|
}, this.onInput = () => {
|
|
133
137
|
const t = this._inputRef.value;
|
|
@@ -185,7 +189,7 @@ class d extends U(p) {
|
|
|
185
189
|
return;
|
|
186
190
|
}
|
|
187
191
|
const s = g(e, this._only ?? void 0);
|
|
188
|
-
s ? (this._digits = s.nationalNumber, this.#t(s.country.iso2, { fromUser: !1 })) : this._digits =
|
|
192
|
+
s ? (this._digits = s.nationalNumber, this.#t(s.country.iso2, { fromUser: !1 })) : this._digits = a(e), this._digits && this.#e(), this.requestUpdate();
|
|
189
193
|
}
|
|
190
194
|
get dialCode() {
|
|
191
195
|
return this.countryList().find((t) => t.iso2 === this.country)?.dialCode ?? "";
|
|
@@ -322,8 +326,8 @@ class d extends U(p) {
|
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
328
|
connectedCallback() {
|
|
325
|
-
super.connectedCallback(), this.#
|
|
326
|
-
const e = t[t.length - 1]?.contentRect.width ?? 0, s = e
|
|
329
|
+
super.connectedCallback(), this.#a(), this._digits && this.#e(), typeof ResizeObserver < "u" && (this.#s ??= new ResizeObserver((t) => {
|
|
330
|
+
const e = t[t.length - 1]?.contentRect.width ?? 0, s = P(e);
|
|
327
331
|
this.renderRoot?.querySelector("mp-input-group")?.toggleAttribute("stacked", s);
|
|
328
332
|
}), this.#s.observe(this));
|
|
329
333
|
}
|
|
@@ -332,7 +336,7 @@ class d extends U(p) {
|
|
|
332
336
|
}
|
|
333
337
|
// ---- rendering ------------------------------------------------------------
|
|
334
338
|
render() {
|
|
335
|
-
const t = this.country, e = this.dialCode, s = this.effectiveDisabled, i = this.hasAttribute("invalid"),
|
|
339
|
+
const t = this.country, e = this.dialCode, s = this.effectiveDisabled, i = this.hasAttribute("invalid"), n = L(this._errorId, this._errorText, i), r = typeof n.id == "string" ? `${this._dialId} ${n.id}` : this._dialId, l = this.getAttribute("aria-label") ?? this._inputLabel ?? "Phone number", u = this._flags?.[t];
|
|
336
340
|
return v`
|
|
337
341
|
<mp-input-group>
|
|
338
342
|
<mp-select
|
|
@@ -370,7 +374,7 @@ class d extends U(p) {
|
|
|
370
374
|
aria-label=${l}
|
|
371
375
|
aria-invalid=${i ? "true" : h}
|
|
372
376
|
aria-required=${this.hasAttribute("required") ? "true" : h}
|
|
373
|
-
aria-errormessage=${
|
|
377
|
+
aria-errormessage=${n.id}
|
|
374
378
|
aria-describedby=${r}
|
|
375
379
|
@beforeinput=${this.onBeforeInput}
|
|
376
380
|
@keydown=${this.onKeydown}
|
|
@@ -380,7 +384,7 @@ class d extends U(p) {
|
|
|
380
384
|
@compositionend=${this.onCompositionEnd}
|
|
381
385
|
/>
|
|
382
386
|
</mp-input-group>
|
|
383
|
-
${
|
|
387
|
+
${n.node}
|
|
384
388
|
`;
|
|
385
389
|
}
|
|
386
390
|
updated() {
|
|
@@ -418,7 +422,7 @@ class d extends U(p) {
|
|
|
418
422
|
}
|
|
419
423
|
// ---- country + rules ------------------------------------------------------
|
|
420
424
|
#t(t, { fromUser: e }) {
|
|
421
|
-
!t || t === this._country || (this._country = t, this.getAttribute("country") !== t && this.setAttribute("country", t), this._rules = this._rules?.country === t ? this._rules : void 0, this._rulesWanted && this.#
|
|
425
|
+
!t || t === this._country || (this._country = t, this.getAttribute("country") !== t && this.setAttribute("country", t), this._rules = this._rules?.country === t ? this._rules : void 0, this._rulesWanted && this.#n(t), this.#a(), e && this.dispatchEvent(
|
|
422
426
|
new CustomEvent("country-change", {
|
|
423
427
|
detail: { country: t, dialCode: this.dialCode },
|
|
424
428
|
bubbles: !0,
|
|
@@ -427,7 +431,7 @@ class d extends U(p) {
|
|
|
427
431
|
), this.requestUpdate());
|
|
428
432
|
}
|
|
429
433
|
#e() {
|
|
430
|
-
this._rulesWanted || (this._rulesWanted = !0, this.#
|
|
434
|
+
this._rulesWanted || (this._rulesWanted = !0, this.#n(this.country));
|
|
431
435
|
}
|
|
432
436
|
/**
|
|
433
437
|
* `valid` is `undefined` until the selected country's rules have loaded, and
|
|
@@ -443,7 +447,7 @@ class d extends U(p) {
|
|
|
443
447
|
* see `getUpdateComplete`. Without an observable settle, the only way to
|
|
444
448
|
* wait for rules is to guess a timeout, which is what made D17 flaky.
|
|
445
449
|
*/
|
|
446
|
-
#
|
|
450
|
+
#n(t) {
|
|
447
451
|
this._rulesPending = k(t).then((e) => {
|
|
448
452
|
!e || this.country !== t || (this._rules = e, this.requestUpdate(), this.#r());
|
|
449
453
|
});
|
|
@@ -459,7 +463,7 @@ class d extends U(p) {
|
|
|
459
463
|
* one resolution, so a single `requestUpdate()` renders the addon flag and all
|
|
460
464
|
* 244 options together — no partial-fill pass, and no re-render per flag.
|
|
461
465
|
*/
|
|
462
|
-
#
|
|
466
|
+
#a() {
|
|
463
467
|
this._flagsRequested || (this._flagsRequested = !0, R().then((t) => {
|
|
464
468
|
this._flags = t, this.requestUpdate();
|
|
465
469
|
}));
|
|
@@ -467,28 +471,28 @@ class d extends U(p) {
|
|
|
467
471
|
#l(t, e, s) {
|
|
468
472
|
const i = g(e, this._only ?? void 0);
|
|
469
473
|
if (i) {
|
|
470
|
-
i.dialCode !== this.dialCode && this.#t(i.country.iso2, { fromUser: !0 }), this.#e(), this.#i(t, i.nationalNumber,
|
|
474
|
+
i.dialCode !== this.dialCode && this.#t(i.country.iso2, { fromUser: !0 }), this.#e(), this.#i(t, i.nationalNumber, a(i.nationalNumber).length);
|
|
471
475
|
return;
|
|
472
476
|
}
|
|
473
|
-
const
|
|
474
|
-
if (r &&
|
|
477
|
+
const n = a(e), r = this._preEdit;
|
|
478
|
+
if (r && n === a(r.value) && e !== r.value) {
|
|
475
479
|
t.value = r.value, t.setSelectionRange(r.start, r.start);
|
|
476
480
|
return;
|
|
477
481
|
}
|
|
478
|
-
if (r && this._rules &&
|
|
479
|
-
const l = this.formatted(
|
|
482
|
+
if (r && this._rules && n.length === a(r.value).length + 1 && this._rules.lengthProblem(n) === "TOO_LONG" && this._rules.lengthProblem(a(r.value)) !== "TOO_LONG") {
|
|
483
|
+
const l = this.formatted(a(r.value));
|
|
480
484
|
t.value = l, t.setSelectionRange(r.start, r.start);
|
|
481
485
|
return;
|
|
482
486
|
}
|
|
483
|
-
this.#i(t,
|
|
487
|
+
this.#i(t, n, _(e, s));
|
|
484
488
|
}
|
|
485
489
|
/** Rule 1: place the caret after the same DIGIT COUNT in the new formatting. */
|
|
486
490
|
#i(t, e, s) {
|
|
487
491
|
this._digits = e;
|
|
488
492
|
const i = this.formatted(e);
|
|
489
493
|
t.value = i;
|
|
490
|
-
const
|
|
491
|
-
t.setSelectionRange(
|
|
494
|
+
const n = O(i, s);
|
|
495
|
+
t.setSelectionRange(n, n), this._preEdit = { value: i, start: n }, this.requestUpdate(), this.#r();
|
|
492
496
|
}
|
|
493
497
|
#r() {
|
|
494
498
|
this.dispatchEvent(
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Matches the `@container (max-width: 22rem)` threshold in the stylesheet. */
|
|
2
|
+
export declare const STACK_THRESHOLD_PX = 352;
|
|
3
|
+
/**
|
|
4
|
+
* Whether the input group should pair its corners vertically at this host
|
|
5
|
+
* width. A width of 0 means "not measured yet" (no layout, a detached host,
|
|
6
|
+
* jsdom), not "narrow", so it never stacks.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isStackedWidth(width: number): boolean;
|