@fkui/vue-labs 6.36.0 → 6.37.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.
@@ -2708,13 +2708,12 @@ const inputFieldConfig = {
2708
2708
  personnummerFormat: {},
2709
2709
  personnummerLuhn: {}
2710
2710
  },
2711
- attributes: () => [{
2712
- name: "inputmode",
2713
- value: "numeric"
2714
- }, {
2715
- name: "maxlength",
2716
- value: "23"
2717
- }]
2711
+ attributes: () => {
2712
+ return {
2713
+ inputmode: "numeric",
2714
+ maxlength: "23"
2715
+ };
2716
+ }
2718
2717
  },
2719
2718
  "text:bankAccountNumber": {
2720
2719
  formatter(value) {
@@ -2726,13 +2725,12 @@ const inputFieldConfig = {
2726
2725
  validationConfig: {
2727
2726
  bankAccountNumber: {}
2728
2727
  },
2729
- attributes: () => [{
2730
- name: "inputmode",
2731
- value: "numeric"
2732
- }, {
2733
- name: "maxlength",
2734
- value: "40"
2735
- }]
2728
+ attributes: () => {
2729
+ return {
2730
+ inputmode: "numeric",
2731
+ maxlength: "40"
2732
+ };
2733
+ }
2736
2734
  },
2737
2735
  "text:bankgiro": {
2738
2736
  formatter(value) {
@@ -2747,13 +2745,12 @@ const inputFieldConfig = {
2747
2745
  },
2748
2746
  bankgiro: {}
2749
2747
  },
2750
- attributes: () => [{
2751
- name: "inputmode",
2752
- value: "numeric"
2753
- }, {
2754
- name: "maxlength",
2755
- value: "40"
2756
- }]
2748
+ attributes: () => {
2749
+ return {
2750
+ inputmode: "numeric",
2751
+ maxlength: "40"
2752
+ };
2753
+ }
2757
2754
  },
2758
2755
  "text:clearingNumber": {
2759
2756
  formatter(value) {
@@ -2765,13 +2762,12 @@ const inputFieldConfig = {
2765
2762
  validationConfig: {
2766
2763
  clearingNumber: {}
2767
2764
  },
2768
- attributes: () => [{
2769
- name: "inputmode",
2770
- value: "numeric"
2771
- }, {
2772
- name: "maxlength",
2773
- value: "16"
2774
- }]
2765
+ attributes: () => {
2766
+ return {
2767
+ inputmode: "numeric",
2768
+ maxlength: "16"
2769
+ };
2770
+ }
2775
2771
  },
2776
2772
  "text:currency": {
2777
2773
  formatter(value) {
@@ -2784,13 +2780,12 @@ const inputFieldConfig = {
2784
2780
  currency: {},
2785
2781
  integer: {}
2786
2782
  },
2787
- attributes: () => [{
2788
- name: "inputmode",
2789
- value: "numeric"
2790
- }, {
2791
- name: "maxlength",
2792
- value: "20"
2793
- }]
2783
+ attributes: () => {
2784
+ return {
2785
+ inputmode: "numeric",
2786
+ maxlength: "20"
2787
+ };
2788
+ }
2794
2789
  },
2795
2790
  "text:date": {
2796
2791
  formatter(value) {
@@ -2802,10 +2797,11 @@ const inputFieldConfig = {
2802
2797
  validationConfig: {
2803
2798
  date: {}
2804
2799
  },
2805
- attributes: () => [{
2806
- name: "type",
2807
- value: "text"
2808
- }]
2800
+ attributes: () => {
2801
+ return {
2802
+ type: "text"
2803
+ };
2804
+ }
2809
2805
  },
2810
2806
  "text:email": {
2811
2807
  formatter(value) {
@@ -2820,13 +2816,12 @@ const inputFieldConfig = {
2820
2816
  length: 80
2821
2817
  }
2822
2818
  },
2823
- attributes: () => [{
2824
- name: "type",
2825
- value: "email"
2826
- }, {
2827
- name: "maxlength",
2828
- value: "80"
2829
- }]
2819
+ attributes: () => {
2820
+ return {
2821
+ type: "email",
2822
+ maxlength: "80"
2823
+ };
2824
+ }
2830
2825
  },
2831
2826
  "text:number": {
2832
2827
  formatter(value) {
@@ -2840,13 +2835,12 @@ const inputFieldConfig = {
2840
2835
  validationConfig: {
2841
2836
  number: {}
2842
2837
  },
2843
- attributes: () => [{
2844
- name: "inputmode",
2845
- value: "numeric"
2846
- }, {
2847
- name: "maxlength",
2848
- value: "20"
2849
- }]
2838
+ attributes: () => {
2839
+ return {
2840
+ inputmode: "numeric",
2841
+ maxlength: "20"
2842
+ };
2843
+ }
2850
2844
  },
2851
2845
  "text:organisationsnummer": {
2852
2846
  formatter(value) {
@@ -2861,13 +2855,12 @@ const inputFieldConfig = {
2861
2855
  },
2862
2856
  organisationsnummer: {}
2863
2857
  },
2864
- attributes: () => [{
2865
- name: "inputmode",
2866
- value: "numeric"
2867
- }, {
2868
- name: "maxlength",
2869
- value: "20"
2870
- }]
2858
+ attributes: () => {
2859
+ return {
2860
+ inputmode: "numeric",
2861
+ maxlength: "20"
2862
+ };
2863
+ }
2871
2864
  },
2872
2865
  "text:percent": {
2873
2866
  formatter(value) {
@@ -2887,14 +2880,12 @@ const inputFieldConfig = {
2887
2880
  maxValue: 999
2888
2881
  }
2889
2882
  },
2890
- attributes: (decimals) => {
2891
- return [{
2892
- name: "inputmode",
2893
- value: decimals ? "decimal" : "numeric"
2894
- }, {
2895
- name: "maxlength",
2896
- value: "10"
2897
- }];
2883
+ attributes: (options) => {
2884
+ const decimals = options?.decimals;
2885
+ return {
2886
+ inputmode: decimals ? "decimal" : "numeric",
2887
+ maxlength: "10"
2888
+ };
2898
2889
  }
2899
2890
  },
2900
2891
  "text:phoneNumber": {
@@ -2910,13 +2901,12 @@ const inputFieldConfig = {
2910
2901
  },
2911
2902
  phoneNumber: {}
2912
2903
  },
2913
- attributes: () => [{
2914
- name: "maxlength",
2915
- value: "80"
2916
- }, {
2917
- name: "type",
2918
- value: "tel"
2919
- }]
2904
+ attributes: () => {
2905
+ return {
2906
+ maxlength: "80",
2907
+ type: "tel"
2908
+ };
2909
+ }
2920
2910
  },
2921
2911
  "text:plusgiro": {
2922
2912
  formatter(value) {
@@ -2931,13 +2921,12 @@ const inputFieldConfig = {
2931
2921
  },
2932
2922
  plusgiro: {}
2933
2923
  },
2934
- attributes: () => [{
2935
- name: "inputmode",
2936
- value: "numeric"
2937
- }, {
2938
- name: "maxlength",
2939
- value: "16"
2940
- }]
2924
+ attributes: () => {
2925
+ return {
2926
+ inputmode: "numeric",
2927
+ maxlength: "16"
2928
+ };
2929
+ }
2941
2930
  },
2942
2931
  "text:postalCode": {
2943
2932
  formatter(value) {
@@ -2952,13 +2941,12 @@ const inputFieldConfig = {
2952
2941
  },
2953
2942
  postalCode: {}
2954
2943
  },
2955
- attributes: () => [{
2956
- name: "inputmode",
2957
- value: "numeric"
2958
- }, {
2959
- name: "maxlength",
2960
- value: "15"
2961
- }]
2944
+ attributes: () => {
2945
+ return {
2946
+ inputmode: "numeric",
2947
+ maxlength: "15"
2948
+ };
2949
+ }
2962
2950
  },
2963
2951
  text: {
2964
2952
  formatter(value) {
@@ -2968,7 +2956,9 @@ const inputFieldConfig = {
2968
2956
  return value;
2969
2957
  },
2970
2958
  validationConfig: {},
2971
- attributes: () => []
2959
+ attributes: () => {
2960
+ return {};
2961
+ }
2972
2962
  }
2973
2963
  };
2974
2964
  const _hoisted_1$c = ["aria-sort"];
@@ -3854,6 +3844,14 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
3854
3844
  function onClose() {
3855
3845
  isOpen.value = false;
3856
3846
  }
3847
+ function onFocusout(event) {
3848
+ const validTarget = event.relatedTarget && event.relatedTarget instanceof HTMLElement;
3849
+ const inPopup = validTarget && Boolean(event.relatedTarget.closest(".popup"));
3850
+ if (inPopup) {
3851
+ return;
3852
+ }
3853
+ isOpen.value = false;
3854
+ }
3857
3855
  function onSelect(key) {
3858
3856
  const action = actions.value.find((it) => it.key === key);
3859
3857
  action?.onClick(__props.row);
@@ -3875,7 +3873,8 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
3875
3873
  items: menuitems.value,
3876
3874
  anchor: (_buttonRef$value = buttonRef.value) !== null && _buttonRef$value !== void 0 ? _buttonRef$value : void 0,
3877
3875
  onClose,
3878
- onSelect
3876
+ onSelect,
3877
+ onFocusout
3879
3878
  }, null, 8, ["is-open", "items", "anchor"])])) : (vue.openBlock(), vue.createElementBlock("td", _hoisted_3$4));
3880
3879
  };
3881
3880
  }
@@ -4094,16 +4093,45 @@ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
4094
4093
  };
4095
4094
  }
4096
4095
  });
