@xy-planning-network/trees 0.10.3 → 0.10.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xy-planning-network/trees",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -45,33 +45,30 @@ const selectionCount = computed(() => {
45
45
  })
46
46
 
47
47
  const minCount = computed(() => {
48
- return props.min || 0
48
+ return props.min || null
49
49
  })
50
50
 
51
51
  const maxCount = computed(() => {
52
- return (
53
- props.max ||
54
- props.options.filter((opt) => {
55
- return !opt.disabled
56
- }).length
57
- )
52
+ return props.max || null
58
53
  })
59
54
 
60
55
  const countError = computed(() => {
61
56
  // min not reached, no max is set
62
- if (selectionCount.value < minCount.value && !props.max) {
57
+ if (minCount.value !== null && selectionCount.value < minCount.value) {
63
58
  return `Please select at least ${minCount.value} of these options.`
64
59
  }
65
60
 
66
61
  // max is reached, no min set
67
- if (selectionCount.value > maxCount.value && !props.min) {
62
+ if (maxCount.value !== null && selectionCount.value > maxCount.value) {
68
63
  return `Please limit your selection to ${maxCount.value} of these options.`
69
64
  }
70
65
 
71
- // min and max are both set and out of range
66
+ // min and max are both set and at least on of them is out of range
72
67
  if (
73
- selectionCount.value < minCount.value ||
74
- selectionCount.value > maxCount.value
68
+ minCount.value !== null &&
69
+ maxCount.value !== null &&
70
+ (selectionCount.value < minCount.value ||
71
+ selectionCount.value > maxCount.value)
75
72
  ) {
76
73
  return `Please select between ${minCount.value} and ${maxCount.value} of these options.`
77
74
  }
@@ -100,7 +97,7 @@ const setValidationError = () => {
100
97
  <FieldsetLegend
101
98
  :id="aria.labelledby"
102
99
  :label="label"
103
- :required="minCount > 0"
100
+ :required="minCount ? true : false"
104
101
  />
105
102
  <InputHelp
106
103
  v-if="help"
@@ -112,17 +109,6 @@ const setValidationError = () => {
112
109
  <InputError :id="aria.errormessage" class="mt-1" :text="errorState" />
113
110
  </div>
114
111
 
115
- <!--Hidden input for custom validation-->
116
- <input
117
- v-if="countError"
118
- ref="errorInput"
119
- required
120
- class="sr-only top-1 left-1"
121
- aria-hidden
122
- type="checkbox"
123
- @invalid="setValidationError"
124
- />
125
-
126
112
  <div class="flex">
127
113
  <div
128
114
  class="grid gap-y-5"
@@ -175,5 +161,15 @@ const setValidationError = () => {
175
161
  </div>
176
162
  </div>
177
163
  </div>
164
+ <!--Hidden input for custom validation-->
165
+ <input
166
+ v-if="countError"
167
+ ref="errorInput"
168
+ required
169
+ class="sr-only top-1 left-1"
170
+ aria-hidden
171
+ type="checkbox"
172
+ @invalid="setValidationError"
173
+ />
178
174
  </fieldset>
179
175
  </template>
@@ -10,9 +10,11 @@ import {
10
10
  withDefaults(
11
11
  defineProps<{
12
12
  modelValue: boolean
13
+ btnText?: string
13
14
  title?: string
14
15
  }>(),
15
16
  {
17
+ btnText: "Go back",
16
18
  title: "",
17
19
  }
18
20
  )
@@ -84,7 +86,7 @@ const updateModelValue = (value: boolean) => {
84
86
  class="inline-flex justify-center w-full xy-btn"
85
87
  @click="updateModelValue(false)"
86
88
  >
87
- Go back
89
+ {{ btnText }}
88
90
  </button>
89
91
  </div>
90
92
  </div>
@@ -40,8 +40,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
40
40
  "onClick:secondary"?: ((e: Event) => any) | undefined;
41
41
  }, {
42
42
  title: string;
43
- btnLink: string;
44
43
  btnText: string;
44
+ btnLink: string;
45
45
  dismissable: boolean;
46
46
  secondaryBtnLink: string;
47
47
  secondaryBtnText: string;
@@ -1,19 +1,24 @@
1
1
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
2
2
  modelValue: boolean;
3
+ btnText?: string | undefined;
3
4
  title?: string | undefined;
4
5
  }>, {
6
+ btnText: string;
5
7
  title: string;
6
8
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
9
  "update:modelValue": (val: boolean) => void;
8
10
  }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
9
11
  modelValue: boolean;
12
+ btnText?: string | undefined;
10
13
  title?: string | undefined;
11
14
  }>, {
15
+ btnText: string;
12
16
  title: string;
13
17
  }>>> & {
14
18
  "onUpdate:modelValue"?: ((val: boolean) => any) | undefined;
15
19
  }, {
16
20
  title: string;
21
+ btnText: string;
17
22
  }, {}>, {
18
23
  icon?(_: {}): any;
19
24
  default?(_: {}): any;