@fkui/vue-labs 6.36.0 → 6.36.1

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 { nextTick, toValue, defineComponent, useTemplateRef, computed, openBlock, createElementBlock, createElementVNode, createVNode, unref, renderSlot, withModifiers, normalizeClass, withCtx, createTextVNode, toDisplayString, createBlock, createCommentVNode, ref, inject, withDirectives, vShow, useId, onMounted, watchEffect, vModelText, toRef, watch, onUpdated, useModel, useSlots, provide, Fragment, renderList, mergeProps, resolveDynamicComponent, mergeModels, resolveDirective, normalizeProps, guardReactiveProps } from "vue";
1
+ import { nextTick, toValue, defineComponent, useTemplateRef, computed, openBlock, createElementBlock, createElementVNode, createVNode, unref, renderSlot, withModifiers, normalizeClass, withCtx, createTextVNode, toDisplayString, createBlock, createCommentVNode, ref, inject, withDirectives, vShow, onMounted, watchEffect, mergeProps, vModelText, toRef, watch, onUpdated, useModel, useSlots, provide, Fragment, renderList, resolveDynamicComponent, mergeModels, resolveDirective, normalizeProps, guardReactiveProps } from "vue";
2
2
  import { assertRef, formatPostalCode, parsePlusgiro, parseNumber, formatNumber, parseOrganisationsnummer, parseDate, parseClearingNumber, parseBankgiro, parseBankAccountNumber, parsePersonnummer, formatPersonnummer, ElementIdService, assertSet, ValidationService, alertScreenReader, debounce, isEmpty, stripWhitespace, isSet, TranslationService } from "@fkui/logic";
3
3
  import { FIcon, IFlex, IFlexItem, useTranslate, getItemIdentifier, FContextMenu, IComboboxDropdown, IPopupError, dispatchComponentValidityEvent, findItemIdentifier, useSlotUtils, setItemIdentifiers, FSortFilterDatasetInjected, EventBus, FFileSelector, FFileItem, TranslationMixin, FTextField, useTextFieldSetup } from "@fkui/vue";
4
4
  import { useElementHover, useFocusWithin, useEventListener } from "@vueuse/core";
@@ -2706,13 +2706,12 @@ const inputFieldConfig = {
2706
2706
  personnummerFormat: {},
2707
2707
  personnummerLuhn: {}
2708
2708
  },
2709
- attributes: () => [{
2710
- name: "inputmode",
2711
- value: "numeric"
2712
- }, {
2713
- name: "maxlength",
2714
- value: "23"
2715
- }]
2709
+ attributes: () => {
2710
+ return {
2711
+ inputmode: "numeric",
2712
+ maxlength: "23"
2713
+ };
2714
+ }
2716
2715
  },
