@mintplayer/web-components 1.0.0 → 1.1.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.
Files changed (236) hide show
  1. package/a11y/index.mjs +2 -56
  2. package/calendar/index.mjs +2 -363
  3. package/checkbox/index.mjs +4 -0
  4. package/checkbox/src/components/index.d.ts +2 -0
  5. package/checkbox/src/components/mp-checkbox.d.ts +69 -0
  6. package/checkbox/src/index.d.ts +2 -0
  7. package/chunks/color-C4VT0EL7.mjs +847 -0
  8. package/chunks/form-check.styles-jBlHetYX.mjs +151 -0
  9. package/chunks/live-announcer-CZDTKulf.mjs +58 -0
  10. package/chunks/mp-calendar.element-UC68iDbi.mjs +365 -0
  11. package/chunks/mp-checkbox-BokLL7BS.mjs +211 -0
  12. package/chunks/mp-datatable-CpAu8JJD.mjs +750 -0
  13. package/chunks/mp-pagination-BGxsawFL.mjs +326 -0
  14. package/chunks/mp-select-BDS1-YGn.mjs +254 -0
  15. package/chunks/mp-splitter-C8cGCmac.mjs +633 -0
  16. package/chunks/mp-tab-page-D1b4x-y2.mjs +414 -0
  17. package/chunks/mp-timepicker.element-BwEiwX92.mjs +428 -0
  18. package/chunks/mp-toggle-button-dLZNDUVz.mjs +534 -0
  19. package/chunks/mp-treeview-Bfq4_IVW.mjs +474 -0
  20. package/code-snippet/index.mjs +16 -13
  21. package/datatable/index.mjs +7 -0
  22. package/datatable/src/components/index.d.ts +2 -0
  23. package/datatable/src/components/mp-datatable.d.ts +156 -0
  24. package/datatable/src/index.d.ts +6 -0
  25. package/datatable/src/sort/compute-next-sort.d.ts +18 -0
  26. package/datatable/src/sort/index.d.ts +3 -0
  27. package/datatable/src/sort/sort-rows.d.ts +6 -0
  28. package/datatable/src/styles/datatable.styles.d.ts +2 -0
  29. package/datatable/src/styles/index.d.ts +1 -0
  30. package/datatable/src/types/column-def.d.ts +30 -0
  31. package/datatable/src/types/index.d.ts +1 -0
  32. package/datepicker/index.mjs +240 -0
  33. package/datepicker/src/index.d.ts +1 -0
  34. package/datepicker/src/mp-datepicker.element.d.ts +94 -0
  35. package/datepicker/src/mp-datepicker.element.template.d.ts +2 -0
  36. package/datetime-picker/index.mjs +427 -0
  37. package/datetime-picker/src/index.d.ts +1 -0
  38. package/datetime-picker/src/mp-datetime-picker.element.d.ts +174 -0
  39. package/datetime-picker/src/mp-datetime-picker.element.template.d.ts +2 -0
  40. package/dock/index.mjs +2402 -0
  41. package/dock/src/components/index.d.ts +1 -0
  42. package/dock/src/components/mint-dock-manager.element.d.ts +313 -0
  43. package/dock/src/components/mint-dock-manager.element.template.d.ts +2 -0
  44. package/dock/src/index.d.ts +2 -0
  45. package/dock/src/types/dock-layout.d.ts +65 -0
  46. package/dock/src/types/index.d.ts +1 -0
  47. package/file-manager/index.mjs +1263 -0
  48. package/file-manager/src/components/index.d.ts +2 -0
  49. package/file-manager/src/components/mp-file-manager.d.ts +320 -0
  50. package/file-manager/src/index.d.ts +5 -0
  51. package/file-manager/src/styles/file-manager.styles.d.ts +2 -0
  52. package/file-manager/src/styles/index.d.ts +1 -0
  53. package/file-manager/src/types/file-system-node.d.ts +24 -0
  54. package/file-manager/src/types/index.d.ts +3 -0
  55. package/file-manager/src/types/messages.d.ts +43 -0
  56. package/multi-range/index.mjs +407 -0
  57. package/multi-range/src/index.d.ts +2 -0
  58. package/multi-range/src/mint-multi-range.element.d.ts +124 -0
  59. package/multi-range/src/mint-multi-range.element.template.d.ts +2 -0
  60. package/multi-range/src/types/multi-range-orientation.d.ts +1 -0
  61. package/otp-input/index.mjs +362 -0
  62. package/otp-input/src/index.d.ts +4 -0
  63. package/otp-input/src/mint-otp-input.element.d.ts +134 -0
  64. package/otp-input/src/mint-otp-input.element.template.d.ts +2 -0
  65. package/otp-input/src/types/otp-input-case.d.ts +1 -0
  66. package/otp-input/src/types/otp-input-size.d.ts +1 -0
  67. package/otp-input/src/types/otp-input-type.d.ts +1 -0
  68. package/overlay/index.mjs +260 -0
  69. package/overlay/src/index.d.ts +2 -0
  70. package/overlay/src/overlay-controller.d.ts +205 -0
  71. package/package.json +1 -1
  72. package/pagination/index.mjs +5 -0
  73. package/pagination/src/components/index.d.ts +2 -0
  74. package/pagination/src/components/mp-pagination.d.ts +95 -0
  75. package/pagination/src/index.d.ts +2 -0
  76. package/pagination/src/styles/index.d.ts +1 -0
  77. package/pagination/src/styles/pagination.styles.d.ts +2 -0
  78. package/query-builder/index.mjs +3720 -0
  79. package/query-builder/src/context.d.ts +14 -0
  80. package/query-builder/src/dnd/drag-controller.d.ts +69 -0
  81. package/query-builder/src/index.d.ts +23 -0
  82. package/query-builder/src/model/default-tree.d.ts +7 -0
  83. package/query-builder/src/model/editor.d.ts +15 -0
  84. package/query-builder/src/model/errors.d.ts +6 -0
  85. package/query-builder/src/model/expression.d.ts +22 -0
  86. package/query-builder/src/model/field-def.d.ts +17 -0
  87. package/query-builder/src/model/messages.d.ts +17 -0
  88. package/query-builder/src/model/operator-overrides.d.ts +21 -0
  89. package/query-builder/src/model/operators.d.ts +8 -0
  90. package/query-builder/src/model/saved-query.d.ts +6 -0
  91. package/query-builder/src/model/sort.d.ts +9 -0
  92. package/query-builder/src/model/tree-ops.d.ts +56 -0
  93. package/query-builder/src/mp-query-builder.element.d.ts +158 -0
  94. package/query-builder/src/mp-query-builder.element.template.d.ts +2 -0
  95. package/query-builder/src/mp-query-condition.element.d.ts +44 -0
  96. package/query-builder/src/mp-query-condition.element.template.d.ts +2 -0
  97. package/query-builder/src/mp-query-group.element.d.ts +52 -0
  98. package/query-builder/src/mp-query-group.element.template.d.ts +2 -0
  99. package/query-builder/src/mp-query-subquery.element.d.ts +37 -0
  100. package/query-builder/src/mp-query-subquery.element.template.d.ts +2 -0
  101. package/query-builder/src/preview/render-expression.d.ts +23 -0
  102. package/query-builder/src/value-editors/builtin-editors.d.ts +6 -0
  103. package/query-builder/src/visitor/visit-tree.d.ts +29 -0
  104. package/query-builder/src/visitor/visitor-types.d.ts +15 -0
  105. package/radio/index.mjs +162 -0
  106. package/radio/src/components/index.d.ts +2 -0
  107. package/radio/src/components/mp-radio.d.ts +63 -0
  108. package/radio/src/index.d.ts +2 -0
  109. package/ribbon/index.mjs +3151 -0
  110. package/ribbon/src/index.d.ts +10 -0
  111. package/ribbon/src/items/index.d.ts +15 -0
  112. package/ribbon/src/items/mp-ribbon-button.element.d.ts +10 -0
  113. package/ribbon/src/items/mp-ribbon-checkbox.element.d.ts +11 -0
  114. package/ribbon/src/items/mp-ribbon-color-picker.element.d.ts +12 -0
  115. package/ribbon/src/items/mp-ribbon-combobox.element.d.ts +19 -0
  116. package/ribbon/src/items/mp-ribbon-dropdown-button.element.d.ts +16 -0
  117. package/ribbon/src/items/mp-ribbon-gallery-item.element.d.ts +15 -0
  118. package/ribbon/src/items/mp-ribbon-gallery.element.d.ts +11 -0
  119. package/ribbon/src/items/mp-ribbon-group-button.element.d.ts +18 -0
  120. package/ribbon/src/items/mp-ribbon-item-base.d.ts +68 -0
  121. package/ribbon/src/items/mp-ribbon-menu-item.element.d.ts +13 -0
  122. package/ribbon/src/items/mp-ribbon-menu-separator.element.d.ts +6 -0
  123. package/ribbon/src/items/mp-ribbon-split-button.element.d.ts +23 -0
  124. package/ribbon/src/items/mp-ribbon-template-item.element.d.ts +12 -0
  125. package/ribbon/src/items/mp-ribbon-toggle-button.element.d.ts +12 -0
  126. package/ribbon/src/mp-quick-access-toolbar.element.d.ts +35 -0
  127. package/ribbon/src/mp-ribbon-contextual-tab-set.element.d.ts +18 -0
  128. package/ribbon/src/mp-ribbon-group.element.d.ts +59 -0
  129. package/ribbon/src/mp-ribbon-tab.element.d.ts +72 -0
  130. package/ribbon/src/mp-ribbon.element.d.ts +211 -0
  131. package/ribbon/src/types/ribbon.types.d.ts +4 -0
  132. package/scheduler/index.mjs +3567 -0
  133. package/scheduler/src/components/mp-scheduler.d.ts +238 -0
  134. package/scheduler/src/drag/drag-manager.d.ts +90 -0
  135. package/scheduler/src/drag/drag-preview.d.ts +42 -0
  136. package/scheduler/src/drag/drag-state-machine.d.ts +102 -0
  137. package/scheduler/src/drag/drag-types.d.ts +104 -0
  138. package/scheduler/src/drag/index.d.ts +4 -0
  139. package/scheduler/src/events/event-types.d.ts +58 -0
  140. package/scheduler/src/events/index.d.ts +2 -0
  141. package/scheduler/src/events/scheduler-event-emitter.d.ts +52 -0
  142. package/scheduler/src/index.d.ts +6 -0
  143. package/scheduler/src/input/index.d.ts +2 -0
  144. package/scheduler/src/input/input-handler.d.ts +105 -0
  145. package/scheduler/src/input/pointer-event.d.ts +39 -0
  146. package/scheduler/src/state/scheduler-state.d.ts +189 -0
  147. package/scheduler/src/styles/scheduler.styles.d.ts +2 -0
  148. package/scheduler/src/views/base-view.d.ts +87 -0
  149. package/scheduler/src/views/day-view.d.ts +25 -0
  150. package/scheduler/src/views/index.d.ts +6 -0
  151. package/scheduler/src/views/month-view.d.ts +27 -0
  152. package/scheduler/src/views/timeline-view.d.ts +23 -0
  153. package/scheduler/src/views/week-view.d.ts +28 -0
  154. package/scheduler/src/views/year-view.d.ts +25 -0
  155. package/scheduler-core/index.mjs +174 -0
  156. package/scheduler-core/src/index.d.ts +3 -0
  157. package/scheduler-core/src/models/drag-state.d.ts +43 -0
  158. package/scheduler-core/src/models/event.d.ts +111 -0
  159. package/scheduler-core/src/models/events.d.ts +108 -0
  160. package/scheduler-core/src/models/index.d.ts +7 -0
  161. package/scheduler-core/src/models/options.d.ts +88 -0
  162. package/scheduler-core/src/models/resource.d.ts +58 -0
  163. package/scheduler-core/src/models/time-slot.d.ts +31 -0
  164. package/scheduler-core/src/models/types.d.ts +20 -0
  165. package/scheduler-core/src/services/date.service.d.ts +140 -0
  166. package/scheduler-core/src/services/index.d.ts +4 -0
  167. package/scheduler-core/src/services/position.service.d.ts +35 -0
  168. package/scheduler-core/src/services/resource.service.d.ts +83 -0
  169. package/scheduler-core/src/services/timeline.service.d.ts +103 -0
  170. package/scheduler-core/src/utils/color.d.ts +24 -0
  171. package/scheduler-core/src/utils/dom.d.ts +54 -0
  172. package/scheduler-core/src/utils/id.d.ts +16 -0
  173. package/scheduler-core/src/utils/index.d.ts +3 -0
  174. package/select/index.mjs +4 -0
  175. package/select/src/components/index.d.ts +2 -0
  176. package/select/src/components/mp-select.d.ts +82 -0
  177. package/select/src/index.d.ts +2 -0
  178. package/splitter/index.mjs +10 -0
  179. package/splitter/src/components/index.d.ts +2 -0
  180. package/splitter/src/components/mp-splitter.d.ts +109 -0
  181. package/splitter/src/index.d.ts +11 -0
  182. package/splitter/src/input/index.d.ts +4 -0
  183. package/splitter/src/input/input-handler.d.ts +36 -0
  184. package/splitter/src/input/pointer-event.d.ts +9 -0
  185. package/splitter/src/managers/index.d.ts +2 -0
  186. package/splitter/src/managers/resize-manager.d.ts +13 -0
  187. package/splitter/src/state/index.d.ts +2 -0
  188. package/splitter/src/state/splitter-state.d.ts +24 -0
  189. package/splitter/src/styles/index.d.ts +1 -0
  190. package/splitter/src/styles/splitter.styles.d.ts +2 -0
  191. package/splitter/src/types/direction.d.ts +1 -0
  192. package/splitter/src/types/index.d.ts +5 -0
  193. package/splitter/src/types/panel-info.d.ts +6 -0
  194. package/splitter/src/types/point.d.ts +4 -0
  195. package/splitter/src/types/resize-operation.d.ts +13 -0
  196. package/tab-control/index.mjs +6 -0
  197. package/tab-control/src/components/index.d.ts +3 -0
  198. package/tab-control/src/components/mp-tab-control.d.ts +50 -0
  199. package/tab-control/src/components/mp-tab-page.d.ts +35 -0
  200. package/tab-control/src/index.d.ts +4 -0
  201. package/tab-control/src/styles/index.d.ts +1 -0
  202. package/tab-control/src/styles/tab-control.styles.d.ts +2 -0
  203. package/tab-control/src/types/index.d.ts +1 -0
  204. package/tab-control/src/types/tabs-position.d.ts +1 -0
  205. package/tile-manager/index.mjs +867 -0
  206. package/tile-manager/src/components/index.d.ts +2 -0
  207. package/tile-manager/src/components/mint-tile-manager.element.d.ts +204 -0
  208. package/tile-manager/src/components/mint-tile-manager.element.template.d.ts +2 -0
  209. package/tile-manager/src/index.d.ts +4 -0
  210. package/tile-manager/src/types/grid-rect.d.ts +12 -0
  211. package/tile-manager/src/types/index.d.ts +3 -0
  212. package/tile-manager/src/types/tile-layout-snapshot.d.ts +15 -0
  213. package/tile-manager/src/types/tile-position.d.ts +10 -0
  214. package/tile-manager/src/utils/index.d.ts +1 -0
  215. package/tile-manager/src/utils/pack.d.ts +24 -0
  216. package/timepicker/index.mjs +5 -0
  217. package/timepicker/src/index.d.ts +2 -0
  218. package/timepicker/src/mp-time-list.element.d.ts +76 -0
  219. package/timepicker/src/mp-time-list.element.template.d.ts +2 -0
  220. package/timepicker/src/mp-timepicker.element.d.ts +87 -0
  221. package/timepicker/src/mp-timepicker.element.template.d.ts +2 -0
  222. package/toggle-button/index.mjs +5 -0
  223. package/toggle-button/src/components/index.d.ts +2 -0
  224. package/toggle-button/src/components/mp-toggle-button.d.ts +50 -0
  225. package/toggle-button/src/index.d.ts +3 -0
  226. package/toggle-button/src/styles/index.d.ts +1 -0
  227. package/toggle-button/src/styles/toggle-button.styles.d.ts +2 -0
  228. package/treeview/index.mjs +5 -0
  229. package/treeview/src/components/index.d.ts +2 -0
  230. package/treeview/src/components/mp-treeview.d.ts +113 -0
  231. package/treeview/src/index.d.ts +4 -0
  232. package/treeview/src/styles/index.d.ts +1 -0
  233. package/treeview/src/styles/treeview.styles.d.ts +2 -0
  234. package/treeview/src/types/index.d.ts +1 -0
  235. package/treeview/src/types/tree-node.d.ts +14 -0
  236. package/custom-elements.json +0 -1774
