@stackone/malachite 2.23.3 → 2.24.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/malachite",
3
- "version": "2.23.3",
3
+ "version": "2.24.0",
4
4
  "description": "StackOne's themeable React component library — Shadow DOM isolated, scoped Tailwind, theme-token driven.",
5
5
  "license": "MIT",
6
6
  "author": "StackOne",
@@ -1,38 +0,0 @@
1
- const T = 8;
2
- const D = /* @__PURE__ */ new Set(["small", "medium"]), G = (P, t = !1) => D.has(P) && !t, e = ({
3
- triggerRect: P,
4
- panelWidth: t,
5
- panelHeight: o,
6
- size: I,
7
- fullWidth: L = !1,
8
- viewportWidth: A,
9
- viewportHeight: a
10
- }) => {
11
- const s = A - 16;
12
- let E, _;
13
- if (G(I, L)) {
14
- _ = Math.min(t || 180, s);
15
- const n = A - _ - 8;
16
- E = Math.max(8, Math.min(P.right - _, n));
17
- } else {
18
- _ = Math.min(P.width, s);
19
- const n = A - _ - 8;
20
- E = Math.max(8, Math.min(P.left, n));
21
- }
22
- const m = a - P.bottom, N = o > 0 && m < o + 8;
23
- return {
24
- top: N ? P.top - o - 8 : P.bottom + 8,
25
- left: E,
26
- width: _,
27
- openUp: N
28
- };
29
- }, l = (P, t, o) => P.bottom < 0 || P.top > o || P.right < 0 || P.left > t, X = (P) => `${P.top},${P.left},${P.width},${P.height}`;
30
- export {
31
- D as CONTENT_SIZED_PANEL,
32
- T as PANEL_VIEWPORT_PADDING_PX,
33
- e as computePanelGeometry,
34
- G as isContentSizedPanel,
35
- l as isTriggerOffscreen,
36
- X as rectSignature
37
- };
38
- //# sourceMappingURL=dropdownPanelPosition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dropdownPanelPosition.js","sources":["../../src/components/dropdownPanelPosition.ts"],"sourcesContent":["import type { DropdownSize } from './Dropdown';\n\nconst PANEL_TRIGGER_GAP_PX = 8;\nexport const PANEL_VIEWPORT_PADDING_PX = 8;\n\n/** Before layout `offsetWidth` is 0, so the first pass needs a width to work from. */\nconst PANEL_FALLBACK_WIDTH_PX = 180;\n\n/** The smaller triggers are chips: their panel sizes to its content and right-aligns. */\nexport const CONTENT_SIZED_PANEL: ReadonlySet<DropdownSize> = new Set(['small', 'medium']);\n\nexport const isContentSizedPanel = (size: DropdownSize, fullWidth = false): boolean =>\n CONTENT_SIZED_PANEL.has(size) && !fullWidth;\n\nexport interface PanelGeometry {\n top: number;\n left: number;\n width: number;\n openUp: boolean;\n}\n\nexport interface PanelGeometryInput {\n triggerRect: Pick<DOMRect, 'top' | 'left' | 'right' | 'bottom' | 'width'>;\n panelWidth: number;\n panelHeight: number;\n size: DropdownSize;\n fullWidth?: boolean;\n viewportWidth: number;\n viewportHeight: number;\n}\n\nexport const computePanelGeometry = ({\n triggerRect,\n panelWidth,\n panelHeight,\n size,\n fullWidth = false,\n viewportWidth,\n viewportHeight,\n}: PanelGeometryInput): PanelGeometry => {\n const maxViewportWidth = viewportWidth - PANEL_VIEWPORT_PADDING_PX * 2;\n\n let left: number;\n let width: number;\n if (isContentSizedPanel(size, fullWidth)) {\n width = Math.min(panelWidth || PANEL_FALLBACK_WIDTH_PX, maxViewportWidth);\n const maxLeft = viewportWidth - width - PANEL_VIEWPORT_PADDING_PX;\n left = Math.max(PANEL_VIEWPORT_PADDING_PX, Math.min(triggerRect.right - width, maxLeft));\n } else {\n width = Math.min(triggerRect.width, maxViewportWidth);\n const maxLeft = viewportWidth - width - PANEL_VIEWPORT_PADDING_PX;\n left = Math.max(PANEL_VIEWPORT_PADDING_PX, Math.min(triggerRect.left, maxLeft));\n }\n\n const spaceBelow = viewportHeight - triggerRect.bottom;\n const openUp = panelHeight > 0 && spaceBelow < panelHeight + PANEL_VIEWPORT_PADDING_PX;\n\n return {\n top: openUp\n ? triggerRect.top - panelHeight - PANEL_TRIGGER_GAP_PX\n : triggerRect.bottom + PANEL_TRIGGER_GAP_PX,\n left,\n width,\n openUp,\n };\n};\n\n/** A panel anchored to a trigger nobody can see is floating over unrelated content. */\nexport const isTriggerOffscreen = (\n rect: Pick<DOMRect, 'top' | 'left' | 'right' | 'bottom'>,\n viewportWidth: number,\n viewportHeight: number,\n): boolean =>\n rect.bottom < 0 || rect.top > viewportHeight || rect.right < 0 || rect.left > viewportWidth;\n\n/** Cheap equality for the frame loop: reposition only when the trigger has actually moved. */\nexport const rectSignature = (\n rect: Pick<DOMRect, 'top' | 'left' | 'width' | 'height'>,\n): string => `${rect.top},${rect.left},${rect.width},${rect.height}`;\n"],"names":["PANEL_VIEWPORT_PADDING_PX","CONTENT_SIZED_PANEL","isContentSizedPanel","size","fullWidth","computePanelGeometry","triggerRect","panelWidth","panelHeight","viewportWidth","viewportHeight","maxViewportWidth","left","width","maxLeft","spaceBelow","openUp","isTriggerOffscreen","rect","rectSignature"],"mappings":"AAGO,MAAMA,IAA4B;AAMlC,MAAMC,IAAiD,oBAAI,IAAI,CAAC,SAAS,QAAQ,CAAC,GAE5EC,IAAsB,CAACC,GAAoBC,IAAY,OAChEH,EAAoB,IAAIE,CAAI,KAAK,CAACC,GAmBzBC,IAAuB,CAAC;AAAA,EACjC,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAL;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,eAAAK;AAAA,EACA,gBAAAC;AACJ,MAAyC;AACrC,QAAMC,IAAmBF,IAAgB;AAEzC,MAAIG,GACAC;AACJ,MAAIX,EAAoBC,GAAMC,CAAS,GAAG;AACtC,IAAAS,IAAQ,KAAK,IAAIN,KAAc,KAAyBI,CAAgB;AACxE,UAAMG,IAAUL,IAAgBI,IAAQ;AACxC,IAAAD,IAAO,KAAK,IAAI,GAA2B,KAAK,IAAIN,EAAY,QAAQO,GAAOC,CAAO,CAAC;AAAA,EAC3F,OAAO;AACH,IAAAD,IAAQ,KAAK,IAAIP,EAAY,OAAOK,CAAgB;AACpD,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