2717
2716
  "text:bankAccountNumber": {
2718
2717
  formatter(value) {
@@ -2724,13 +2723,12 @@ const inputFieldConfig = {
2724
2723
  validationConfig: {
2725
2724
  bankAccountNumber: {}
2726
2725
  },
2727
- attributes: () => [{
2728
- name: "inputmode",
2729
- value: "numeric"
2730
- }, {
2731
- name: "maxlength",
2732
- value: "40"
2733
- }]
2726
+ attributes: () => {
2727
+ return {
2728
+ inputmode: "numeric",
2729
+ maxlength: "40"
2730
+ };
2731
+ }
2734
2732
  },
2735
2733
  "text:bankgiro": {
2736
2734
  formatter(value) {
@@ -2745,13 +2743,12 @@ const inputFieldConfig = {
2745
2743
  },
2746
2744
  bankgiro: {}
2747
2745
  },
2748
- attributes: () => [{
2749
- name: "inputmode",
2750
- value: "numeric"
2751
- }, {
2752
- name: "maxlength",
2753
- value: "40"
2754
- }]
2746
+ attributes: () => {
2747
+ return {
2748
+ inputmode: "numeric",
2749
+ maxlength: "40"
2750
+ };
2751
+ }
2755
2752
  },
2756
2753
  "text:clearingNumber": {
2757
2754
  formatter(value) {
@@ -2763,13 +2760,12 @@ const inputFieldConfig = {
2763
2760
  validationConfig: {
2764
2761
  clearingNumber: {}
2765
2762
  },
2766
- attributes: () => [{
2767
- name: "inputmode",
2768
- value: "numeric"
2769
- }, {
2770
- name: "maxlength",
2771
- value: "16"
2772
- }]
2763
+ attributes: () => {
2764
+ return {
2765
+ inputmode: "numeric",
2766
+ maxlength: "16"
2767
+ };
2768
+ }
2773
2769
  },
2774
2770
  "text:currency": {
2775
2771
  formatter(value) {
@@ -2782,13 +2778,12 @@ const inputFieldConfig = {
2782
2778
  currency: {},
2783
2779
  integer: {}
2784
2780
  },
2785
- attributes: () => [{
2786
- name: "inputmode",
2787
- value: "numeric"
2788
- }, {
2789
- name: "maxlength",
2790
- value: "20"
2791
- }]
2781
+ attributes: () => {
2782
+ return {
2783
+ inputmode: "numeric",
2784
+ maxlength: "20"
2785
+ };
2786
+ }
2792
2787
  },
2793
2788
  "text:date": {
2794
2789
  formatter(value) {
@@ -2800,10 +2795,11 @@ const inputFieldConfig = {
2800
2795
  validationConfig: {
2801
2796
  date: {}
2802
2797
  },
2803
- attributes: () => [{
2804
- name: "type",
2805
- value: "text"
2806
- }]
2798
+ attributes: () => {
2799
+ return {
2800
+ type: "text"
2801
+ };
2802
+ }
2807
2803
  },
2808
2804
  "text:email": {
2809
2805
  formatter(value) {
@@ -2818,13 +2814,12 @@ const inputFieldConfig = {
2818
2814
  length: 80
2819
2815
  }
2820
2816
  },
2821
- attributes: () => [{
2822
- name: "type",
2823
- value: "email"
2824
- }, {
2825
- name: "maxlength",
2826
- value: "80"
2827
- }]
2817
+ attributes: () => {
2818
+ return {
2819
+ type: "email",
2820
+ maxlength: "80"
2821
+ };
2822
+ }
2828
2823
  },
2829
2824
  "text:number": {
2830
2825
  formatter(value) {
@@ -2838,13 +2833,12 @@ const inputFieldConfig = {
2838
2833
  validationConfig: {
2839
2834
  number: {}
2840
2835
  },
2841
- attributes: () => [{
2842
- name: "inputmode",
2843
- value: "numeric"
2844
- }, {
2845
- name: "maxlength",
2846
- value: "20"
2847
- }]
2836
+ attributes: () => {
2837
+ return {
2838
+ inputmode: "numeric",
2839
+ maxlength: "20"
2840
+ };
2841
+ }
2848
2842
  },
2849
2843
  "text:organisationsnummer": {
2850
2844
  formatter(value) {
@@ -2859,13 +2853,12 @@ const inputFieldConfig = {
2859
2853
  },
2860
2854
  organisationsnummer: {}
2861
2855
  },
2862
- attributes: () => [{
2863
- name: "inputmode",
2864
- value: "numeric"
2865
- }, {
2866
- name: "maxlength",
2867
- value: "20"
2868
- }]
2856
+ attributes: () => {
2857
+ return {
2858
+ inputmode: "numeric",
2859
+ maxlength: "20"
2860
+ };
2861
+ }
2869
2862
  },
2870
2863
  "text:percent": {
2871
2864
  formatter(value) {
@@ -2885,14 +2878,12 @@ const inputFieldConfig = {
2885
2878
  maxValue: 999
2886
2879
  }
2887
2880
  },
2888
- attributes: (decimals) => {
2889
- return [{
2890
- name: "inputmode",
2891
- value: decimals ? "decimal" : "numeric"
2892
- }, {
2893
- name: "maxlength",
2894
- value: "10"
2895
- }];
2881
+ attributes: (options) => {
2882
+ const decimals = options?.decimals;
2883
+ return {
2884
+ inputmode: decimals ? "decimal" : "numeric",
2885
+ maxlength: "10"
2886
+ };
2896
2887
  }
2897
2888
  },
2898
2889
  "text:phoneNumber": {
@@ -2908,13 +2899,12 @@ const inputFieldConfig = {
2908
2899
  },
2909
2900
  phoneNumber: {}
2910
2901
  },
2911
- attributes: () => [{
2912
- name: "maxlength",
2913
- value: "80"
2914
- }, {
2915
- name: "type",
2916
- value: "tel"
2917
- }]
2902
+ attributes: () => {
2903
+ return {
2904
+ maxlength: "80",
2905
+ type: "tel"
2906
+ };
2907
+ }
2918
2908
  },
2919
2909
  "text:plusgiro": {
2920
2910
  formatter(value) {
@@ -2929,13 +2919,12 @@ const inputFieldConfig = {
2929
2919
  },
2930
2920
  plusgiro: {}
2931
2921
  },
2932
- attributes: () => [{
2933
- name: "inputmode",
2934
- value: "numeric"
2935
- }, {
2936
- name: "maxlength",
2937
- value: "16"
2938
- }]
2922
+ attributes: () => {
2923
+ return {
2924
+ inputmode: "numeric",
2925
+ maxlength: "16"
2926
+ };
2927
+ }
2939
2928
  },
2940
2929
  "text:postalCode": {
2941
2930
  formatter(value) {
@@ -2950,13 +2939,12 @@ const inputFieldConfig = {
2950
2939
  },
2951
2940
  postalCode: {}
2952
2941
  },
2953
- attributes: () => [{
2954
- name: "inputmode",
2955
- value: "numeric"
2956
- }, {
2957
- name: "maxlength",
2958
- value: "15"
2959
- }]
2942
+ attributes: () => {
2943
+ return {
2944
+ inputmode: "numeric",
2945
+ maxlength: "15"
2946
+ };
2947
+ }
2960
2948
  },
2961
2949
  text: {
2962
2950
  formatter(value) {
@@ -2966,7 +2954,9 @@ const inputFieldConfig = {
2966
2954
  return value;
2967
2955
  },
2968
2956
  validationConfig: {},
2969
- attributes: () => []
2957
+ attributes: () => {
2958
+ return {};
2959
+ }
2970
2960
  }
2971
2961
  };
2972
2962
  const _hoisted_1$c = ["aria-sort"];
@@ -3852,6 +3842,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3852
3842
  function onClose() {
3853
3843
  isOpen.value = false;
3854
3844
  }
3845
+ function onFocusout(event) {
3846
+ const validTarget = event.relatedTarget && event.relatedTarget instanceof HTMLElement;
3847
+ const inPopup = validTarget && Boolean(event.relatedTarget.closest(".popup"));
3848
+ if (inPopup) {
3849
+ return;
3850
+ }
3851
+ isOpen.value = false;
3852
+ }
3855
3853
  function onSelect(key) {
3856
3854
  const action = actions.value.find((it) => it.key === key);
3857
3855
  action?.onClick(__props.row);
@@ -3873,7 +3871,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3873
3871
  items: menuitems.value,
3874
3872
  anchor: (_buttonRef$value = buttonRef.value) !== null && _buttonRef$value !== void 0 ? _buttonRef$value : void 0,
3875
3873
  onClose,
3876
- onSelect
3874
+ onSelect,
3875
+ onFocusout
3877
3876
  }, null, 8, ["is-open", "items", "anchor"])])) : (openBlock(), createElementBlock("td", _hoisted_3$4));
3878
3877
  };
3879
3878
  }
@@ -4092,16 +4091,45 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4092
4091
  };
4093
4092
  }
4094
4093
  });
