sit-onyx 1.0.0-beta.263 → 1.0.0-beta.265

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.
@@ -13,13 +13,17 @@ declare function __VLS_template(): {
13
13
  */
14
14
  default(): unknown;
15
15
  };
16
- refs: {};
16
+ refs: {
17
+ buttonRef: HTMLButtonElement;
18
+ };
17
19
  rootEl: any;
18
20
  };
19
21
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
20
22
  declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
21
23
  type: import('./types.js', { with: { "resolution-mode": "import" } }).ButtonType;
22
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
24
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
25
+ buttonRef: HTMLButtonElement;
26
+ }, any>;
23
27
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
24
28
  export default _default;
25
29
  type __VLS_WithTemplateSlots<T, S> = T & {
@@ -30,6 +30,7 @@ declare const __VLS_component: import('vue').DefineComponent<OnyxDialogProps, {}
30
30
  alert: boolean;
31
31
  open: boolean;
32
32
  modal: boolean;
33
+ disableClosingOnBackdropClick: boolean;
33
34
  alignment: import('./types.js', { with: { "resolution-mode": "import" } }).DialogAlignment;
34
35
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
35
36
  dialogRef: HTMLDialogElement;
@@ -14,6 +14,10 @@ export type OnyxDialogProps = DensityProp & {
14
14
  * Also the `close` event is emitted when pressing "Escape".
15
15
  */
16
16
  modal?: boolean;
17
+ /**
18
+ * Whether to prevent closing the dialog when clicking outside of it.
19
+ */
20
+ disableClosingOnBackdropClick?: boolean;
17
21
  /**
18
22
  * Whether the dialog is an [alert dialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/).
19
23
  * Should be set for better accessibility / screen reader support when the dialog
@@ -0,0 +1,13 @@
1
+ import { Nullable } from '../../types/index.js';
2
+ import { OnyxFabButtonProps } from '../OnyxFabButton/types.js';
3
+ export type OnyxFabProps = OnyxFabButtonProps & {
4
+ /**
5
+ * How to align the component relative to the viewport.
6
+ */
7
+ alignment?: "left" | "right";
8
+ /**
9
+ * Whether the element is expanded or collapsed.
10
+ * If unset, the open state is manged internally.
11
+ */
12
+ open?: Nullable<boolean>;
13
+ };
@@ -0,0 +1,17 @@
1
+ import { DensityProp } from '../../composables/density.js';
2
+ import { WithLinkProp } from '../OnyxRouterLink/types.js';
3
+ export type OnyxFabButtonProps = DensityProp & WithLinkProp & {
4
+ /**
5
+ * (Aria) Label of the action button that describes the action.
6
+ */
7
+ label: string;
8
+ /**
9
+ * If `true`, the label will be visually hidden.
10
+ * For accessibility / screen readers, the aria-label will still be set.
11
+ */
12
+ hideLabel?: boolean;
13
+ /**
14
+ * Icon to show in the action button.
15
+ */
16
+ icon?: string;
17
+ };
@@ -0,0 +1,17 @@
1
+ import { DensityProp } from '../../composables/density.js';
2
+ import { WithLinkProp } from '../OnyxRouterLink/types.js';
3
+ export type OnyxFabItemProps = DensityProp & WithLinkProp & {
4
+ /**
5
+ * Text label to show
6
+ */
7
+ label: string;
8
+ /**
9
+ * If `true`, the label will be visually hidden.
10
+ * For accessibility / screen readers, the aria-label will still be set.
11
+ */
12
+ hideLabel?: boolean;
13
+ /**
14
+ * Optional icon to show.
15
+ */
16
+ icon?: string;
17
+ };
@@ -83,6 +83,8 @@ declare function __VLS_template(): {
83
83
  };
84
84
  $refs: {
85
85
  [x: string]: unknown;
86
+ } & {
87
+ buttonRef: HTMLButtonElement;
86
88
  };
87
89
  $slots: Readonly<{
88
90
  [name: string]: import('vue').Slot<any> | undefined;
@@ -258,6 +260,8 @@ declare const __VLS_component: import('vue').DefineComponent<OnyxMenuItemProps,
258
260
  };
259
261
  $refs: {
260
262
  [x: string]: unknown;
263
+ } & {
264
+ buttonRef: HTMLButtonElement;
261
265
  };
262
266
  $slots: Readonly<{
263
267
  [name: string]: import('vue').Slot<any> | undefined;
@@ -34,7 +34,16 @@ declare function __VLS_template(): {
34
34
  rootEl: HTMLDivElement;
35
35
  };
36
36
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
37
- declare const __VLS_component: import('vue').DefineComponent<OnyxPopoverProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<OnyxPopoverProps> & Readonly<{}>, {
37
+ declare const __VLS_component: import('vue').DefineComponent<OnyxPopoverProps, {
38
+ /**
39
+ * Actual used popover position.
40
+ */
41
+ popoverPosition: import('vue').ComputedRef<"top" | "left" | "right" | "bottom" | "top right" | "top left" | "bottom right" | "bottom left">;
42
+ /**
43
+ * Actual used popover alignment.
44
+ */
45
+ popoverAlignment: import('vue').ComputedRef<import('../../composables/useOpenAlignment.js', { with: { "resolution-mode": "import" } }).OpenAlignment>;
46
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<OnyxPopoverProps> & Readonly<{}>, {
38
47
  alignment: import('../../composables/useOpenAlignment.js', { with: { "resolution-mode": "import" } }).OpenAlignment | "auto";
39
48
  position: import('../../composables/useAnchorPositionPolyfill.js', { with: { "resolution-mode": "import" } }).AnchorPosition | "auto";
40
49
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
@@ -46,6 +46,7 @@ declare function __VLS_template(): {
46
46
  readonly density?: import('../../composables/density.js', { with: { "resolution-mode": "import" } }).Density | undefined;
47
47
  readonly alert?: boolean | undefined;
48
48
  readonly open?: boolean | undefined;
49
+ readonly disableClosingOnBackdropClick?: boolean | undefined;
49
50
  readonly alignment?: Exclude<import('../OnyxDialog/types.ts', { with: { "resolution-mode": "import" } }).DialogAlignment, "center"> | undefined;
50
51
  readonly modal?: boolean | undefined;
51
52
  readonly onClose?: (() => any) | undefined;
@@ -129,6 +130,7 @@ declare const __VLS_component: import('vue').DefineComponent<OnyxSidebarProps, {
129
130
  readonly density?: import('../../composables/density.js', { with: { "resolution-mode": "import" } }).Density | undefined;
130
131
  readonly alert?: boolean | undefined;
131
132
  readonly open?: boolean | undefined;
133
+ readonly disableClosingOnBackdropClick?: boolean | undefined;
132
134
  readonly alignment?: Exclude<import('../OnyxDialog/types.ts', { with: { "resolution-mode": "import" } }).DialogAlignment, "center"> | undefined;
133
135
  readonly modal?: boolean | undefined;
134
136
  readonly onClose?: (() => any) | undefined;
@@ -465,6 +465,7 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
465
465
  label: { type: String, required: true },
466
466
  open: { type: Boolean, required: false, default: false },
467
467
  modal: { type: Boolean, required: false, default: false },
468
+ disableClosingOnBackdropClick: { type: Boolean, required: false, default: false },
468
469
  alert: { type: Boolean, required: false, default: false },
469
470
  alignment: { type: null, required: false, default: "center" }
470
471
  },
@@ -483,6 +484,16 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
483
484
  if (props.open) openDialog();
484
485
  else dialog2.value?.close();
485
486
  });
487
+ const handleBackdropClick = (event) => {
488
+ const dialogElement = dialog2.value;
489
+ if (!event.detail || !dialogElement || !props.modal || props.disableClosingOnBackdropClick) {
490
+ return;
491
+ }
492
+ const dialogDimensions = dialogElement.getBoundingClientRect();
493
+ if (event.clientX < dialogDimensions.left || event.clientX > dialogDimensions.right || event.clientY < dialogDimensions.top || event.clientY > dialogDimensions.bottom) {
494
+ emit("close");
495
+ }
496
+ };
486
497
  watch(
487
498
  () => props.modal,
488
499
  () => {
@@ -492,7 +503,7 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
492
503
  }
493
504
  }
494
505
  );
495
- const __returned__ = { props, emit, dialog: dialog2, densityClass, openDialog };
506
+ const __returned__ = { props, emit, dialog: dialog2, densityClass, openDialog, handleBackdropClick };
496
507
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
497
508
  return __returned__;
498
509
  }
@@ -512,7 +523,8 @@ function _sfc_render$1r(_ctx, _cache, $props, $setup, $data, $options) {
512
523
  "aria-modal": $setup.props.modal,
513
524
  "aria-label": $setup.props.label,
514
525
  role: $setup.props.alert ? "alertdialog" : void 0,
515
- onCancel: _cache[0] || (_cache[0] = withModifiers(($event) => $setup.emit("close"), ["prevent"]))
526
+ onCancel: _cache[0] || (_cache[0] = withModifiers(($event) => $setup.emit("close"), ["prevent"])),
527
+ onClick: $setup.handleBackdropClick
516
528
  }, [
517
529
  renderSlot(_ctx.$slots, "default")
518
530
  ], 42, _hoisted_1$11)) : createCommentVNode("v-if", true);