4097
- function addInputValidators(inputElement, type, decimals) {
4098
- logic.ValidationService.addValidatorsToElement(inputElement, inputFieldConfig[type].validationConfig, true);
4099
- const options = void 0;
4100
- const attributes = inputFieldConfig[type].attributes(options);
4101
- for (const {
4102
- name,
4103
- value
4104
- } of attributes) {
4105
- inputElement.setAttribute(name, value);
4096
+ function defaultTnumValue(type) {
4097
+ const tnumTypes = ["text:bankAccountNumber", "text:bankgiro", "text:clearingNumber", "text:currency", "text:number", "text:organisationsnummer", "text:percent", "text:personnummer", "text:phoneNumber", "text:plusgiro", "text:postalCode"];
4098
+ return tnumTypes.includes(type);
4099
+ }
4100
+ function getLabelFn(fn) {
4101
+ if (fn) {
4102
+ return fn;
4106
4103
  }
4104
+ return () => "";
4105
+ }
4106
+ function getUpdateFn(fn, key) {
4107
+ if (fn) {
4108
+ return fn;
4109
+ }
4110
+ if (key) {
4111
+ return (row, value) => {
4112
+ row[key] = value;
4113
+ };
4114
+ }
4115
+ return () => void 0;
4116
+ }
4117
+ function getValueFn(fn, key, coerce, defaultValue) {
4118
+ if (fn) {
4119
+ return fn;
4120
+ }
4121
+ if (key) {
4122
+ return (row) => {
4123
+ var _row$key;
4124
+ return coerce((_row$key = row[key]) !== null && _row$key !== void 0 ? _row$key : defaultValue);
4125
+ };
4126
+ }
4127
+ return () => defaultValue;
4128
+ }
4129
+ function isColumnTypeNumber(column) {
4130
+ const type = column.type;
4131
+ return numberTypes.includes(type);
4132
+ }
4133
+ function addInputValidators(inputElement, type) {
4134
+ logic.ValidationService.addValidatorsToElement(inputElement, inputFieldConfig[type].validationConfig, true);
4107
4135
  }
4108
4136
  function isAlphanumeric(e) {
4109
4137
  return e.key.length === 1 && !e.ctrlKey && !e.metaKey;
@@ -4136,8 +4164,8 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
4136
4164
  const emit = __emit;
4137
4165
  const viewValue = vue.ref("");
4138
4166
  const inEdit = vue.ref(false);
4139
- const cellId = vue.useId();
4140
- const inputId = vue.useId();
4167
+ const cellId = logic.ElementIdService.generateElementId();
4168
+ const inputId = logic.ElementIdService.generateElementId();
4141
4169
  const validity = vue.ref({
4142
4170
  isValid: true,
4143
4171
  validationMessage: "",
@@ -4191,6 +4219,22 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
4191
4219
  }
4192
4220
  return value.length > 0 ? value : void 0;
4193
4221
  });
4222
+ const columnAttributes = vue.computed(() => {
4223
+ if (__props.column.attributes && typeof __props.column.attributes === "function") {
4224
+ return __props.column.attributes(__props.row);
4225
+ } else {
4226
+ return __props.column.attributes;
4227
+ }
4228
+ });
4229
+ const configAttributes = vue.computed(() => {
4230
+ let decimals = void 0;
4231
+ if (isColumnTypeNumber(__props.column)) {
4232
+ decimals = __props.column.decimals;
4233
+ }
4234
+ return inputFieldConfig[__props.column.type].attributes({
4235
+ decimals
4236
+ });
4237
+ });
4194
4238
  const tdElement = vue.useTemplateRef("td");
4195
4239
  const inputElement = vue.useTemplateRef("input");
4196
4240
  const penElement = vue.useTemplateRef("pen");
@@ -4308,9 +4352,9 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
4308
4352
  const value = __props.column.value(__props.row);
4309
4353
  if (validity.value.isValid) {
4310
4354
  var _props$column$format;
4311
- return (_props$column$format = __props.column.formatter(value)) !== null && _props$column$format !== void 0 ? _props$column$format : value;
4355
+ return (_props$column$format = __props.column.formatter(value)) !== null && _props$column$format !== void 0 ? _props$column$format : value.toString();
4312
4356
  }
4313
- return value;
4357
+ return value.toString();
4314
4358
  }
4315
4359
  function toColumnValue(value) {
4316
4360
  logic.assertRef(validity);
@@ -4428,18 +4472,22 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
4428
4472
  onKeydown
4429
4473
  }, [vue.createElementVNode("div", {
4430
4474
  class: vue.normalizeClass(divClasses.value)
4431
- }, [vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(fromColumnValue()), 1), _cache[1] || (_cache[1] = vue.createTextVNode()), viewModeErrorMessage.value ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_3$2, vue.toDisplayString(viewModeErrorMessage.value), 1)) : vue.createCommentVNode("", true), _cache[2] || (_cache[2] = vue.createTextVNode()), vue.withDirectives(vue.createElementVNode("input", {
4475
+ }, [vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(fromColumnValue()), 1), _cache[1] || (_cache[1] = vue.createTextVNode()), viewModeErrorMessage.value ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_3$2, vue.toDisplayString(viewModeErrorMessage.value), 1)) : vue.createCommentVNode("", true), _cache[2] || (_cache[2] = vue.createTextVNode()), vue.withDirectives(vue.createElementVNode("input", vue.mergeProps({
4432
4476
  id: vue.unref(inputId),
4433
4477
  ref: "input",
4434
4478
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => viewValue.value = $event),
4435
- class: vue.normalizeClass(inputClasses.value),
4479
+ class: inputClasses.value,
4436
4480
  type: "text",
4437
4481
  maxlength: "40",
4438
4482
  tabindex: "-1",
4439
- "aria-label": ariaLabel.value,
4483
+ "aria-label": ariaLabel.value
4484
+ }, {
4485
+ ...configAttributes.value,
4486
+ ...columnAttributes.value
4487
+ }, {
4440
4488
  onValidity,
4441
4489
  onPendingValidity
4442
- }, null, 42, _hoisted_4$2), [[vue.vModelText, viewValue.value]]), _cache[3] || (_cache[3] = vue.createTextVNode()), vue.createElementVNode("div", _hoisted_5$2, [vue.createVNode(vue.unref(vue$1.FIcon), {
4490
+ }), null, 16, _hoisted_4$2), [[vue.vModelText, viewValue.value]]), _cache[3] || (_cache[3] = vue.createTextVNode()), vue.createElementVNode("div", _hoisted_5$2, [vue.createVNode(vue.unref(vue$1.FIcon), {
4443
4491
  name: "pen",
4444
4492
  class: "table-ng__editable__icon"
4445
4493
  })], 512)], 2), _cache[4] || (_cache[4] = vue.createTextVNode()), vue.createVNode(vue.unref(vue$1.IPopupError), {
@@ -4457,39 +4505,6 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
4457
4505
  };
4458
4506
  }