4095
- function addInputValidators(inputElement, type, decimals) {
4096
- ValidationService.addValidatorsToElement(inputElement, inputFieldConfig[type].validationConfig, true);
4097
- const options = void 0;
4098
- const attributes = inputFieldConfig[type].attributes(options);
4099
- for (const {
4100
- name,
4101
- value
4102
- } of attributes) {
4103
- inputElement.setAttribute(name, value);
4094
+ function defaultTnumValue(type) {
4095
+ const tnumTypes = ["text:bankAccountNumber", "text:bankgiro", "text:clearingNumber", "text:currency", "text:number", "text:organisationsnummer", "text:percent", "text:personnummer", "text:phoneNumber", "text:plusgiro", "text:postalCode"];
4096
+ return tnumTypes.includes(type);
4097
+ }
4098
+ function getLabelFn(fn) {
4099
+ if (fn) {
4100
+ return fn;
4104
4101
  }
4102
+ return () => "";
4103
+ }
4104
+ function getUpdateFn(fn, key) {
4105
+ if (fn) {
4106
+ return fn;
4107
+ }
4108
+ if (key) {
4109
+ return (row, value) => {
4110
+ row[key] = value;
4111
+ };
4112
+ }
4113
+ return () => void 0;
4114
+ }
4115
+ function getValueFn(fn, key, coerce, defaultValue) {
4116
+ if (fn) {
4117
+ return fn;
4118
+ }
4119
+ if (key) {
4120
+ return (row) => {
4121
+ var _row$key;
4122
+ return coerce((_row$key = row[key]) !== null && _row$key !== void 0 ? _row$key : defaultValue);
4123
+ };
4124
+ }
4125
+ return () => defaultValue;
4126
+ }
4127
+ function isColumnTypeNumber(column) {
4128
+ const type = column.type;
4129
+ return numberTypes.includes(type);
4130
+ }
4131
+ function addInputValidators(inputElement, type) {
4132
+ ValidationService.addValidatorsToElement(inputElement, inputFieldConfig[type].validationConfig, true);
4105
4133
  }
4106
4134
  function isAlphanumeric(e) {
4107
4135
  return e.key.length === 1 && !e.ctrlKey && !e.metaKey;
@@ -4134,8 +4162,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
4134
4162
  const emit = __emit;
4135
4163
  const viewValue = ref("");
4136
4164
  const inEdit = ref(false);
4137
- const cellId = useId();
4138
- const inputId = useId();
4165
+ const cellId = ElementIdService.generateElementId();
4166
+ const inputId = ElementIdService.generateElementId();
4139
4167
  const validity = ref({
4140
4168
  isValid: true,
4141
4169
  validationMessage: "",
@@ -4189,6 +4217,22 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
4189
4217
  }
4190
4218
  return value.length > 0 ? value : void 0;
4191
4219
  });
4220
+ const columnAttributes = computed(() => {
4221
+ if (__props.column.attributes && typeof __props.column.attributes === "function") {
4222
+ return __props.column.attributes(__props.row);
4223
+ } else {
4224
+ return __props.column.attributes;
4225
+ }
4226
+ });
4227
+ const configAttributes = computed(() => {
4228
+ let decimals = void 0;
4229
+ if (isColumnTypeNumber(__props.column)) {
4230
+ decimals = __props.column.decimals;
4231
+ }
4232
+ return inputFieldConfig[__props.column.type].attributes({
4233
+ decimals
4234
+ });
4235
+ });
4192
4236
  const tdElement = useTemplateRef("td");
4193
4237
  const inputElement = useTemplateRef("input");
4194
4238
  const penElement = useTemplateRef("pen");
@@ -4306,9 +4350,9 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
4306
4350
  const value = __props.column.value(__props.row);
4307
4351
  if (validity.value.isValid) {
4308
4352
  var _props$column$format;
4309
- return (_props$column$format = __props.column.formatter(value)) !== null && _props$column$format !== void 0 ? _props$column$format : value;
4353
+ return (_props$column$format = __props.column.formatter(value)) !== null && _props$column$format !== void 0 ? _props$column$format : value.toString();
4310
4354
  }
4311
- return value;
4355
+ return value.toString();
4312
4356
  }
4313
4357
  function toColumnValue(value) {
4314
4358
  assertRef(validity);
@@ -4426,18 +4470,22 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
4426
4470
  onKeydown
4427
4471
  }, [createElementVNode("div", {
4428
4472
  class: normalizeClass(divClasses.value)
4429
- }, [createElementVNode("span", _hoisted_2$2, toDisplayString(fromColumnValue()), 1), _cache[1] || (_cache[1] = createTextVNode()), viewModeErrorMessage.value ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(viewModeErrorMessage.value), 1)) : createCommentVNode("", true), _cache[2] || (_cache[2] = createTextVNode()), withDirectives(createElementVNode("input", {
4473
+ }, [createElementVNode("span", _hoisted_2$2, toDisplayString(fromColumnValue()), 1), _cache[1] || (_cache[1] = createTextVNode()), viewModeErrorMessage.value ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(viewModeErrorMessage.value), 1)) : createCommentVNode("", true), _cache[2] || (_cache[2] = createTextVNode()), withDirectives(createElementVNode("input", mergeProps({
4430
4474
  id: unref(inputId),
4431
4475
  ref: "input",
4432
4476
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => viewValue.value = $event),
4433
- class: normalizeClass(inputClasses.value),
4477
+ class: inputClasses.value,
4434
4478
  type: "text",
4435
4479
  maxlength: "40",
4436
4480
  tabindex: "-1",
4437
- "aria-label": ariaLabel.value,
4481
+ "aria-label": ariaLabel.value
4482
+ }, {
4483
+ ...configAttributes.value,
4484
+ ...columnAttributes.value
4485
+ }, {
4438
4486
  onValidity,
4439
4487
  onPendingValidity
4440
- }, null, 42, _hoisted_4$2), [[vModelText, viewValue.value]]), _cache[3] || (_cache[3] = createTextVNode()), createElementVNode("div", _hoisted_5$2, [createVNode(unref(FIcon), {
4488
+ }), null, 16, _hoisted_4$2), [[vModelText, viewValue.value]]), _cache[3] || (_cache[3] = createTextVNode()), createElementVNode("div", _hoisted_5$2, [createVNode(unref(FIcon), {
4441
4489
  name: "pen",
4442
4490
  class: "table-ng__editable__icon"
4443
4491
  })], 512)], 2), _cache[4] || (_cache[4] = createTextVNode()), createVNode(unref(IPopupError), {
@@ -4455,39 +4503,6 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
4455
4503
  };
4456
4504
  }
4457
4505
  });
