free-fe-core-modules 0.0.17 → 0.0.19

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.
@@ -0,0 +1,35 @@
1
+ import { watch, onMounted, nextTick, getCurrentInstance } from "vue";
2
+ import { useRoute } from 'vue-router';
3
+
4
+ export function useAnchor(opts) {
5
+ const { proxy:vm } = getCurrentInstance();
6
+ const route = useRoute();
7
+
8
+ const goToPageAnchor = (astr) => {
9
+ const anchorStr = astr || route.params.anchor || route.query.anchor;
10
+ if (anchorStr) {
11
+ const anchor = vm.$el.querySelector(`#${anchorStr}`);
12
+ if (anchor && anchor.scrollIntoView) {
13
+ nextTick(() => {
14
+ anchor.scrollIntoView({
15
+ behavior: 'smooth',
16
+ ...opts,
17
+ });
18
+ });
19
+ }
20
+ }
21
+ };
22
+
23
+ watch(() => route, () => {
24
+ goToPageAnchor();
25
+ });
26
+
27
+ onMounted(() => {
28
+ goToPageAnchor();
29
+ });
30
+
31
+ return {
32
+ goToPageAnchor,
33
+ }
34
+ };
35
+
@@ -43,6 +43,10 @@ export function useFormValidator(...list) {
43
43
  hasErr = !validFun() || hasErr;
44
44
 
45
45
  if (hasErr) {
46
+ if (refi.el?.className) {
47
+ refi.el.className += ' hasError';
48
+ }
49
+
46
50
  console.error('got error', args)
47
51
  break;
48
52
  }
@@ -2,6 +2,7 @@ import { ref, defineComponent, getCurrentInstance, h, computed } from 'vue';
2
2
  import { QInput, QIcon, QPopupProxy, QDate } from 'quasar';
3
3
  import { useFreeField, freeFieldProps } from '../composible/useFreeField';
4
4
  import freeFieldLabel from '../composible/freeFieldLabel';
5
+ import ReadonlyContent from '../composible/readonlyContent';
5
6
  import { useFormValidator} from '../../composible/useFormValidator';
6
7
 
7
8
  export default defineComponent({
@@ -43,7 +44,7 @@ export default defineComponent({
43
44
 
44
45
  const { proxy: vm } = getCurrentInstance();
45
46
 
46
- const { fieldData, setFieldData } = useFreeField(props);
47
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
47
48
 
48
49
  const before = (props.Field.Label !== void 0) ? () => h(freeFieldLabel, {
49
50
  Field: props.Field,
@@ -86,6 +87,9 @@ export default defineComponent({
86
87
 
87
88
  rules: props.Field.Rules,
88
89
 
90
+ ...inputControlSettings.value,
91
+
92
+ class: 'full-width',
89
93
  modelValue: localDate.value,
90
94
  'onUpdate:modelValue': (v) => {
91
95
  setFieldData(v, emit);
@@ -121,6 +125,11 @@ export default defineComponent({
121
125
  }),
122
126
  }));
123
127
 
128
+ const readonlyNode = () => h(ReadonlyContent, {
129
+ Field: props.Field,
130
+ Content: fieldData.value,
131
+ });
132
+
124
133
  const {
125
134
  validate,
126
135
  } = useFormValidator(DateNode);
@@ -43,7 +43,7 @@ export default defineComponent({
43
43
 
44
44
  const { proxy: vm } = getCurrentInstance();
45
45
 
46
- const { fieldData, setFieldData } = useFreeField(props);
46
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
47
47
 
48
48
  const updateFieldDate = () => {
49
49
  setFieldData([min.value, max.value].join(props.Field.Separator || '~'), emit);
@@ -125,6 +125,8 @@ export default defineComponent({
125
125
 
126
126
  rules: props.Field.Rules,
127
127
 
128
+ ...inputControlSettings.value,
129
+
128
130
  modelValue: min.value,
129
131
  'onUpdate:modelValue': (v) => {
130
132
  min.value = v;
@@ -170,6 +172,8 @@ export default defineComponent({
170
172
 
171
173
  rules: props.Field.Rules,
172
174
 
175
+ ...inputControlSettings.value,
176
+
173
177
  modelValue: max.value,
174
178
  'onUpdate:modelValue': (v) => {
175
179
  max.value = v;
@@ -89,6 +89,7 @@ export default defineComponent({
89
89
  ],
90
90
  Description: '',
91
91
  },
92
+ emits: ['input'],
92
93
  props: {
93
94
  ...freeFieldProps,
94
95
  },
@@ -96,7 +97,7 @@ export default defineComponent({
96
97
  setup(props, { emit, slots , expose }){
97
98
  if (!props.Field) return {};
98
99
 
99
- const { fieldData, setFieldData } = useFreeField(props);
100
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
100
101
 
101
102
  // keep between the min and max value
102
103
  watch(fieldData, (d) => {
@@ -140,6 +141,8 @@ export default defineComponent({
140
141
  hideBottomSpace: true,
141
142
  readonly: props.Field?.ReadOnly,
142
143
 
144
+ ...inputControlSettings.value,
145
+
143
146
  class: 'full-width',
144
147
  style: props.Field.Info?.Style,
145
148
 
@@ -15,7 +15,6 @@
15
15
  <span v-else class="row items-center no-wrap">
16
16
  <q-input
17
17
  :readonly="Field.ReadOnly"
18
- v-bind="$attrs"
19
18
  :placeholder="$attrs.placeholder || $t(getModule('field-components').config['defaultInputFieldPlaceholder'])"
20
19
  hide-bottom-space
21
20
  @input="rangeChanged"
@@ -23,6 +22,7 @@
23
22
  v-model.number="range.min"
24
23
  :ref="`input_field_validator_${Field.Name || Field.Label}`"
25
24
  :maxlength="maxlength"
25
+ v-bind="inputControlSettings"
26
26
  >
27
27
  <template
28
28
  v-slot:prepend
@@ -41,7 +41,6 @@
41
41
  <span class="free-field-range-separator">{{`${Field.Separator || '~'}`}}</span>
42
42
  <q-input
43
43
  :readonly="Field.ReadOnly"
44
- v-bind="$attrs"
45
44
  :placeholder="$attrs.placeholder || $t(getModule('field-components').config['defaultInputFieldPlaceholder'])"
46
45
  hide-bottom-space
47
46
  @input="rangeChanged"
@@ -49,6 +48,7 @@
49
48
  v-model.number="range.max"
50
49
  :ref="`input_field_validator_${Field.Name || Field.Label}2`"
51
50
  :maxlength="maxlength"
51
+ v-bind="inputControlSettings"
52
52
  >
53
53
  <template
54
54
  v-slot:prepend
@@ -71,14 +71,15 @@
71
71
  </template>
72
72
 
73
73
  <script>
74
- import { defineComponent } from 'vue';
75
- import { freeFieldProps } from '../composible/useFreeField';
74
+ import { defineComponent, ref } from 'vue';
75
+ import { freeFieldProps, useFreeField } from '../composible/useFreeField';
76
76
 
77
77
  export default defineComponent({
78
78
  name: 'InputFieldNumberRange',
79
79
  props: {
80
80
  ...freeFieldProps,
81
81
  },
82
+ emits: ['input'],
82
83
  fieldInfo: {
83
84
  Category: 'Simple',
84
85
  Label: '数字范围',
@@ -97,12 +98,19 @@ export default defineComponent({
97
98
  ],
98
99
  Description: '',
99
100
  },
100
- data() {
101
+ setup(props){
102
+ if (!props.Field) return {};
103
+
104
+ const { fieldData, inputControlSettings } = useFreeField(props);
105
+ const range = ref({
106
+ min: 0,
107
+ max: 0,
108
+ });
109
+
101
110
  return {
102
- range: {
103
- min: 0,
104
- max: 0,
105
- },
111
+ range,
112
+ fieldData,
113
+ inputControlSettings,
106
114
  };
107
115
  },
108
116
  watch: {
@@ -32,7 +32,7 @@ export default defineComponent({
32
32
  setup(props, { emit, slots, expose }){
33
33
  if (!props.Field) return {};
34
34
 
35
- const { fieldData, setFieldData } = useFreeField(props);
35
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
36
36
  const isPwd = ref(true);
37
37
 
38
38
  const before = () => h(freeFieldLabel, {
@@ -55,6 +55,8 @@ export default defineComponent({
55
55
  hideBottomSpace: true,
56
56
  readonly: props.Field?.ReadOnly,
57
57
 
58
+ ...inputControlSettings.value,
59
+
58
60
  class: 'full-width',
59
61
  style: props.Field.Info?.Style,
60
62
 
@@ -68,6 +68,7 @@ export default defineComponent({
68
68
  props: {
69
69
  ...freeFieldProps,
70
70
  },
71
+ emits: ['input'],
71
72
  setup(props, { expose, emit }) {
72
73
  if (!props.Field) return {};
73
74
 
@@ -109,6 +109,7 @@ export default defineComponent({
109
109
  components: {
110
110
  tiny,
111
111
  },
112
+ emits: ['input'],
112
113
  props: {
113
114
  ...freeFieldProps,
114
115
  enableField: { type: Boolean, default: false },
@@ -12,6 +12,7 @@
12
12
  ((Field.Options?.SearchPlaceholder) || Field.Placeholder)"
13
13
  @keydown.enter="search()"
14
14
  class="full-width"
15
+ v-bind="inputControlSettings"
15
16
  >
16
17
  <template v-slot:append>
17
18
  <q-btn :class="Field.Options?.SearchBtnClasses" :flat="!Field.Options?.SearchBtn3D" :round="!Field.Options?.SearchBtnRect" icon="search" @click="search()" :disabled="Field.ReadOnly">{{Field.Options.SearchBtnText}}</q-btn>
@@ -290,7 +291,7 @@ export default defineComponent({
290
291
  setup(props, { expose }) {
291
292
  if (!props.Field) return {};
292
293
 
293
- const { fieldData, setFieldData } = useFreeField(props);
294
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
294
295
 
295
296
  const { validate } = useFormValidator('fieldToValid');
296
297
  expose({
@@ -300,6 +301,7 @@ export default defineComponent({
300
301
  return {
301
302
  fieldData,
302
303
  setFieldData,
304
+ inputControlSettings,
303
305
  };
304
306
  },
305
307
  data() {
@@ -58,6 +58,8 @@
58
58
  ref="fieldToValid"
59
59
  :use-input="Field && Field.UseInput"
60
60
  :use-chip="Field && Field.UseChip"
61
+ v-bind="inputControlSettings"
62
+ :rules="Field.Rules"
61
63
  >
62
64
  <template v-slot:before>
63
65
  <span
@@ -246,7 +248,7 @@ export default defineComponent({
246
248
 
247
249
  const { proxy:vm } = getCurrentInstance();
248
250
 
249
- const { fieldData, getFieldData, setFieldData } = useFreeField(props);
251
+ const { fieldData, getFieldData, setFieldData, inputControlSettings } = useFreeField(props);
250
252
 
251
253
  const hasError = ref(false);
252
254
  const checked = ref([]);
@@ -296,21 +298,22 @@ export default defineComponent({
296
298
  });
297
299
 
298
300
  const selfValidate = () => {
299
- if (props.Field.AsCheck && props.Field.Required) {
300
- const isValid = checked.value && checked.value.length > 0;
301
- hasError.value = !isValid;
302
- return isValid;
303
- }
304
-
305
- return true;
301
+ const isValid = checked.value && checked.value.length > 0;
302
+ hasError.value = !isValid;
303
+ return isValid;
306
304
  };
307
305
 
308
306
  const { validate } = useFormValidator('fieldToValid');
309
307
  expose ({
310
- selfValidate,
311
308
  validate,
312
309
  })
313
310
 
311
+ if (props.Field.AsCheck && props.Field.Required) {
312
+ expose ({
313
+ selfValidate,
314
+ })
315
+ }
316
+
314
317
  const selectChanged = (v) => {
315
318
  selfValidate();
316
319
  setFieldData(v, emit);
@@ -391,6 +394,7 @@ export default defineComponent({
391
394
 
392
395
  selectChanged,
393
396
  checkChanged,
397
+ inputControlSettings,
394
398
  };
395
399
  },
396
400
  });
@@ -35,6 +35,7 @@
35
35
  emit-value
36
36
  @input="selectionChanged(index)"
37
37
  ref="fieldsToValid"
38
+ v-bind="inputControlSettings"
38
39
  ></q-select>
39
40
  </span>
40
41
  <span v-if="Field && Field.ReadOnly">
@@ -119,7 +120,7 @@ export default defineComponent({
119
120
 
120
121
  const { proxy:vm } = getCurrentInstance();
121
122
 
122
- const { fieldData, setFieldData } = useFreeField(props);
123
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
123
124
 
124
125
  const optionsList = ref([]);
125
126
  const valuesList = ref([]);
@@ -217,6 +218,7 @@ export default defineComponent({
217
218
  valuesList,
218
219
 
219
220
  selectionChanged,
221
+ inputControlSettings,
220
222
  };
221
223
  },
222
224
  created() {
@@ -63,7 +63,7 @@ export default defineComponent({
63
63
  if (!props.Field) return {};
64
64
 
65
65
  const { proxy:vm } = getCurrentInstance();
66
- const { fieldData, setFieldData } = useFreeField(props);
66
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
67
67
 
68
68
  const readonlyNode = () => h(ReadonlyContent, {
69
69
  Field: props.Field,
@@ -88,6 +88,9 @@ export default defineComponent({
88
88
  // bottomSlots: true,
89
89
  hideBottomSpace: true,
90
90
  readonly: props.Field?.ReadOnly,
91
+
92
+ ...inputControlSettings.value,
93
+
91
94
  placeholder: props.Field?.Placeholder || attrs.placeholder || vm.$t(vm.getModule('core-modules').config['defaultInputFieldPlaceholder']),
92
95
 
93
96
  class: 'full-width',
@@ -105,7 +108,7 @@ export default defineComponent({
105
108
  append,
106
109
  }));
107
110
 
108
- const { validate } = useFormValidator(inputNode);
111
+ const { validate } = useFormValidator(inputNode.value);
109
112
  expose({
110
113
  validate,
111
114
  })
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, ref, watchEffect, computed } from 'vue';
1
+ import { defineComponent, h, ref, watchEffect, computed, useAttrs } from 'vue';
2
2
  import { QInput } from 'quasar';
3
3
  import { useFreeField, freeFieldProps } from '../composible/useFreeField';
4
4
  import ReadonlyContent from '../composible/readonlyContent';
@@ -24,10 +24,10 @@ export default defineComponent({
24
24
  ...freeFieldProps,
25
25
  },
26
26
  emits: ['input'],
27
- setup(props, { emit, slots, expose }){
27
+ setup(props, { emit, slots, expose, attrs }){
28
28
  if (!props.Field) return {};
29
29
 
30
- const { fieldData, setFieldData } = useFreeField(props);
30
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
31
31
 
32
32
  const rows = ref(3);
33
33
 
@@ -53,6 +53,8 @@ export default defineComponent({
53
53
  readonly: props.Field?.ReadOnly,
54
54
  rows: rows.value,
55
55
 
56
+ ...inputControlSettings.value,
57
+
56
58
  class: 'full-width',
57
59
  style: props.Field.Info?.Style,
58
60
 
@@ -14,6 +14,7 @@
14
14
  <q-input v-else v-model="fieldData.value" hide-bottom-space
15
15
  :readonly="Field.ReadOnly"
16
16
  @input="$emit('input')"
17
+ v-bind="inputControlSettings"
17
18
  ref="fieldToValid">
18
19
  <template v-slot:before v-if="Field.Label !== void 0">
19
20
  <span
@@ -97,7 +98,7 @@ export default defineComponent({
97
98
 
98
99
  const { proxy:vm } = getCurrentInstance();
99
100
 
100
- const { fieldData, setFieldData } = useFreeField(props);
101
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
101
102
 
102
103
  const locale = vm.ctx.config.locales.find(
103
104
  (l) => l.locale === (vm.ctx.config.locale || vm.ctx.config.defaultLocale),
@@ -175,7 +176,8 @@ export default defineComponent({
175
176
 
176
177
  changed: (v) => {
177
178
  setFieldData(v, emit);
178
- }
179
+ },
180
+ inputControlSettings,
179
181
  };
180
182
  },
181
183
  });
@@ -27,6 +27,7 @@
27
27
  v-model="min"
28
28
  hide-bottom-space
29
29
  :readonly="Field.ReadOnly"
30
+ v-bind="inputControlSettings"
30
31
  ref="input_field_validator_first"
31
32
  >
32
33
  <q-popup-proxy
@@ -62,6 +63,7 @@
62
63
  v-model="max"
63
64
  hide-bottom-space
64
65
  :readonly="Field.ReadOnly"
66
+ v-bind="inputControlSettings"
65
67
  ref="input_field_validator_second"
66
68
  >
67
69
  <q-popup-proxy
@@ -161,7 +163,7 @@ export default defineComponent({
161
163
 
162
164
  const { proxy:vm } = getCurrentInstance();
163
165
 
164
- const { fieldData, setFieldData } = useFreeField(props);
166
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
165
167
 
166
168
  const updateFieldDate = () => {
167
169
  setFieldData([min.value, max.value].join(props.Field.Separator || '~'), emit);
@@ -364,7 +366,8 @@ export default defineComponent({
364
366
 
365
367
  changed: (v) => {
366
368
  setFieldData(v, emit);
367
- }
369
+ },
370
+ inputControlSettings,
368
371
  };
369
372
  },
370
373
  });
@@ -75,7 +75,7 @@ export default defineComponent({
75
75
  setup(props, { emit, slots, expose }){
76
76
  if (!props.Field) return {};
77
77
 
78
- const { fieldData, setFieldData } = useFreeField(props);
78
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
79
79
 
80
80
  const before = (props.Field.Label !== void 0) ? () => h(freeFieldLabel, {
81
81
  Field: props.Field,
@@ -111,6 +111,8 @@ export default defineComponent({
111
111
  'map-options': true,
112
112
  label: props.Field.Placeholder,
113
113
 
114
+ ...inputControlSettings.value,
115
+
114
116
  class: 'full-width',
115
117
  style: props.Field.Info?.Style,
116
118
 
@@ -19,6 +19,7 @@
19
19
  :options="minYearOptions"
20
20
  :readonly="Field.ReadOnly"
21
21
  @input="rangeChanged"
22
+ v-bind="inputControlSettings"
22
23
  ref="input_field_validator_first"
23
24
  >
24
25
  <template v-slot:before v-if="Field.Label !== void 0">
@@ -39,6 +40,7 @@
39
40
  :options="maxYearOptions"
40
41
  :readonly="Field.ReadOnly"
41
42
  @input="rangeChanged"
43
+ v-bind="inputControlSettings"
42
44
  ref="input_field_validator_second"
43
45
  />
44
46
  </span>
@@ -89,7 +91,7 @@ export default defineComponent({
89
91
  setup(props, { emit, expose }) {
90
92
  if (!props.Field) return () => null;
91
93
 
92
- const { fieldData, setFieldData } = useFreeField(props);
94
+ const { fieldData, setFieldData, inputControlSettings } = useFreeField(props);
93
95
 
94
96
  const min = ref('');
95
97
  const max = ref('');
@@ -175,6 +177,7 @@ export default defineComponent({
175
177
  maxYearOptions,
176
178
 
177
179
  rangeChanged,
180
+ inputControlSettings,
178
181
  };
179
182
  },
180
183
  });
@@ -49,7 +49,7 @@ export default defineComponent({
49
49
  lField.Rules.push(
50
50
  (val) => {
51
51
  const pVal = isRef(val) ? val.value : val;
52
- return typeof pVal !== "undefined" && pVal !== "";
52
+ return !!pVal;
53
53
  }
54
54
  );
55
55
  }
@@ -11,7 +11,7 @@ export default defineComponent({
11
11
  if (!props.Field) return {};
12
12
 
13
13
  const readonlyNode = () => h('span', {
14
- class: 'full-width',
14
+ class: 'full-width row no-wrap',
15
15
  }, [
16
16
  (props.Field.Label !== void 0) && h(FieldLabel, {
17
17
  Field: props.Field,
@@ -1,4 +1,4 @@
1
- import { reactive, getCurrentInstance, watchEffect } from "vue";
1
+ import { reactive, getCurrentInstance, watchEffect, computed } from "vue";
2
2
 
3
3
  export const freeFieldProps = {
4
4
  values: { type: Object },
@@ -12,11 +12,11 @@ export function useFreeField(props, ctx) {
12
12
  watchEffect(() => {
13
13
  let realData = void 0;
14
14
  let usingDft = false;
15
-
15
+
16
16
  if (!props.Field) {
17
17
  return;
18
18
  }
19
-
19
+
20
20
  if (!props.Field.Name) {
21
21
  realData = props.Field.Value || props.Field.Default || void 0;
22
22
  usingDft = true;
@@ -71,6 +71,10 @@ export function useFreeField(props, ctx) {
71
71
  fieldData.value = realData;
72
72
  });
73
73
 
74
+ const inputControlSettings = computed(() => {
75
+ return vm.ctx.config['core-modules']?.inputControlSettings || {};
76
+ });
77
+
74
78
  return {
75
79
  fieldData,
76
80
  getFieldData: (n) => Object.nestValue(props.values, n),
@@ -83,5 +87,6 @@ export function useFreeField(props, ctx) {
83
87
  setData: (n, v) => {
84
88
  Object.setValue(props.values, n, v);
85
89
  },
90
+ inputControlSettings,
86
91
  }
87
92
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-fe-core-modules",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/freeeis/free-fe-core-modules.git",
6
6
  "author": "zhiquan",