@@ -732,6 +744,22 @@ function _sfc_render$1o(_ctx, _cache, $props, $setup, $data, $options) {
732
744
  }, 8, ["id", "class"]));
733
745
  }
734
746
  const OnyxHeadline = /* @__PURE__ */ _export_sfc(_sfc_main$1o, [["render", _sfc_render$1o], ["__file", "/home/runner/work/onyx/onyx/packages/sit-onyx/src/components/OnyxHeadline/OnyxHeadline.vue"]]);
747
+ const useAutofocus = (inputRef, props) => {
748
+ if (!props.autofocus) {
749
+ return;
750
+ }
751
+ onMounted(() => {
752
+ if (!props.loading) {
753
+ inputRef.value?.focus();
754
+ return;
755
+ }
756
+ watch(
757
+ () => !!props.loading,
758
+ () => inputRef.value?.focus(),
759
+ { once: true }
760
+ );
761
+ });
762
+ };
735
763
  const FORM_INJECTION_KEY = Symbol();
736
764
  const FORM_INJECTED_SYMBOL = Symbol("FORM_INJECTED_SYMBOL");
737
765
  const createCompute = (formProps, props, key, defaultValue) => computed(() => {
@@ -778,11 +806,13 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
778
806
  setup(__props, { expose: __expose }) {
779
807
  __expose();
780
808
  const props = __props;
809
+ const button = useTemplateRef("buttonRef");
781
810
  const { disabled } = useFormContext(props);
782
811
  const linkProps = computed(
783
812
  () => props.link != void 0 ? extractLinkProps(props.link) : void 0
784
813
  );
785
- const __returned__ = { props, disabled, linkProps, OnyxRouterLink };
814
+ useAutofocus(button, props);
815
+ const __returned__ = { props, button, disabled, linkProps, OnyxRouterLink };
786
816
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
787
817
  return __returned__;
788
818
  }
@@ -803,6 +833,7 @@ function _sfc_render$1n(_ctx, _cache, $props, $setup, $data, $options) {
803
833
  /* FULL_PROPS */
804
834
  )) : (openBlock(), createElementBlock("button", {
805
835
  key: 1,
836
+ ref: "buttonRef",
806
837
  disabled: $setup.disabled || $setup.props.loading,
807
838
  type: $setup.props.type,
808
839
  autofocus: $setup.props.autofocus
@@ -870,6 +901,7 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
870
901
  density: { type: null, required: false },
871
902
  label: { type: String, required: true },
872
903
  open: { type: Boolean, required: false },
904
+ disableClosingOnBackdropClick: { type: Boolean, required: false },
873
905
  icon: { type: Object, required: false }
874
906
  },
875
907
  emits: ["close"],
@@ -1652,22 +1684,6 @@ const useRequired = (props, requiredMarker) => ({
1652
1684
  "onyx-optional-marker": !props.required
1653
1685
  }))
1654
1686
  });