4458
- function defaultTnumValue(type) {
4459
- const tnumTypes = ["text:bankAccountNumber", "text:bankgiro", "text:clearingNumber", "text:currency", "text:number", "text:organisationsnummer", "text:percent", "text:personnummer", "text:phoneNumber", "text:plusgiro", "text:postalCode"];
4460
- return tnumTypes.includes(type);
4461
- }
4462
- function getLabelFn(fn) {
4463
- if (fn) {
4464
- return fn;
4465
- }
4466
- return () => "";
4467
- }
4468
- function getUpdateFn(fn, key) {
4469
- if (fn) {
4470
- return fn;
4471
- }
4472
- if (key) {
4473
- return (row, value) => {
4474
- row[key] = value;
4475
- };
4476
- }
4477
- return () => void 0;
4478
- }
4479
- function getValueFn(fn, key, coerce, defaultValue) {
4480
- if (fn) {
4481
- return fn;
4482
- }
4483
- if (key) {
4484
- return (row) => {
4485
- var _row$key;
4486
- return coerce((_row$key = row[key]) !== null && _row$key !== void 0 ? _row$key : defaultValue);
4487
- };
4488
- }
4489
- return () => defaultValue;
4490
- }
4491
4506
  function normalizeAnchorColumn(column) {
4492
4507
  var _column$key;
4493
4508
  return {
@@ -4577,6 +4592,7 @@ function normalizeNumberColumn(column) {
4577
4592
  decimals,
4578
4593
  tnum: (_column$tnum = column.tnum) !== null && _column$tnum !== void 0 ? _column$tnum : defaultTnumValue(type),
4579
4594
  align: (_column$align = column.align) !== null && _column$align !== void 0 ? _column$align : "right",
4595
+ attributes: column.attributes,
4580
4596
  value: getValueFn(column.value, column.key, String, ""),
4581
4597
  update: getUpdateFn(column.update, column.key),
4582
4598
  editable: typeof column.editable === "function" ? column.editable : () => {
@@ -4658,6 +4674,7 @@ function normalizeTextColumn(column) {
4658
4674
  type,
4659
4675
  tnum: (_column$tnum = column.tnum) !== null && _column$tnum !== void 0 ? _column$tnum : defaultTnumValue(type),
4660
4676
  align: (_column$align = column.align) !== null && _column$align !== void 0 ? _column$align : "left",
4677
+ attributes: column.attributes,
4661
4678
  label: getLabelFn(column.label),
4662
4679
  value: getValueFn(column.value, column.key, String, ""),
4663
4680
  update: getUpdateFn(column.update, column.key),