sit-onyx 1.1.0-dev-20250930114848 → 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.
@@ -49,9 +49,9 @@ declare const __VLS_component: import('vue').DefineComponent<OnyxBasicPopoverPro
49
49
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
50
50
  }>, {
51
51
  role: "menu" | "listbox" | "tree" | "grid" | "dialog";
52
+ sticky: boolean;
52
53
  alignment: import('../../composables/useOpenAlignment.js', { with: { "resolution-mode": "import" } }).OpenAlignment | "auto";
53
54
  position: import('../../composables/useAnchorPositionPolyfill.js', { with: { "resolution-mode": "import" } }).AnchorPosition | "auto";
54
- clipping: boolean;
55
55
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
56
56
  popoverWrapper: HTMLDivElement;
57
57
  popover: HTMLDivElement;
@@ -35,5 +35,5 @@ export type OnyxBasicPopoverProps = {
35
35
  */
36
36
  role?: "menu" | "listbox" | "tree" | "grid" | "dialog";
37
37
  /** If true, the popover remains visible within the viewport even if its parent element scrolls out of view. */
38
- clipping?: boolean;
38
+ sticky?: boolean;
39
39
  };
@@ -57,8 +57,8 @@ declare const __VLS_component: import('vue').DefineComponent<OnyxDialogProps, {}
57
57
  }, string, import('vue').PublicProps, Readonly<OnyxDialogProps> & Readonly<{
58
58
  "onUpdate:open"?: ((open: boolean) => any) | undefined;
59
59
  }>, {
60
+ sticky: boolean;
60
61
  open: boolean | null;
61
- clipping: boolean;
62
62
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
63
63
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
64
64
  export default _default;
@@ -1,16 +1,16 @@
1
1
  import { CSSProperties, Ref } from 'vue';
2
2
  import { AnchorPosition } from './useAnchorPositionPolyfill.js';
3
3
  import { OpenDirection } from './useOpenDirection.js';
4
- export type UseClippingOptions = {
4
+ export type UseStickyOptions = {
5
5
  popoverRef: Ref<HTMLElement | null>;
6
6
  popoverWrapperRef: Ref<HTMLElement | null>;
7
7
  popoverPosition: Ref<AnchorPosition | OpenDirection>;
8
8
  isVisible: Ref<boolean>;
9
- clipping: Ref<boolean>;
9
+ sticky: Ref<boolean>;
10
10
  };
11
- export declare function useClipping(options: UseClippingOptions): {
12
- clippingStyles: Ref<CSSProperties | undefined, CSSProperties | undefined>;
11
+ export declare function useSticky(options: UseStickyOptions): {
12
+ stickyStyles: Ref<CSSProperties | undefined, CSSProperties | undefined>;
13
13
  scrolledOut: Ref<OpenDirection | undefined, OpenDirection | undefined>;
14
- isClipping: Ref<boolean, boolean>;
14
+ isSticky: Ref<boolean, boolean>;
15
15
  checkVisibilityOnScroll: () => void;
16
16
  };
@@ -2296,82 +2296,6 @@ const useAnchorPositionPolyfill = ({
2296
2296
  useragentSupportsAnchorApi
2297
2297
  };
2298
2298
  };
2299
- function useClipping(options) {
2300
- const clippingStyles = ref();
2301
- const scrolledOut = ref();
2302
- const isClipping = ref(false);
2303
- const checkVisibilityOnScroll = () => {
2304
- const MIN_DISTANCE_TO_BORDER = 16;
2305
- const MARGIN = 8;
2306
- if (!options.popoverRef.value || !options.popoverWrapperRef.value || !options.isVisible.value)
2307
- return;
2308
- if (isClipping.value) {
2309
- const popoverRect = options.popoverRef.value.getBoundingClientRect();
2310
- const wrapperRect = options.popoverWrapperRef.value.getBoundingClientRect();
2311
- const requiredHeight = popoverRect.height + MIN_DISTANCE_TO_BORDER + MARGIN;
2312
- if (options.popoverPosition.value.includes("top")) {
2313
- if (scrolledOut.value === "top" && wrapperRect.top > requiredHeight) {
2314
- isClipping.value = false;
2315
- return;
2316
- }
2317
- if (scrolledOut.value === "bottom" && wrapperRect.top + MARGIN < window.innerHeight) {
2318
- isClipping.value = false;
2319
- return;
2320
- }
2321
- } else if (options.popoverPosition.value.includes("bottom")) {
2322
- if (scrolledOut.value === "top" && wrapperRect.bottom > MARGIN) {
2323
- isClipping.value = false;
2324
- return;
2325
- }
2326
- if (scrolledOut.value === "bottom" && window.innerHeight - wrapperRect.bottom > requiredHeight) {
2327
- isClipping.value = false;
2328
- return;
2329
- }
2330
- } else {
2331
- if (scrolledOut.value === "top" && wrapperRect.top + MIN_DISTANCE_TO_BORDER > popoverRect.height) {
2332
- isClipping.value = false;
2333
- return;
2334
- }
2335
- if (scrolledOut.value === "bottom" && wrapperRect.bottom + MIN_DISTANCE_TO_BORDER < window.innerHeight) {
2336
- isClipping.value = false;
2337
- return;
2338
- }
2339
- }
2340
- } else {
2341
- const rect = options.popoverRef.value.getBoundingClientRect();
2342
- const isTooHigh = rect.top < MIN_DISTANCE_TO_BORDER;
2343
- const isTooLow = rect.bottom > window.innerHeight - MIN_DISTANCE_TO_BORDER;
2344
- if (isTooHigh || isTooLow) {
2345
- isClipping.value = true;
2346
- if (isTooHigh) {
2347
- scrolledOut.value = "top";
2348
- clippingStyles.value = { left: rect.left + "px", top: "var(--onyx-density-md)" };
2349
- } else if (isTooLow) {
2350
- scrolledOut.value = "bottom";
2351
- clippingStyles.value = { left: rect.left + "px", bottom: "var(--onyx-density-md)" };
2352
- }
2353
- }
2354
- }
2355
- };
2356
- const disableClipping = computed(() => {
2357
- return !options.clipping.value || !options.isVisible.value;
2358
- });
2359
- useGlobalEventListener({
2360
- type: "scroll",
2361
- listener: () => checkVisibilityOnScroll(),
2362
- disabled: disableClipping
2363
- });
2364
- useGlobalEventListener({
2365
- type: "resize",
2366
- listener: () => checkVisibilityOnScroll(),
2367
- disabled: disableClipping
2368
- });
2369
- onMounted(async () => {
2370
- await nextTick();
2371
- if (!disableClipping.value) checkVisibilityOnScroll();
2372
- });
2373
- return { clippingStyles, scrolledOut, isClipping, checkVisibilityOnScroll };
2374
- }
2375
2299
  const useOpenAlignment = (element, tooltipElement, defaultPosition = "center") => {
2376
2300
  const minMargin = 16;
2377
2301
  const openAlignment = ref(defaultPosition);
@@ -2451,6 +2375,82 @@ const findParentWithHiddenOverflow = (element) => {
2451
2375
  }
2452
2376
  return element.parentElement ? findParentWithHiddenOverflow(element.parentElement) : void 0;
2453
2377
  };
2378
+ function useSticky(options) {
2379
+ const stickyStyles = ref();
2380
+ const scrolledOut = ref();
2381
+ const isSticky = ref(false);
2382
+ const checkVisibilityOnScroll = () => {
2383
+ const MIN_DISTANCE_TO_BORDER = 16;
2384
+ const MARGIN = 8;
2385
+ if (!options.popoverRef.value || !options.popoverWrapperRef.value || !options.isVisible.value)
2386
+ return;
2387
+ if (isSticky.value) {
2388
+ const popoverRect = options.popoverRef.value.getBoundingClientRect();
2389
+ const wrapperRect = options.popoverWrapperRef.value.getBoundingClientRect();
2390
+ const requiredHeight = popoverRect.height + MIN_DISTANCE_TO_BORDER + MARGIN;
2391
+ if (options.popoverPosition.value.includes("top")) {
2392
+ if (scrolledOut.value === "top" && wrapperRect.top > requiredHeight) {
2393
+ isSticky.value = false;
2394
+ return;
2395
+ }
2396
+ if (scrolledOut.value === "bottom" && wrapperRect.top + MARGIN < window.innerHeight) {
2397
+ isSticky.value = false;
2398
+ return;
2399
+ }
2400
+ } else if (options.popoverPosition.value.includes("bottom")) {
2401
+ if (scrolledOut.value === "top" && wrapperRect.bottom > MARGIN) {
2402
+ isSticky.value = false;
2403
+ return;
2404
+ }
2405
+ if (scrolledOut.value === "bottom" && window.innerHeight - wrapperRect.bottom > requiredHeight) {
2406
+ isSticky.value = false;
2407
+ return;
2408
+ }
2409
+ } else {
2410
+ if (scrolledOut.value === "top" && wrapperRect.top + MIN_DISTANCE_TO_BORDER > popoverRect.height) {
2411
+ isSticky.value = false;
2412
+ return;
2413
+ }
2414
+ if (scrolledOut.value === "bottom" && wrapperRect.bottom + MIN_DISTANCE_TO_BORDER < window.innerHeight) {
2415
+ isSticky.value = false;
2416
+ return;
2417
+ }
2418
+ }
2419
+ } else {
2420
+ const rect = options.popoverRef.value.getBoundingClientRect();
2421
+ const isTooHigh = rect.top < MIN_DISTANCE_TO_BORDER;
2422
+ const isTooLow = rect.bottom > window.innerHeight - MIN_DISTANCE_TO_BORDER;
2423
+ if (isTooHigh || isTooLow) {
2424
+ isSticky.value = true;
2425
+ if (isTooHigh) {
2426
+ scrolledOut.value = "top";
2427
+ stickyStyles.value = { left: rect.left + "px", top: "var(--onyx-density-md)" };
2428
+ } else if (isTooLow) {
2429
+ scrolledOut.value = "bottom";
2430
+ stickyStyles.value = { left: rect.left + "px", bottom: "var(--onyx-density-md)" };
2431
+ }
2432
+ }
2433
+ }
2434
+ };
2435
+ const disableSticky = computed(() => {
2436
+ return !options.sticky.value || !options.isVisible.value;
2437
+ });
2438
+ useGlobalEventListener({
2439
+ type: "scroll",
2440
+ listener: () => checkVisibilityOnScroll(),
2441
+ disabled: disableSticky
2442
+ });
2443
+ useGlobalEventListener({
2444
+ type: "resize",
2445
+ listener: () => checkVisibilityOnScroll(),
2446
+ disabled: disableSticky
2447
+ });
2448
+ onMounted(async () => {
2449
+ await nextTick();
2450
+ if (!disableSticky.value) checkVisibilityOnScroll();
2451
+ });
2452
+ return { stickyStyles, scrolledOut, isSticky, checkVisibilityOnScroll };
2453
+ }
2454
2454
  const _sfc_main$1s = /* @__PURE__ */ defineComponent({
2455
2455
  __name: "OnyxBasicPopover",
2456
2456
  props: {
@@ -2461,7 +2461,7 @@ const _sfc_main$1s = /* @__PURE__ */ defineComponent({
2461
2461
  fitParent: { type: Boolean, required: false },
2462
2462
  disabled: { type: Boolean, required: false },
2463
2463
  role: { type: String, required: false, default: "dialog" },
2464
- clipping: { type: Boolean, required: false, default: false }
2464
+ sticky: { type: Boolean, required: false, default: false }
2465
2465
  },
2466
2466
  emits: ["update:open"],
2467
2467
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -2532,12 +2532,12 @@ const _sfc_main$1s = /* @__PURE__ */ defineComponent({
2532
2532
  updateOpenDirection();
2533
2533
  updateOpenAlignment();
2534
2534
  };
2535
- const { clippingStyles, isClipping } = useClipping({
2535
+ const { stickyStyles, isSticky } = useSticky({
2536
2536
  popoverRef,
2537
2537
  popoverWrapperRef,
2538
2538
  popoverPosition,
2539
2539
  isVisible,
2540
- clipping: computed(() => props.clipping)
2540
+ sticky: toRef(() => props.sticky)
2541
2541
  });
2542
2542
  useGlobalEventListener({
2543
2543
  type: "resize",
@@ -2573,7 +2573,7 @@ const _sfc_main$1s = /* @__PURE__ */ defineComponent({
2573
2573
  [`onyx-basic-popover__dialog--alignment-${popoverAlignment.value}`]: true,
2574
2574
  "onyx-basic-popover__dialog--fitparent": props.fitParent,
2575
2575
  "onyx-basic-popover__dialog--disabled": disabled.value,
2576
- "onyx-basic-popover__dialog--clipping": isClipping.value,
2576
+ "onyx-basic-popover__dialog--sticky": isSticky.value,
2577
2577
  "onyx-basic-popover__dialog--dont-support-anchor": !useragentSupportsAnchorApi.value
2578
2578
  };
2579
2579
  });
@@ -2604,7 +2604,7 @@ const _sfc_main$1s = /* @__PURE__ */ defineComponent({
2604
2604
  top: topPosition.value
2605
2605
  };
2606
2606
  });
2607
- const __returned__ = { props, emit, _isVisible, isVisible, popoverPosition, popoverAlignment, disabled, positionAndAlignment, popoverRef, popoverWrapperRef, openDirection, updateOpenDirection, openAlignment, updateOpenAlignment, leftPosition, topPosition, updateAnchorPositionPolyfill, useragentSupportsAnchorApi, width, handleOpening, updateDirections, clippingStyles, isClipping, toggle, trigger, id, anchorName, popoverClasses, popoverStyles };
2607
+ const __returned__ = { props, emit, _isVisible, isVisible, popoverPosition, popoverAlignment, disabled, positionAndAlignment, popoverRef, popoverWrapperRef, openDirection, updateOpenDirection, openAlignment, updateOpenAlignment, leftPosition, topPosition, updateAnchorPositionPolyfill, useragentSupportsAnchorApi, width, handleOpening, updateDirections, stickyStyles, isSticky, toggle, trigger, id, anchorName, popoverClasses, popoverStyles };
2608
2608
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2609
2609
  return __returned__;
2610
2610
  }
@@ -2626,7 +2626,7 @@ function _sfc_render$1s(_ctx, _cache, $props, $setup, $data, $options) {
2626
2626
  "aria-label": $setup.props.label,
2627
2627
  popover: "manual",
2628
2628
  class: normalizeClass(["onyx-basic-popover__dialog", $setup.popoverClasses]),
2629
- style: normalizeStyle(!$setup.isClipping ? $setup.popoverStyles : $setup.clippingStyles)
2629
+ style: normalizeStyle(!$setup.isSticky ? $setup.popoverStyles : $setup.stickyStyles)
2630
2630
  }, [
2631
2631
  renderSlot(_ctx.$slots, "content")
2632
2632
  ], 14, _hoisted_1$11)
@@ -8983,7 +8983,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
8983
8983
  position: { type: String, required: false },
8984
8984
  alignment: { type: String, required: false },
8985
8985
  disabled: { type: Boolean, required: false },
8986
- clipping: { type: Boolean, required: false, default: true },
8986
+ sticky: { type: Boolean, required: false, default: true },
8987
8987
  nonDismissible: { type: Boolean, required: false }
8988
8988
  },
8989
8989
  emits: ["update:open"],