@@ -0,0 +1,260 @@
1
+ const k = [
2
+ { originX: "start", originY: "bottom", overlayX: "start", overlayY: "top" },
3
+ { originX: "start", originY: "top", overlayX: "start", overlayY: "bottom" }
4
+ ];
5
+ class r {
6
+ constructor(t, e) {
7
+ this._open = !1, this.mouseDownAttached = !1, this.stackToken = null, this.activeAnchor = null, this.positionFrame = 0, this.scrollListenersAttached = !1, this.blockedScroll = null, this.blockedBodyPaddingRight = null, this.onScroll = () => {
8
+ if (!this._open) return;
9
+ const o = this.currentStrategy();
10
+ if (o === "close") {
11
+ this.close(!1);
12
+ return;
13
+ }
14
+ o === "reposition" && this.schedulePosition();
15
+ }, this.onResize = () => {
16
+ this._open && this.schedulePosition();
17
+ }, this.onKeyDown = (o) => {
18
+ o.key === "Escape" && this._open && this.isTopOfStack() && (this.close(), o.preventDefault());
19
+ }, this.onMouseDown = (o) => {
20
+ this._open && (o.composedPath().includes(this.host) || this.close(!1));
21
+ }, this.host = t, this.options = e, t.addController(this);
22
+ }
23
+ static {
24
+ this.openStack = [];
25
+ }
26
+ /**
27
+ * Allocate a frame on top of the shared overlay stack. Use this from code
28
+ * paths that don't own a full `OverlayController` instance. Pair every
29
+ * `pushFrame()` with a `releaseFrame(token)`.
30
+ */
31
+ static pushFrame() {
32
+ const t = Symbol("overlay-frame-external");
33
+ return r.openStack.push(t), t;
34
+ }
35
+ static releaseFrame(t) {
36
+ const e = r.openStack.lastIndexOf(t);
37
+ e >= 0 && r.openStack.splice(e, 1);
38
+ }
39
+ static isFrameTop(t) {
40
+ return r.openStack.length > 0 && r.openStack[r.openStack.length - 1] === t;
41
+ }
42
+ hostConnected() {
43
+ document.addEventListener("keydown", this.onKeyDown);
44
+ }
45
+ hostDisconnected() {
46
+ document.removeEventListener("keydown", this.onKeyDown), this.detachMouseDown(), this.stackToken && this.releaseStackToken();
47
+ }
48
+ get isOpen() {
49
+ return this._open;
50
+ }
51
+ async open() {
52
+ this._open || (this._open = !0, this.stackToken = r.pushFrame(), this.host.setAttribute("data-menu-open", ""), this.host.requestUpdate(), await this.host.updateComplete, this.position(), this.attachScrollListeners(), setTimeout(() => this.attachMouseDown(), 0), this.options.onOpen?.());
53
+ }
54
+ close(t = !0) {
55
+ this._open && (this._open = !1, this.releaseStackToken(), this.host.removeAttribute("data-menu-open"), this.host.requestUpdate(), this.detachMouseDown(), this.detachScrollListeners(), this.positionFrame && (cancelAnimationFrame(this.positionFrame), this.positionFrame = 0), t && (this.options.trigger?.() ?? this.activeAnchor)?.focus(), this.activeAnchor = null, this.options.onClose?.());
56
+ }
57
+ async toggle() {
58
+ this._open ? this.close() : await this.open();
59
+ }
60
+ /**
61
+ * Resolve the list of candidate anchors from `anchor()`. Single-element
62
+ * returns become a one-item array; null returns become an empty array.
63
+ * Nulls inside arrays are filtered out.
64
+ */
65
+ resolveAnchors() {
66
+ const t = this.options.anchor();
67
+ if (t === null) return [];
68
+ if (Array.isArray(t)) {
69
+ const e = t.filter((o) => o != null);
70
+ return e.length === 0 && t.length > 0 && console.warn("[OverlayController] anchor() returned an array of all-null elements."), e;
71
+ }
72
+ return [t];
73
+ }
74
+ /**
75
+ * Resolve the *active* anchor — the one used in the most recent positioning
76
+ * pass, or the first available one if none has been picked yet.
77
+ */
78
+ resolveAnchor() {
79
+ return this.activeAnchor ? this.activeAnchor : this.resolveAnchors()[0] ?? null;
80
+ }
81
+ /**
82
+ * Walk the configured `positions` and pick the first candidate whose panel
83
+ * rect fully fits inside the viewport (minus `viewportMargin`). If none fit,
84
+ * the last candidate is applied and clamped to viewport edges (push behaviour).
85
+ *
86
+ * `start`/`end` are direction-aware: in RTL contexts they swap to match
87
+ * visual layout.
88
+ *
89
+ * Sticky-offscreen behaviour: when `stickyOnAnchorOffscreen` is true and the
90
+ * anchor's bounding rect is entirely outside the viewport, the panel is
91
+ * pinned to its last in-viewport position (clamped to viewport edges) rather
92
+ * than disappearing with the anchor. Normal positioning resumes when the
93
+ * anchor re-enters the viewport.
94
+ */
95
+ position() {
96
+ const t = this.resolveAnchors(), e = this.options.panel();
97
+ if (t.length === 0 || !e) return;
98
+ this.applyPanelWidth(e, t[0]);
99
+ const o = this.options.viewportMargin ?? 8, i = e.getBoundingClientRect(), s = window.innerWidth, n = window.innerHeight, h = t[0].getBoundingClientRect();
100
+ if (this.options.stickyOnAnchorOffscreen && this.isAnchorOffscreen(h, s, n)) {
101
+ const l = parseFloat(e.style.left) || i.left, d = parseFloat(e.style.top) || i.top, c = this.clampToViewport({ left: l, top: d }, i, s, n, o);
102
+ e.style.left = `${c.left}px`, e.style.top = `${c.top}px`;
103
+ return;
104
+ }
105
+ const a = this.options.positions ?? k, m = this.isRtl();
106
+ let p = null, u = null;
107
+ t: for (const l of t) {
108
+ const d = l.getBoundingClientRect();
109
+ for (const c of a) {
110
+ const y = this.placeFor(c, d, i, m);
111
+ if (p = l, u = y, this.fitsInViewport(y, i, s, n, o)) break t;
112
+ }
113
+ }
114
+ if (!u || !p) return;
115
+ this.activeAnchor = p;
116
+ const f = this.clampToViewport(u, i, s, n, o);
117
+ e.style.left = `${f.left}px`, e.style.top = `${f.top}px`;
118
+ }
119
+ /** True when the anchor's bounding rect lies entirely outside the viewport. */
120
+ isAnchorOffscreen(t, e, o) {
121
+ return t.right < 0 || t.bottom < 0 || t.left > e || t.top > o;
122
+ }
123
+ /**
124
+ * Apply the configured `panelWidth` strategy to the panel element. Called
125
+ * from `position()` before measurement so the position-pair fit check
126
+ * sees the post-resize panel dimensions.
127
+ *
128
+ * For `'anchor'` and `'anchor-min'` the anchor's `offsetWidth` is used
129
+ * (not `getBoundingClientRect().width`) so transforms / zoom on ancestors
130
+ * don't skew the result.
131
+ */
132
+ applyPanelWidth(t, e) {
133
+ const o = this.options.panelWidth;
134
+ if (o != null) {
135
+ if (o === "anchor") {
136
+ t.style.width = `${e.offsetWidth}px`, t.style.minWidth = "";
137
+ return;
138
+ }
139
+ if (o === "anchor-min") {
140
+ t.style.minWidth = `${e.offsetWidth}px`, t.style.width = "";
141
+ return;
142
+ }
143
+ if (typeof o == "number") {
144
+ t.style.width = `${o}px`, t.style.minWidth = "";
145
+ return;
146
+ }
147
+ t.style.width = o, t.style.minWidth = "";
148
+ }
149
+ }
150
+ isRtl() {
151
+ return getComputedStyle(this.host).direction === "rtl";
152
+ }
153
+ /**
154
+ * Compute the (left, top) at which `panel` should be placed for a single
155
+ * position candidate. The candidate identifies which corner of the anchor
156
+ * to align which corner of the panel to, plus optional pixel offsets.
157
+ */
158
+ placeFor(t, e, o, i) {
159
+ const s = this.anchorXFor(t.originX, e, i), n = this.anchorYFor(t.originY, e), h = this.panelXOffsetFor(t.overlayX, o.width, i), a = this.panelYOffsetFor(t.overlayY, o.height);
160
+ return {
161
+ left: s + h + (t.offsetX ?? 0),
162
+ top: n + a + (t.offsetY ?? 0)
163
+ };
164
+ }
165
+ anchorXFor(t, e, o) {
166
+ const i = o ? e.right : e.left, s = o ? e.left : e.right;
167
+ return t === "start" ? i : t === "end" ? s : e.left + e.width / 2;
168
+ }
169
+ anchorYFor(t, e) {
170
+ return t === "top" ? e.top : t === "bottom" ? e.bottom : e.top + e.height / 2;
171
+ }
172
+ panelXOffsetFor(t, e, o) {
173
+ return t === "start" ? o ? -e : 0 : t === "end" ? o ? 0 : -e : -e / 2;
174
+ }
175
+ panelYOffsetFor(t, e) {
176
+ return t === "top" ? 0 : t === "bottom" ? -e : -e / 2;
177
+ }
178
+ fitsInViewport(t, e, o, i, s) {
179
+ return t.left >= s && t.top >= s && t.left + e.width <= o - s && t.top + e.height <= i - s;
180
+ }
181
+ clampToViewport(t, e, o, i, s) {
182
+ let { left: n, top: h } = t;
183
+ return n + e.width > o - s && (n = o - e.width - s), n < s && (n = s), h + e.height > i - s && (h = i - e.height - s), h < s && (h = s), { left: n, top: h };
184
+ }
185
+ /* ---- Scroll + resize tracking ---- */
186
+ currentStrategy() {
187
+ return this.options.scrollStrategy ?? "reposition";
188
+ }
189
+ /**
190
+ * Wire scroll + resize listeners according to the active strategy. Called
191
+ * from open(); paired with detachScrollListeners() in close().
192
+ *
193
+ * The capture-phase listener on document catches scroll events from any
194
+ * scrollable ancestor without us having to walk the DOM — scroll events
195
+ * don't bubble, but capture-phase listeners receive every dispatch.
196
+ */
197
+ attachScrollListeners() {
198
+ if (this.scrollListenersAttached) return;
199
+ this.scrollListenersAttached = !0;
200
+ const t = this.currentStrategy();
201
+ if (t !== "noop") {
202
+ if (window.addEventListener("resize", this.onResize, { passive: !0 }), t === "block") {
203
+ this.applyBlockScroll();
204
+ return;
205
+ }
206
+ document.addEventListener("scroll", this.onScroll, {
207
+ passive: !0,
208
+ capture: !0
209
+ });
210
+ }
211
+ }
212
+ detachScrollListeners() {
213
+ this.scrollListenersAttached && (this.scrollListenersAttached = !1, window.removeEventListener("resize", this.onResize), document.removeEventListener("scroll", this.onScroll, !0), this.releaseBlockScroll());
214
+ }
215
+ schedulePosition() {
216
+ this.positionFrame || (this.positionFrame = requestAnimationFrame(() => {
217
+ this.positionFrame = 0, this.position();
218
+ }));
219
+ }
220
+ /**
221
+ * 'block' strategy: lock the document scroll position while the overlay is
222
+ * open. Mirrors CDK's BlockScrollStrategy — sets position: fixed on the html
223
+ * element with the saved offset, then restores on close. Cheap; no event
224
+ * preventDefault dance required.
225
+ */
226
+ applyBlockScroll() {
227
+ if (this.blockedScroll) return;
228
+ const t = document.documentElement, e = t.scrollTop || window.scrollY, o = t.scrollLeft || window.scrollX, i = Math.max(0, window.innerWidth - t.clientWidth);
229
+ if (this.blockedScroll = { top: e, left: o }, i > 0) {
230
+ const s = document.body;
231
+ this.blockedBodyPaddingRight = s.style.paddingRight;
232
+ const n = parseFloat(getComputedStyle(s).paddingRight) || 0;
233
+ s.style.paddingRight = `${n + i}px`;
234
+ }
235
+ t.style.setProperty("--overlay-blocked-top", `-${e}px`), t.style.setProperty("--overlay-blocked-left", `-${o}px`), t.style.position = "fixed", t.style.top = `-${e}px`, t.style.left = `-${o}px`, t.style.width = "100%";
236
+ }
237
+ releaseBlockScroll() {
238
+ if (!this.blockedScroll) return;
239
+ const { top: t, left: e } = this.blockedScroll;
240
+ this.blockedScroll = null;
241
+ const o = document.documentElement;
242
+ o.style.position = "", o.style.top = "", o.style.left = "", o.style.width = "", o.style.removeProperty("--overlay-blocked-top"), o.style.removeProperty("--overlay-blocked-left"), this.blockedBodyPaddingRight !== null && (document.body.style.paddingRight = this.blockedBodyPaddingRight, this.blockedBodyPaddingRight = null), window.scrollTo(e, t);
243
+ }
244
+ /* ---- Esc-stack ---- */
245
+ releaseStackToken() {
246
+ this.stackToken && (r.releaseFrame(this.stackToken), this.stackToken = null);
247
+ }
248
+ isTopOfStack() {
249
+ return this.stackToken !== null && r.isFrameTop(this.stackToken);
250
+ }
251
+ attachMouseDown() {
252
+ this.mouseDownAttached || (document.addEventListener("mousedown", this.onMouseDown, !0), this.mouseDownAttached = !0);
253
+ }
254
+ detachMouseDown() {
255
+ this.mouseDownAttached && (document.removeEventListener("mousedown", this.onMouseDown, !0), this.mouseDownAttached = !1);
256
+ }
257
+ }
258
+ export {
259
+ r as OverlayController
260
+ };
@@ -0,0 +1,2 @@
1
+ export { OverlayController } from './overlay-controller';
2
+ export type { OverlayControllerOptions, OverlayPosition, OverlayOriginX, OverlayOriginY, PanelWidth, ScrollStrategy, } from './overlay-controller';
@@ -0,0 +1,205 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ export type OverlayOriginX = 'start' | 'center' | 'end';
3
+ export type OverlayOriginY = 'top' | 'center' | 'bottom';
4
+ export interface OverlayPosition {
5
+ /** Which X corner of the anchor to align from. */
6
+ originX: OverlayOriginX;
7
+ /** Which Y corner of the anchor to align from. */
8
+ originY: OverlayOriginY;
9
+ /** Which X corner of the overlay panel to align to. */
10
+ overlayX: OverlayOriginX;
11
+ /** Which Y corner of the overlay panel to align to. */
12
+ overlayY: OverlayOriginY;
13
+ /** Optional pixel offset, applied after corner alignment. */
14
+ offsetX?: number;
15
+ offsetY?: number;
16
+ }
17
+ export type ScrollStrategy = 'reposition' | 'block' | 'close' | 'noop';
18
+ export interface OverlayControllerOptions {
19
+ /**
20
+ * Element(s) the overlay positions itself against. Required. Pass an array
21
+ * when you want fallback anchors — the controller walks candidates in order
22
+ * and uses the first non-null one as the active anchor for positioning.
23
+ *
24
+ * This is intentionally distinct from `trigger`: in many UIs the natural
25
+ * **anchor** for an overlay is a wrapper (e.g. a Bootstrap `.input-group`
26
+ * containing an input + a button), but the **trigger** that opens the
27
+ * overlay is just the button. Conflating them caused the overlay to align
28
+ * to the wrong corner.
29
+ */
30
+ anchor: () => HTMLElement | HTMLElement[] | null;
31
+ /** Overlay panel element — the popup content that gets positioned. Required. */
32
+ panel: () => HTMLElement | null;
33
+ /**
34
+ * The interactive control that opens the overlay (typically a `<button>`).
35
+ * Used for keyboard focus-return when `close(returnFocus=true)` runs. When
36
+ * unset, focus returns to the active positioning anchor — appropriate when
37
+ * the anchor is itself focusable (e.g. a single trigger button). Set this
38
+ * explicitly when `anchor` is a non-focusable wrapper.
39
+ */
40
+ trigger?: () => HTMLElement | null;
41
+ /**
42
+ * Ordered list of position candidates. The first one that produces a
43
+ * panel rect fully inside the viewport (minus `viewportMargin`) is used.
44
+ * Default: drop below the anchor, flip above on overflow.
45
+ */
46
+ positions?: OverlayPosition[];
47
+ /** Pixel margin between the panel and the viewport edges. Default: 8. */
48
+ viewportMargin?: number;
49
+ /** Scroll behaviour while the panel is open. Default: 'reposition'. */
50
+ scrollStrategy?: ScrollStrategy;
51
+ /**
52
+ * When `true`, the panel stays pinned to the nearest viewport edge if the
53
+ * anchor scrolls completely out of viewport. Default: false (CDK parity).
54
+ */
55
+ stickyOnAnchorOffscreen?: boolean;
56
+ /**
57
+ * Panel width strategy. Recomputed on every position pass so resizes stay
58
+ * in sync. Default: `null` (panel uses its intrinsic content width).
59
+ *
60
+ * - `null` — leave the panel's CSS width alone
61
+ * - `'anchor'` — `width = anchor.offsetWidth` (exact match — the
62
+ * `sameDropdownWidth` pattern used by `bs-dropdown` consumers)
63
+ * - `'anchor-min'` — `minWidth = anchor.offsetWidth`, allow growth
64
+ * - `number` — fixed pixel width
65
+ * - `string` — any CSS width value (`'50vw'`, `'fit-content'`, …)
66
+ */
67
+ panelWidth?: PanelWidth;
68
+ onOpen?: () => void;
69
+ onClose?: () => void;
70
+ }
71
+ export type PanelWidth = null | 'anchor' | 'anchor-min' | number | string;
72
+ declare const DEFAULT_POSITIONS: OverlayPosition[];
73
+ /**
74
+ * Reusable popup-overlay primitive for Lit elements, modeled on Angular CDK's
75
+ * FlexibleConnectedPositionStrategy + scrollStrategies.reposition() but
76
+ * framework-agnostic (no @angular/cdk dependency).
77
+ *
78
+ * Features (built across M1–M5):
79
+ * - Position-pair selection: walks `positions` and uses the first candidate
80
+ * that produces a panel rect fully inside the viewport.
81
+ * - Scroll tracking: 'reposition' / 'block' / 'close' / 'noop' strategies.
82
+ * - Resize handling: window.resize re-runs positioning (rAF-batched).
83
+ * - Sticky-on-offscreen: optionally pins the panel to the nearest viewport
84
+ * edge when the anchor scrolls completely out of view.
85
+ * - Multi-anchor: trigger() may return an array; first non-null wins.
86
+ * - Esc-stack: shared LIFO stack so nested overlays unwind one at a time.
87
+ *
88
+ * In M0, ships with: type definitions, single-anchor `trigger()`, static
89
+ * positioning (no scroll tracking), Esc-stack, outside-click close, focus
90
+ * return on close. M1+ build out behaviour.
91
+ */
92
+ export declare class OverlayController implements ReactiveController {
93
+ private static readonly openStack;
94
+ /**
95
+ * Allocate a frame on top of the shared overlay stack. Use this from code
96
+ * paths that don't own a full `OverlayController` instance. Pair every
97
+ * `pushFrame()` with a `releaseFrame(token)`.
98
+ */
99
+ static pushFrame(): symbol;
100
+ static releaseFrame(token: symbol): void;
101
+ static isFrameTop(token: symbol): boolean;
102
+ private readonly host;
103
+ private readonly options;
104
+ private _open;
105
+ private mouseDownAttached;
106
+ private stackToken;
107
+ /** Anchor used by the last positioning pass. Drives focus-return on close. */
108
+ private activeAnchor;
109
+ /** rAF id for the next scheduled position() call. 0 = none scheduled. */
110
+ private positionFrame;
111
+ /** True while scroll-tracking listeners are attached. */
112
+ private scrollListenersAttached;
113
+ /** Saved scrollTop/scrollLeft when 'block' strategy is active. */
114
+ private blockedScroll;
115
+ /** Inline `padding-right` we wrote on <body> to compensate for the
116
+ * disappearing scrollbar — captured so release() can restore exactly. */
117
+ private blockedBodyPaddingRight;
118
+ constructor(host: ReactiveControllerHost & HTMLElement, options: OverlayControllerOptions);
119
+ hostConnected(): void;
120
+ hostDisconnected(): void;
121
+ get isOpen(): boolean;
122
+ open(): Promise<void>;
123
+ close(returnFocus?: boolean): void;
124
+ toggle(): Promise<void>;
125
+ /**
126
+ * Resolve the list of candidate anchors from `anchor()`. Single-element
127
+ * returns become a one-item array; null returns become an empty array.
128
+ * Nulls inside arrays are filtered out.
129
+ */
130
+ protected resolveAnchors(): HTMLElement[];
131
+ /**
132
+ * Resolve the *active* anchor — the one used in the most recent positioning
133
+ * pass, or the first available one if none has been picked yet.
134
+ */
135
+ protected resolveAnchor(): HTMLElement | null;
136
+ /**
137
+ * Walk the configured `positions` and pick the first candidate whose panel
138
+ * rect fully fits inside the viewport (minus `viewportMargin`). If none fit,
139
+ * the last candidate is applied and clamped to viewport edges (push behaviour).
140
+ *
141
+ * `start`/`end` are direction-aware: in RTL contexts they swap to match
142
+ * visual layout.
143
+ *
144
+ * Sticky-offscreen behaviour: when `stickyOnAnchorOffscreen` is true and the
145
+ * anchor's bounding rect is entirely outside the viewport, the panel is
146
+ * pinned to its last in-viewport position (clamped to viewport edges) rather
147
+ * than disappearing with the anchor. Normal positioning resumes when the
148
+ * anchor re-enters the viewport.
149
+ */
150
+ position(): void;
151
+ /** True when the anchor's bounding rect lies entirely outside the viewport. */
152
+ private isAnchorOffscreen;
153
+ /**
154
+ * Apply the configured `panelWidth` strategy to the panel element. Called
155
+ * from `position()` before measurement so the position-pair fit check
156
+ * sees the post-resize panel dimensions.
157
+ *
158
+ * For `'anchor'` and `'anchor-min'` the anchor's `offsetWidth` is used
159
+ * (not `getBoundingClientRect().width`) so transforms / zoom on ancestors
160
+ * don't skew the result.
161
+ */
162
+ private applyPanelWidth;
163
+ private isRtl;
164
+ /**
165
+ * Compute the (left, top) at which `panel` should be placed for a single
166
+ * position candidate. The candidate identifies which corner of the anchor
167
+ * to align which corner of the panel to, plus optional pixel offsets.
168
+ */
169
+ private placeFor;
170
+ private anchorXFor;
171
+ private anchorYFor;
172
+ private panelXOffsetFor;
173
+ private panelYOffsetFor;
174
+ private fitsInViewport;
175
+ private clampToViewport;
176
+ private currentStrategy;
177
+ /**
178
+ * Wire scroll + resize listeners according to the active strategy. Called
179
+ * from open(); paired with detachScrollListeners() in close().
180
+ *
181
+ * The capture-phase listener on document catches scroll events from any
182
+ * scrollable ancestor without us having to walk the DOM — scroll events
183
+ * don't bubble, but capture-phase listeners receive every dispatch.
184
+ */
185
+ private attachScrollListeners;
186
+ private detachScrollListeners;
187
+ private onScroll;
188
+ private onResize;
189
+ private schedulePosition;
190
+ /**
191
+ * 'block' strategy: lock the document scroll position while the overlay is
192
+ * open. Mirrors CDK's BlockScrollStrategy — sets position: fixed on the html
193
+ * element with the saved offset, then restores on close. Cheap; no event
194
+ * preventDefault dance required.
195
+ */
196
+ private applyBlockScroll;
197
+ private releaseBlockScroll;
198
+ private releaseStackToken;
199
+ private isTopOfStack;
200
+ private attachMouseDown;
201
+ private detachMouseDown;
202
+ private onKeyDown;
203
+ private onMouseDown;
204
+ }
205
+ export { DEFAULT_POSITIONS };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/web-components",
3
- "version": "1.0.0",
3
+ "version": "1.1.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": {
@@ -0,0 +1,5 @@
1
+ import { M as o, b as n } from "../chunks/mp-pagination-BGxsawFL.mjs";
2
+ export {
3
+ o as MpPagination,
4
+ n as buildPaginationLayout
5
+ };
@@ -0,0 +1,2 @@
1
+ export { MpPagination, buildPaginationLayout } from './mp-pagination';
2
+ export type { PageChangeEventDetail, PaginationSize, PaginationItem, PaginationLayout, } from './mp-pagination';
@@ -0,0 +1,95 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ export type PaginationSize = 'small' | 'medium' | 'large';
3
+ /** A rendered slot in the pagination list — either a page button or an ellipsis gap. */
4
+ export type PaginationItem = {
5
+ kind: 'page';
6
+ page: number;
7
+ current: boolean;
8
+ } | {
9
+ kind: 'gap';
10
+ };
11
+ /**
12
+ * Full layout produced by `buildPaginationLayout`: which arrow buttons fit
13
+ * the budget, plus the ordered page / gap items between them.
14
+ */
15
+ export interface PaginationLayout {
16
+ showPrev: boolean;
17
+ showNext: boolean;
18
+ items: PaginationItem[];
19
+ }
20
+ export interface PageChangeEventDetail {
21
+ page: number;
22
+ }
23
+ /**
24
+ * `<mp-pagination>` — page selector with first/last anchors, ellipsis gaps,
25
+ * and previous/next arrows. The visible budget is fully driven by the
26
+ * `numberOfBoxes` input (0 = uncapped). Layout-time auto-fit was tried
27
+ * earlier but produced a feedback loop with flex parents whose item width
28
+ * resolves from their content's `max-content` — the consumer is responsible
29
+ * for picking a cap that fits the host on their target viewports.
30
+ */
31
+ export declare class MpPagination extends LitElement {
32
+ static styles: import('lit').CSSResult[];
33
+ static get observedAttributes(): string[];
34
+ private _pageNumbers;
35
+ private _selectedPageNumber;
36
+ private _numberOfBoxes;
37
+ private _showArrows;
38
+ private _size;
39
+ private _ariaLabel;
40
+ get pageNumbers(): number[];
41
+ set pageNumbers(value: number[] | ReadonlyArray<number>);
42
+ get selectedPageNumber(): number;
43
+ set selectedPageNumber(value: number);
44
+ get numberOfBoxes(): number;
45
+ set numberOfBoxes(value: number);
46
+ get showArrows(): boolean;
47
+ set showArrows(value: boolean);
48
+ get size(): PaginationSize;
49
+ set size(value: PaginationSize);
50
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
51
+ /**
52
+ * Effective TOTAL budget (boxes including arrows). When `numberOfBoxes`
53
+ * is `0` the budget is uncapped and all pages render; otherwise the cap
54
+ * is honoured verbatim. (An earlier ResizeObserver-driven "auto-fit"
55
+ * was removed — its measurement of self-width fed back into the rendered
56
+ * content and the WC + flex parent could oscillate or lock the budget
57
+ * to a single button.)
58
+ */
59
+ private effectiveBudget;
60
+ /** Build the full layout — arrows + page items. Pure — no DOM access. */
61
+ protected computeLayout(): PaginationLayout;
62
+ render(): TemplateResult;
63
+ private isFirstPage;
64
+ private isLastPage;
65
+ private selectPage;
66
+ private onPrevious;
67
+ private onNext;
68
+ }
69
+ /**
70
+ * Pure helper: deterministic layout for `(pages, current, totalBudget, showArrows)`.
71
+ *
72
+ * `totalBudget` is the maximum visible boxes — pages AND arrows count toward it.
73
+ * The current page is always slot #1; subsequent slots are allocated by
74
+ * stepping through a fixed priority sequence:
75
+ *
76
+ * 1. Arrows (next, then prev) when `showArrows`.
77
+ * 2. **Phase 1** — round-robin `[start, end, before, after]`:
78
+ * - start: page #1
79
+ * - end: last page
80
+ * - before: left ellipsis
81
+ * - after: right ellipsis
82
+ * 3. **Phase 2+** — round-robin `[before, after, start, end]`, repeated
83
+ * until budget runs out. Each pass adds one page in that direction:
84
+ * - before extends C-1, C-2, …
85
+ * - after extends C+1, C+2, …
86
+ * - start extends 2, 3, …
87
+ * - end extends last-1, last-2, …
88
+ *
89
+ * When a direction has no more pages to add (overlap with another direction,
90
+ * or current at an extreme), that step is skipped and the cycle continues
91
+ * with the next action.
92
+ *
93
+ * See `docs/issue_329_PRD.md` § "Growth algorithm".
94
+ */
95
+ export declare function buildPaginationLayout(pages: ReadonlyArray<number>, current: number, totalBudget: number, showArrows: boolean): PaginationLayout;
@@ -0,0 +1,2 @@
1
+ export { MpPagination, buildPaginationLayout } from './components';
2
+ export type { PageChangeEventDetail, PaginationSize, PaginationItem, PaginationLayout, } from './components';
@@ -0,0 +1 @@
1
+ export { paginationStyles } from './pagination.styles';
@@ -0,0 +1,2 @@
1
+ export declare const paginationStyles: import('lit').CSSResult;
2
+ export default paginationStyles;