@fkui/vue 5.45.1 → 5.46.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.
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, renderSlot, mergeProps, createTextVNode, createElementVNode, isVNode, Comment, createApp, resolveComponent, withKeys, createCommentVNode, toDisplayString, createVNode, createBlock, withCtx, Fragment, renderList, withModifiers, getCurrentInstance, resolveDynamicComponent, onMounted, toValue, onUnmounted, useSlots, normalizeProps, guardReactiveProps, Transition, Teleport, normalizeStyle, useTemplateRef, watchEffect, watch, nextTick, withDirectives, vShow, ref, unref, readonly, inject, toRef, provide, createSlots, vModelSelect, vModelDynamic, toHandlers, shallowRef, toRefs } from "vue";
1
+ import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, renderSlot, mergeProps, createTextVNode, createElementVNode, isVNode, Comment, createApp, resolveComponent, withKeys, createCommentVNode, toDisplayString, createVNode, createBlock, withCtx, Fragment, renderList, withModifiers, getCurrentInstance, resolveDynamicComponent, onMounted, toValue, onUnmounted, useSlots, ref, normalizeProps, guardReactiveProps, unref, Transition, Teleport, normalizeStyle, useTemplateRef, watchEffect, watch, nextTick, withDirectives, vShow, readonly, inject, toRef, provide, createSlots, vModelSelect, vModelDynamic, toHandlers, shallowRef, toRefs } from "vue";
2
2
  import { TranslationService, isSet, configLogic, focus as focus$1, ElementIdService, pushFocus, findTabbableElements, popFocus, scrollTo, Reference, documentOrderComparator, ValidationService, isValidatableHTMLElement, alertScreenReader, debounce, handleTab, isEmpty, deepClone, formatNumber, parseNumber, parseBankAccountNumber, parseBankgiro, parseClearingNumber, formatPersonnummer, parsePersonnummer, parsePlusgiro, formatPostalCode, parsePercent, formatPercent, parseOrganisationsnummer, isInvalidDatesConfig, isInvalidWeekdaysConfig, parseDate, waitForScreenReader, focusFirst, saveFocus, addFocusListener, removeFocusListener, restoreFocus, DomUtils } from "@fkui/logic";
3
3
  import { getWeekdayNamings, groupByWeek, FDate, DateFormat } from "@fkui/date";
4
4
  const statuses = ["default", "warning", "error", "success", "info"];
@@ -5530,6 +5530,9 @@ const _sfc_main$12 = defineComponent({
5530
5530
  };
5531
5531
  },
5532
5532
  computed: {
5533
+ ariaLabel() {
5534
+ return `${this.value.monthName} ${this.value.year}`;
5535
+ },
5533
5536
  totalCols() {
5534
5537
  return this.hideWeekNumbers ? 7 : 8;
5535
5538
  },
@@ -5571,50 +5574,43 @@ const _sfc_main$12 = defineComponent({
5571
5574
  }
5572
5575
  }
5573
5576
  });