4459
4507
  });
4460
- function defaultTnumValue(type) {
4461
- const tnumTypes = ["text:bankAccountNumber", "text:bankgiro", "text:clearingNumber", "text:currency", "text:number", "text:organisationsnummer", "text:percent", "text:personnummer", "text:phoneNumber", "text:plusgiro", "text:postalCode"];
4462
- return tnumTypes.includes(type);
4463
- }
4464
- function getLabelFn(fn) {
4465
- if (fn) {
4466
- return fn;
4467
- }
4468
- return () => "";
4469
- }
4470
- function getUpdateFn(fn, key) {
4471
- if (fn) {
4472
- return fn;
4473
- }
4474
- if (key) {
4475
- return (row, value) => {
4476
- row[key] = value;
4477
- };
4478
- }
4479
- return () => void 0;
4480
- }
4481
- function getValueFn(fn, key, coerce, defaultValue) {
4482
- if (fn) {
4483
- return fn;
4484
- }
4485
- if (key) {
4486
- return (row) => {
4487
- var _row$key;
4488
- return coerce((_row$key = row[key]) !== null && _row$key !== void 0 ? _row$key : defaultValue);
4489
- };
4490
- }
4491
- return () => defaultValue;
4492
- }
4493
4508
  function normalizeAnchorColumn(column) {
4494
4509
  var _column$key;
4495
4510
  return {
@@ -4579,6 +4594,7 @@ function normalizeNumberColumn(column) {
4579
4594
  decimals,
4580
4595
  tnum: (_column$tnum = column.tnum) !== null && _column$tnum !== void 0 ? _column$tnum : defaultTnumValue(type),
4581
4596
  align: (_column$align = column.align) !== null && _column$align !== void 0 ? _column$align : "right",
4597
+ attributes: column.attributes,
4582
4598
  value: getValueFn(column.value, column.key, String, ""),
4583
4599
  update: getUpdateFn(column.update, column.key),
4584
4600
  editable: typeof column.editable === "function" ? column.editable : () => {
@@ -4660,6 +4676,7 @@ function normalizeTextColumn(column) {
4660
4676
  type,
4661
4677
  tnum: (_column$tnum = column.tnum) !== null && _column$tnum !== void 0 ? _column$tnum : defaultTnumValue(type),
4662
4678
  align: (_column$align = column.align) !== null && _column$align !== void 0 ? _column$align : "left",
4679
+ attributes: column.attributes,
4663
4680
  label: getLabelFn(column.label),
4664
4681
  value: getValueFn(column.value, column.key, String, ""),
4665
4682
  update: getUpdateFn(column.update, column.key),