1655
- const useAutofocus = (inputRef, props) => {
1656
- if (!props.autofocus) {
1657
- return;
1658
- }
1659
- onMounted(() => {
1660
- if (!props.loading) {
1661
- inputRef.value?.focus();
1662
- return;
1663
- }
1664
- watch(
1665
- () => !!props.loading,
1666
- () => inputRef.value?.focus(),
1667
- { once: true }
1668
- );
1669
- });
1670
- };
1671
1687
  const isValidDate = (date) => {
1672
1688
  return date instanceof Date && !isNaN(date);
1673
1689
  };
@@ -2226,7 +2242,7 @@ const useOutsideClick = ({
2226
2242
  const clickListener = (event) => {
2227
2243
  if (isOutsideClick(event.target)) onOutsideClick(event);
2228
2244
  };
2229
- useGlobalEventListener({ type: "click", listener: clickListener, disabled });
2245
+ useGlobalEventListener({ type: "mousedown", listener: clickListener, disabled });
2230
2246
  if (checkOnTab) {
2231
2247
  const keydownListener = async (event) => {
2232
2248
  if (event.key !== "Tab") return;
@@ -2543,6 +2559,7 @@ const createMenuButton = createBuilder((options) => {
2543
2559
  const rootRef = createElRef();
2544
2560
  const menuRef = createElRef();
2545
2561
  const buttonId = useId();
2562
+ const position = computed(() => toValue(options.position) ?? "bottom");
2546
2563
  useGlobalEventListener({
2547
2564
  type: "keydown",
2548
2565
  listener: (e) => e.key === "Escape" && setExpanded(false),
@@ -2567,6 +2584,7 @@ const createMenuButton = createBuilder((options) => {
2567
2584
  const currentMenu = currentMenuItem?.closest('[role="menu"]') || menuRef.value;
2568
2585
  if (!currentMenu) return;
2569
2586
  const menuItems = Array.from(currentMenu.querySelectorAll('[role="menuitem"]')).filter((item) => item.closest('[role="menu"]') === currentMenu);
2587
+ if (position.value === "top") menuItems.reverse();
2570
2588
  let nextIndex = 0;
2571
2589
  if (currentMenuItem) {
2572
2590
  const currentIndex = menuItems.indexOf(currentMenuItem);
@@ -2592,11 +2610,11 @@ const createMenuButton = createBuilder((options) => {
2592
2610
  switch (event.key) {
2593
2611
  case "ArrowDown":
2594
2612
  event.preventDefault();
2595
- focusRelativeItem("next");
2613
+ focusRelativeItem(position.value === "bottom" ? "next" : "prev");
2596
2614
  break;
2597
2615
  case "ArrowUp":
2598
2616
  event.preventDefault();
2599
- focusRelativeItem("prev");
2617
+ focusRelativeItem(position.value === "bottom" ? "prev" : "next");
2600
2618
  break;
2601
2619
  case "Home":
2602
2620
  event.preventDefault();
@@ -2619,7 +2637,7 @@ const createMenuButton = createBuilder((options) => {
2619
2637
  }
2620
2638
  };
2621
2639
  const triggerEvents = computed(() => {
2622
- if (options.trigger.value !== "hover") return;
2640
+ if (toValue(options.trigger) !== "hover") return;
2623
2641
  return {
2624
2642
  onMouseenter: () => setExpanded(true),
2625
2643
  onMouseleave: () => setExpanded(false, true)
@@ -2645,7 +2663,7 @@ const createMenuButton = createBuilder((options) => {
2645
2663
  "aria-expanded": options.isExpanded.value,
2646
2664
  "aria-haspopup": true,
2647
2665
  onFocus: () => setExpanded(true, true),
2648
- onClick: () => options.trigger.value == "click" ? setExpanded(!options.isExpanded.value) : void 0,
2666
+ onClick: () => toValue(options.trigger) == "click" ? setExpanded(!options.isExpanded.value) : void 0,
2649
2667
  id: buttonId,
2650
2668
  disabled: options.disabled?.value
2651
2669
  })
@@ -4242,7 +4260,6 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent({
4242
4260
  disabled: { type: Boolean, required: false }
4243
4261
  },
4244
4262
  setup(__props, { expose: __expose }) {
4245
- __expose();
4246
4263
  const props = __props;
4247
4264
  const _isVisible = ref(false);
4248
4265
  const isVisible = computed({
@@ -4255,6 +4272,16 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent({
4255
4272
  const popoverAlignment = computed(
4256
4273
  () => props.alignment === "auto" ? openAlignment.value : props.alignment
4257
4274
  );
4275
+ __expose({
4276
+ /**
4277
+ * Actual used popover position.
4278
+ */
4279
+ popoverPosition,
4280
+ /**
4281
+ * Actual used popover alignment.
4282
+ */
4283
+ popoverAlignment
4284
+ });
4258
4285
  const disabled = computed(() => props.disabled);
4259
4286
  const positionAndAlignment = computed(() => {
4260
4287
  let returnPosition = popoverPosition.value;
@@ -4340,7 +4367,7 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent({
4340
4367
  "onyx-popover__dialog--dont-support-anchor": !userAgentSupportsAnchorApi.value
4341
4368
  };
4342
4369
  });
4343
- watch([disabled], () => {
4370
+ watch(disabled, () => {
4344
4371
  if (disabled.value) {
4345
4372
  _isVisible.value = false;
4346
4373
  }
@@ -4412,15 +4439,20 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
4412
4439
  default: false
4413
4440
  });
4414
4441
  const slots = useSlots();
4442
+ const popover = ref();
4443
+ const actualPosition = computed(() => popover.value?.popoverPosition);
4415
4444
  const {
4416
4445
  elements: { root, button, menu: menu2 }
4417
4446
  } = createMenuButton({
4418
4447
  isExpanded: computed(() => !!isExpanded.value),
4419
4448
  onToggle: () => isExpanded.value = !isExpanded.value,
4420
4449
  trigger: computed(() => props.trigger),
4421
- disabled: computed(() => props.disabled)
4450
+ disabled: computed(() => props.disabled),
4451
+ position: computed(() => actualPosition.value?.includes("top") ? "top" : "bottom")
4422
4452
  });
4423
- const __returned__ = { props, emit, isExpanded, slots, root, button, menu: menu2, OnyxPopover };
4453
+ const __returned__ = { props, emit, isExpanded, slots, popover, actualPosition, root, button, menu: menu2, get mergeVueProps() {
4454
+ return mergeVueProps;
4455
+ }, OnyxPopover };
4424
4456
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
4425
4457
  return __returned__;
4426
4458
  }
@@ -4428,7 +4460,8 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
4428
4460
  const _hoisted_1$H = { class: "onyx-flyout-menu__list-header" };
4429
4461
  const _hoisted_2$w = { class: "onyx-flyout-menu__list-footer" };
4430
4462
  function _sfc_render$Z(_ctx, _cache, $props, $setup, $data, $options) {
4431
- return openBlock(), createBlock($setup["OnyxPopover"], mergeProps({ class: "onyx-component onyx-flyout-menu" }, $setup.root, {
4463
+ return openBlock(), createBlock($setup["OnyxPopover"], mergeProps($setup.mergeVueProps($setup.root, { ref: $setup.popover }), {
4464
+ class: "onyx-component onyx-flyout-menu",
4432
4465
  open: $setup.isExpanded,
4433
4466
  label: $setup.props.label,
4434
4467
  alignment: $setup.props.alignment,
@@ -7446,6 +7479,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
7446
7479
  density: { type: null, required: false },
7447
7480
  label: { type: String, required: true },
7448
7481
  open: { type: Boolean, required: false },
7482
+ disableClosingOnBackdropClick: { type: Boolean, required: false },
7449
7483
  alert: { type: Boolean, required: false }
7450
7484
  },
7451
7485
  emits: ["close"],
@@ -7534,6 +7568,7 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
7534
7568
  density: { type: null, required: false },
7535
7569
  label: { type: String, required: true },
7536
7570
  open: { type: Boolean, required: false },
7571
+ disableClosingOnBackdropClick: { type: Boolean, required: false },
7537
7572
  alert: { type: Boolean, required: false },
7538
7573
  alignment: { type: null, required: false, default: "left" },
7539
7574
  modal: { type: Boolean, required: false, default: true }