5574
- const _hoisted_1$O = {
5577
+ const _hoisted_1$O = ["aria-label"];
5578
+ const _hoisted_2$A = {
5575
5579
  key: 0,
5576
5580
  class: "calendar-month__col--week"
5577
5581
  };
5578
- const _hoisted_2$A = {
5579
- role: "presentation"
5580
- };
5581
5582
  const _hoisted_3$s = {
5582
- role: "presentation"
5583
- };
5584
- const _hoisted_4$n = {
5585
5583
  key: 0,
5586
5584
  scope: "col",
5587
5585
  "aria-hidden": "true",
5588
5586
  class: "calendar-month__header-cell"
5589
5587
  };
5590
- const _hoisted_5$i = ["title"];
5591
- const _hoisted_6$e = {
5592
- role: "presentation"
5593
- };
5594
- const _hoisted_7$d = {
5588
+ const _hoisted_4$n = ["title"];
5589
+ const _hoisted_5$i = {
5595
5590
  key: 0,
5596
5591
  class: "calendar-month__cell calendar-month__cell--week-number",
5597
5592
  "aria-hidden": "true"
5598
5593
  };
5599
- const _hoisted_8$8 = ["colspan"];
5600
- const _hoisted_9$5 = ["colspan"];
5601
- const _hoisted_10$3 = {
5594
+ const _hoisted_6$e = ["colspan"];
5595
+ const _hoisted_7$d = ["colspan"];
5596
+ const _hoisted_8$8 = {
5602
5597
  key: 0,
5603
5598
  "aria-hidden": "true"
5604
5599
  };
5605
- const _hoisted_11$2 = ["colspan"];
5606
- const _hoisted_12$2 = {
5600
+ const _hoisted_9$5 = ["colspan"];
5601
+ const _hoisted_10$3 = {
5607
5602
  key: 1,
5608
5603
  "aria-hidden": "true"
5609
5604
  };
5610
- const _hoisted_13$1 = ["colspan"];
5605
+ const _hoisted_11$2 = ["colspan"];
5611
5606
  function _sfc_render$Q(_ctx, _cache, $props, $setup, $data, $options) {
5612
5607
  return openBlock(), createElementBlock("table", {
5613
5608
  class: "calendar-month__table",
5614
- role: "application",
5609
+ role: "grid",
5610
+ "aria-label": _ctx.ariaLabel,
5615
5611
  onFocusin: _cache[0] || (_cache[0] = (...args) => _ctx.onFocusin && _ctx.onFocusin(...args)),
5616
5612
  onFocusout: _cache[1] || (_cache[1] = (...args) => _ctx.onFocusout && _ctx.onFocusout(...args))
5617
- }, [createElementVNode("colgroup", null, [!_ctx.internalHideWeekNumbers ? (openBlock(), createElementBlock("col", _hoisted_1$O)) : createCommentVNode("", true), _cache[2] || (_cache[2] = createTextVNode()), _cache[3] || (_cache[3] = createElementVNode("col", {
5613
+ }, [createElementVNode("colgroup", null, [!_ctx.internalHideWeekNumbers ? (openBlock(), createElementBlock("col", _hoisted_2$A)) : createCommentVNode("", true), _cache[2] || (_cache[2] = createTextVNode()), _cache[3] || (_cache[3] = createElementVNode("col", {
5618
5614
  class: "calendar-month__col--day"
5619
5615
  }, null, -1)), _cache[4] || (_cache[4] = createTextVNode()), _cache[5] || (_cache[5] = createElementVNode("col", {
5620
5616
  class: "calendar-month__col--day"
@@ -5628,26 +5624,23 @@ function _sfc_render$Q(_ctx, _cache, $props, $setup, $data, $options) {
5628
5624
  class: "calendar-month__col--day"
5629
5625
  }, null, -1)), _cache[14] || (_cache[14] = createTextVNode()), _cache[15] || (_cache[15] = createElementVNode("col", {
5630
5626
  class: "calendar-month__col--day"
5631
- }, null, -1))]), _cache[22] || (_cache[22] = createTextVNode()), createElementVNode("thead", _hoisted_2$A, [createElementVNode("tr", _hoisted_3$s, [!_ctx.internalHideWeekNumbers ? (openBlock(), createElementBlock("th", _hoisted_4$n)) : createCommentVNode("", true), _cache[16] || (_cache[16] = createTextVNode()), (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weekdays, (weekday) => {
5627
+ }, null, -1))]), _cache[22] || (_cache[22] = createTextVNode()), createElementVNode("thead", null, [createElementVNode("tr", null, [!_ctx.internalHideWeekNumbers ? (openBlock(), createElementBlock("th", _hoisted_3$s)) : createCommentVNode("", true), _cache[16] || (_cache[16] = createTextVNode()), (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weekdays, (weekday) => {
5632
5628
  return openBlock(), createElementBlock("th", {
5633
5629
  key: weekday.name,
5634
5630
  scope: "col",
5635
- role: "presentation",
5636
5631
  class: "calendar-month__header-cell"
5637
5632
  }, [createElementVNode("abbr", {
5638
- "aria-hidden": "true",
5639
5633
  title: weekday.name
5640
- }, toDisplayString(_ctx.showShortWeekdays ? weekday.shortName : weekday.name), 9, _hoisted_5$i)]);
5641
- }), 128))])]), _cache[23] || (_cache[23] = createTextVNode()), createElementVNode("tbody", _hoisted_6$e, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (week) => {
5634
+ }, toDisplayString(_ctx.showShortWeekdays ? weekday.shortName : weekday.name), 9, _hoisted_4$n)]);
5635
+ }), 128))])]), _cache[23] || (_cache[23] = createTextVNode()), createElementVNode("tbody", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (week) => {
5642
5636
  return openBlock(), createElementBlock("tr", {
5643
- key: week.week,
5644
- role: "presentation"
5645
- }, [!_ctx.internalHideWeekNumbers ? (openBlock(), createElementBlock("td", _hoisted_7$d, toDisplayString(week.week), 1)) : createCommentVNode("", true), _cache[17] || (_cache[17] = createTextVNode()), _ctx.getDayStartOffset(week.days) ? (openBlock(), createElementBlock("td", {
5637
+ key: week.week
5638
+ }, [!_ctx.internalHideWeekNumbers ? (openBlock(), createElementBlock("td", _hoisted_5$i, toDisplayString(week.week), 1)) : createCommentVNode("", true), _cache[17] || (_cache[17] = createTextVNode()), _ctx.getDayStartOffset(week.days) ? (openBlock(), createElementBlock("td", {
5646
5639
  key: 1,
5647
5640
  class: "calendar-month__cell",
5648
5641
  colspan: _ctx.getDayStartOffset(week.days),
5649
5642
  "aria-hidden": "true"
5650
- }, null, 8, _hoisted_8$8)) : createCommentVNode("", true), _cache[18] || (_cache[18] = createTextVNode()), (openBlock(true), createElementBlock(Fragment, null, renderList(week.days, (day) => {
5643
+ }, null, 8, _hoisted_6$e)) : createCommentVNode("", true), _cache[18] || (_cache[18] = createTextVNode()), (openBlock(true), createElementBlock(Fragment, null, renderList(week.days, (day) => {
5651
5644
  return openBlock(), createElementBlock("td", {
5652
5645
  key: day.toString(),
5653
5646
  class: "calendar-month__cell",
@@ -5661,16 +5654,16 @@ function _sfc_render$Q(_ctx, _cache, $props, $setup, $data, $options) {
5661
5654
  class: "calendar-month__cell",
5662
5655
  colspan: _ctx.getDayEndOffset(week.days),
5663
5656
  "aria-hidden": "true"
5664
- }, null, 8, _hoisted_9$5)) : createCommentVNode("", true)]);
5665
- }), 128)), _cache[20] || (_cache[20] = createTextVNode()), _ctx.weeks.length < 5 ? (openBlock(), createElementBlock("tr", _hoisted_10$3, [createElementVNode("td", {
5657
+ }, null, 8, _hoisted_7$d)) : createCommentVNode("", true)]);
5658
+ }), 128)), _cache[20] || (_cache[20] = createTextVNode()), _ctx.weeks.length < 5 ? (openBlock(), createElementBlock("tr", _hoisted_8$8, [createElementVNode("td", {
5666
5659
  class: "calendar-month__cell",
5667
5660
  colspan: _ctx.totalCols,
5668
5661
  "aria-hidden": "true"
5669
- }, null, 8, _hoisted_11$2)])) : createCommentVNode("", true), _cache[21] || (_cache[21] = createTextVNode()), _ctx.weeks.length < 6 ? (openBlock(), createElementBlock("tr", _hoisted_12$2, [createElementVNode("td", {
5662
+ }, null, 8, _hoisted_9$5)])) : createCommentVNode("", true), _cache[21] || (_cache[21] = createTextVNode()), _ctx.weeks.length < 6 ? (openBlock(), createElementBlock("tr", _hoisted_10$3, [createElementVNode("td", {
5670
5663
  class: "calendar-month__cell",
5671
5664
  colspan: _ctx.totalCols,
5672
5665
  "aria-hidden": "true"
5673
- }, null, 8, _hoisted_13$1)])) : createCommentVNode("", true)])], 32);
5666
+ }, null, 8, _hoisted_11$2)])) : createCommentVNode("", true)])], 40, _hoisted_1$O);
5674
5667
  }
5675
5668
  const ICalendarMonthGrid = /* @__PURE__ */ _export_sfc(_sfc_main$12, [["render", _sfc_render$Q]]);
5676
5669
  const DayStep = {
@@ -5743,6 +5736,11 @@ const _sfc_main$11 = defineComponent({
5743
5736
  this.$emit("click", date);
5744
5737
  },
5745
5738
  async onKeydownDay(date, event) {
5739
+ if (event.code === "Enter" || event.code === "Space") {
5740
+ event.preventDefault();
5741
+ this.$emit("click", date);
5742
+ return;
5743
+ }
5746
5744
  if (!isDayStepKey(event)) {
5747
5745
  return;
5748
5746
  }
@@ -5790,13 +5788,13 @@ function _sfc_render$P(_ctx, _cache, $props, $setup, $data, $options) {
5790
5788
  }, {
5791
5789
  default: withCtx(({
5792
5790
  date
5793
- }) => [createElementVNode("button", {
5791
+ }) => [createElementVNode("div", {
5794
5792
  ref: date.toString(),
5793
+ role: "gridcell",
5795
5794
  class: "calendar-month__button",
5796
5795
  "data-test": "select-day-button",
5797
5796
  "data-date": date.toString(),
5798
5797
  tabindex: _ctx.getTabindex(date),
5799
- type: "button",
5800
5798
  onClick: withModifiers(($event) => _ctx.onClickDay(date), ["stop", "prevent"]),
5801
5799
  onKeydown: ($event) => _ctx.onKeydownDay(date, $event)
5802
5800
  }, [renderSlot(_ctx.$slots, "default", {
@@ -6004,9 +6002,7 @@ function useSlotUtils() {
6004
6002
  }
6005
6003
  };
6006
6004
  }
6007
- const _hoisted_1$K = {
6008
- class: "card card--default"
6009
- };
6005
+ const _hoisted_1$K = ["id"];
6010
6006
  const _hoisted_2$y = {
6011
6007
  key: 0,
6012
6008
  class: "card__header"
@@ -6020,16 +6016,91 @@ const _hoisted_4$m = {
6020
6016
  };
6021
6017
  const _sfc_main$_ = /* @__PURE__ */ defineComponent({
6022
6018
  __name: "FCard",
6019
+ props: {
6020
+ /**
6021
+ * Element to focus on when card is invalid. Set when using validation.
6022
+ */
6023
+ focusRef: {
6024
+ type: Object,
6025
+ required: false,
6026
+ default: null
6027
+ },
6028
+ /**
6029
+ * Optional id (generated by default).
6030
+ */
6031
+ id: {
6032
+ type: String,
6033
+ required: false,
6034
+ default: () => ElementIdService.generateElementId()
6035
+ }
6036
+ },
6023
6037
  setup(__props) {
6024
6038
  const {
6025
6039
  hasSlot: hasSlot2
6026
6040
  } = useSlotUtils();
6041
+ const validationMessage = ref("");
6042
+ const hasError = ref(false);
6043
+ const isMounted = ref(false);
6027
6044
  const hasHeaderSlot = computed(() => hasSlot2("header"));
6028
6045
  const hasFooterSlot = computed(() => hasSlot2("footer"));
6046
+ const cardClass = computed(() => `card card--${hasError.value ? "error" : "default"}`);
6047
+ const props = __props;
6048
+ onMounted(() => isMounted.value = true);
6049
+ async function onValidity({
6050
+ detail
6051
+ }) {
6052
+ if (!isMounted.value) {
6053
+ return;
6054
+ }
6055
+ if (!props.focusRef) {
6056
+ throw new Error("Element to focus on when card is invalid (`focusRef`) is required when using card validation.");
6057
+ }
6058
+ const focusElementId = props.focusRef.id;
6059
+ if (!focusElementId) {
6060
+ throw new Error("An id must be set on the card's focus element.");
6061
+ }
6062
+ hasError.value = !detail.isValid;
6063
+ validationMessage.value = detail.validationMessage;
6064
+ dispatchComponentValidityEvent(props.focusRef, {
6065
+ ...detail,
6066
+ errorMessage: validationMessage.value,
6067
+ focusElementId
6068
+ });
6069
+ }
6029
6070
  return (_ctx, _cache) => {
6030
- return openBlock(), createElementBlock("div", _hoisted_1$K, [hasHeaderSlot.value ? (openBlock(), createElementBlock("div", _hoisted_2$y, [renderSlot(_ctx.$slots, "header", normalizeProps(guardReactiveProps({
6071
+ return openBlock(), createElementBlock("div", {
6072
+ id: __props.id,
6073
+ class: normalizeClass(cardClass.value),
6074
+ onValidity
6075
+ }, [hasHeaderSlot.value ? (openBlock(), createElementBlock("div", _hoisted_2$y, [renderSlot(_ctx.$slots, "header", normalizeProps(guardReactiveProps({
6031
6076
  headingSlotClass: "card__header-label"
6032
- })))])) : createCommentVNode("", true), _cache[0] || (_cache[0] = createTextVNode()), createElementVNode("div", _hoisted_3$r, [renderSlot(_ctx.$slots, "default")]), _cache[1] || (_cache[1] = createTextVNode()), hasFooterSlot.value ? (openBlock(), createElementBlock("div", _hoisted_4$m, [renderSlot(_ctx.$slots, "footer")])) : createCommentVNode("", true)]);
6077
+ })))])) : createCommentVNode("", true), _cache[1] || (_cache[1] = createTextVNode()), renderSlot(_ctx.$slots, "error-message", normalizeProps(guardReactiveProps({
6078
+ hasError: hasError.value,
6079
+ validationMessage: validationMessage.value
6080
+ })), () => [hasError.value ? (openBlock(), createBlock(unref(IFlex), {
6081
+ key: 0,
6082
+ gap: "1x",
6083
+ class: "card__error-message"
6084
+ }, {
6085
+ default: withCtx(() => [createVNode(unref(IFlexItem), {
6086
+ shrink: "",
6087
+ align: "center"
6088
+ }, {
6089
+ default: withCtx(() => [createVNode(unref(FIcon), {
6090
+ name: "error"
6091
+ })]),
6092
+ _: 1
6093
+ }), _cache[0] || (_cache[0] = createTextVNode()), createVNode(unref(IFlexItem), {
6094
+ grow: ""
6095
+ }, {
6096
+ default: withCtx(() => [createTextVNode(toDisplayString(validationMessage.value), 1)]),
6097
+ _: 1
6098
+ })]),
6099
+ _: 1
6100
+ })) : createCommentVNode("", true)]), _cache[2] || (_cache[2] = createTextVNode()), createElementVNode("div", _hoisted_3$r, [renderSlot(_ctx.$slots, "default")]), _cache[3] || (_cache[3] = createTextVNode()), hasFooterSlot.value ? (openBlock(), createElementBlock("div", _hoisted_4$m, [renderSlot(_ctx.$slots, "footer", normalizeProps(guardReactiveProps({
6101
+ hasError: hasError.value,
6102
+ validationMessage: validationMessage.value
6103
+ })))])) : createCommentVNode("", true)], 42, _hoisted_1$K);
6033
6104
  };
6034
6105
  }
6035
6106
  });
@@ -17052,6 +17123,20 @@ const _sfc_main = defineComponent({
17052
17123
  });
17053
17124
  }
17054
17125
  DomUtils.focus(headerElement);
17126
+ },
17127
+ beforeNextWrapper() {
17128
+ return this.beforeNext({
17129
+ key: this.step.key,
17130
+ stepNumber: this.stepNumber,
17131
+ totalSteps: this.totalSteps
17132
+ });
17133
+ },
17134
+ beforeValidationWrapper() {
17135
+ return this.beforeValidation({
17136
+ key: this.step.key,
17137
+ stepNumber: this.stepNumber,
17138
+ totalSteps: this.totalSteps
17139
+ });
17055
17140
  }
17056
17141
  }
17057
17142
  });
@@ -17167,19 +17252,25 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
17167
17252
  }, {
17168
17253
  default: withCtx(() => [createVNode(_component_f_validation_form, {
17169
17254
  id: _ctx.formId,
17170
- "before-submit": _ctx.beforeNext,
17171
- "before-validation": _ctx.beforeValidation,
17255
+ "before-submit": _ctx.beforeNextWrapper,
17256
+ "before-validation": _ctx.beforeValidationWrapper,
17172
17257
  "use-error-list": _ctx.useErrorList,
17173
17258
  class: "wizard-step-body",
17174
17259
  onSubmit: _ctx.onSubmit
17175
17260
  }, {
17176
- "error-message": withCtx(() => [renderSlot(_ctx.$slots, "error-message", {}, () => [createTextVNode(toDisplayString(_ctx.$t("fkui.wizard-step.errorlist.title", "Oj, du har glömt att fylla i något. Gå till:")), 1)])]),
17261
+ "error-message": withCtx(() => [renderSlot(_ctx.$slots, "error-message", normalizeProps(guardReactiveProps({
17262
+ stepNumber: _ctx.stepNumber,
17263
+ totalSteps: _ctx.totalSteps
17264
+ })), () => [createTextVNode(toDisplayString(_ctx.$t("fkui.wizard-step.errorlist.title", "Oj, du har glömt att fylla i något. Gå till:")), 1)])]),
17177
17265
  default: withCtx(() => [renderSlot(_ctx.$slots, "default"), _cache[14] || (_cache[14] = createTextVNode()), createElementVNode("div", _hoisted_10, [createElementVNode("button", {
17178
17266
  "data-test": "submit-button",
17179
17267
  "data-disabled": _ctx.ignoreClick ? "true" : "false",
17180
17268
  type: "submit",
17181
17269
  class: "button button--primary button-group__item button--large"
17182
- }, [renderSlot(_ctx.$slots, "next-button-text", {}, () => [_ctx.isFinalStep ? (openBlock(), createElementBlock(Fragment, {
17270
+ }, [renderSlot(_ctx.$slots, "next-button-text", normalizeProps(guardReactiveProps({
17271
+ stepNumber: _ctx.stepNumber,
17272
+ totalSteps: _ctx.totalSteps
17273
+ })), () => [_ctx.isFinalStep ? (openBlock(), createElementBlock(Fragment, {
17183
17274
  key: 0
17184
17275
  }, [createTextVNode(toDisplayString(_ctx.$t("fkui.wizard-step.button.next.text-final", "Gå vidare och granska")), 1)], 64)) : (openBlock(), createElementBlock(Fragment, {
17185
17276
  key: 1