@onereach/ui-components 2.70.1 → 2.70.2-beta.2199.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.
Files changed (185) hide show
  1. package/dist/bundled/v2/{OrCardCollection-0141a358.js → OrCardCollection-1bb83cfb.js} +1 -1
  2. package/dist/bundled/v2/{OrCheckbox-dbef9f9a.js → OrCheckbox-251ecafc.js} +32 -17
  3. package/dist/bundled/v2/{OrConfirm-23c3ce56.js → OrConfirm-4cae7867.js} +1 -1
  4. package/dist/bundled/v2/{OrInlineInput-87589946.js → OrInlineInput-2133e469.js} +38 -22
  5. package/dist/bundled/v2/{OrInlineTextarea-21b0e6fc.js → OrInlineTextarea-d61ca596.js} +34 -18
  6. package/dist/bundled/v2/{OrInput-82ccfe00.js → OrInput-770f1bed.js} +38 -30
  7. package/dist/bundled/v2/{OrPagination-379c10b8.js → OrPagination-468d0964.js} +1 -1
  8. package/dist/bundled/v2/{OrRadio-cd39b20b.js → OrRadio-ae89bc9b.js} +30 -15
  9. package/dist/bundled/v2/{OrSearch-53470b0e.js → OrSearch-2e5f9e24.js} +1 -1
  10. package/dist/bundled/v2/{OrSelect-c49e1bcf.js → OrSelect-039c0711.js} +2 -2
  11. package/dist/bundled/v2/{OrSwitch-237a2081.js → OrSwitch-20640a05.js} +30 -15
  12. package/dist/bundled/v2/{OrTabs-42f7c52c.js → OrTabs-85aefcba.js} +1 -1
  13. package/dist/bundled/v2/{OrTextarea-5593fbe9.js → OrTextarea-0ff8063b.js} +39 -20
  14. package/dist/bundled/v2/components/index.js +15 -13
  15. package/dist/bundled/v2/components/or-card-collection-v3/index.js +5 -3
  16. package/dist/bundled/v2/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -2
  17. package/dist/bundled/v2/components/or-checkbox-v3/index.js +2 -1
  18. package/dist/bundled/v2/components/or-confirm-v3/index.js +4 -2
  19. package/dist/bundled/v2/components/or-inline-input-v3/OrInlineInput.vue.d.ts +36 -6
  20. package/dist/bundled/v2/components/or-inline-input-v3/index.js +3 -1
  21. package/dist/bundled/v2/components/or-inline-textarea-v3/OrInlineTextarea.vue.d.ts +36 -6
  22. package/dist/bundled/v2/components/or-inline-textarea-v3/index.js +3 -1
  23. package/dist/bundled/v2/components/or-input-v3/OrInput.vue.d.ts +43 -8
  24. package/dist/bundled/v2/components/or-input-v3/index.js +3 -1
  25. package/dist/bundled/v2/components/or-pagination-v3/index.js +1 -1
  26. package/dist/bundled/v2/components/or-radio-v3/OrRadio.vue.d.ts +18 -2
  27. package/dist/bundled/v2/components/or-radio-v3/index.js +2 -1
  28. package/dist/bundled/v2/components/or-search-v3/index.js +4 -2
  29. package/dist/bundled/v2/components/or-select-v3/index.js +5 -3
  30. package/dist/bundled/v2/components/or-switch-v3/OrSwitch.vue.d.ts +18 -2
  31. package/dist/bundled/v2/components/or-switch-v3/index.js +2 -1
  32. package/dist/bundled/v2/components/or-tabs-v3/index.js +1 -1
  33. package/dist/bundled/v2/components/or-textarea-v3/OrTextarea.vue.d.ts +45 -6
  34. package/dist/bundled/v2/components/or-textarea-v3/index.js +3 -1
  35. package/dist/bundled/v2/hooks/index.d.ts +3 -0
  36. package/dist/bundled/v2/hooks/index.js +2 -0
  37. package/dist/bundled/v2/hooks/useControlAttributes.d.ts +8 -0
  38. package/dist/bundled/v2/hooks/useIdAttribute.d.ts +2 -0
  39. package/dist/bundled/v2/hooks/useValidationAttributes.d.ts +12 -0
  40. package/dist/bundled/v2/index.js +15 -13
  41. package/dist/bundled/v2/useIdAttribute-cf61643f.js +22 -0
  42. package/dist/bundled/v2/useValidationAttributes-6df7bcf9.js +17 -0
  43. package/dist/bundled/v3/{OrCardCollection.vue_vue_type_script_lang-2d78a51a.js → OrCardCollection.vue_vue_type_script_lang-a0f29a55.js} +1 -1
  44. package/dist/bundled/v3/{OrCheckbox.vue_vue_type_script_lang-8b36e06c.js → OrCheckbox.vue_vue_type_script_lang-2024ec32.js} +22 -7
  45. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-05b21989.js → OrConfirm.vue_vue_type_script_lang-7d9d3810.js} +2 -2
  46. package/dist/bundled/v3/{OrInlineInput.vue_vue_type_script_lang-67218502.js → OrInlineInput.vue_vue_type_script_lang-40f0073f.js} +27 -11
  47. package/dist/bundled/v3/{OrInlineTextarea.vue_vue_type_script_lang-a1831ab8.js → OrInlineTextarea.vue_vue_type_script_lang-2817edd5.js} +27 -11
  48. package/dist/bundled/v3/{OrInput-a4f220ed.js → OrInput-e325a104.js} +12 -12
  49. package/dist/bundled/v3/{OrInput.vue_vue_type_script_lang-607d79d4.js → OrInput.vue_vue_type_script_lang-fd850b82.js} +26 -15
  50. package/dist/bundled/v3/{OrPagination.vue_vue_type_script_lang-c96d7cd7.js → OrPagination.vue_vue_type_script_lang-0d9daaa7.js} +1 -1
  51. package/dist/bundled/v3/{OrRadio.vue_vue_type_script_lang-2e666a56.js → OrRadio.vue_vue_type_script_lang-29e8b856.js} +22 -7
  52. package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-06f318ca.js → OrSearch.vue_vue_type_script_lang-480f4b1c.js} +2 -2
  53. package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-58e5a52b.js → OrSelect.vue_vue_type_script_lang-7aa8956a.js} +17 -15
  54. package/dist/bundled/v3/{OrSwitch.vue_vue_type_script_lang-04829f64.js → OrSwitch.vue_vue_type_script_lang-02b4913a.js} +22 -7
  55. package/dist/bundled/v3/{OrTabs.vue_vue_type_script_lang-61b79a5a.js → OrTabs.vue_vue_type_script_lang-01188224.js} +1 -1
  56. package/dist/bundled/v3/{OrTextarea.vue_vue_type_script_lang-8e3531cd.js → OrTextarea.vue_vue_type_script_lang-2fdac7b2.js} +31 -12
  57. package/dist/bundled/v3/components/index.js +16 -14
  58. package/dist/bundled/v3/components/or-card-collection-v3/index.js +6 -4
  59. package/dist/bundled/v3/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -2
  60. package/dist/bundled/v3/components/or-checkbox-v3/index.js +2 -1
  61. package/dist/bundled/v3/components/or-confirm-v3/index.js +5 -3
  62. package/dist/bundled/v3/components/or-inline-input-v3/OrInlineInput.vue.d.ts +36 -6
  63. package/dist/bundled/v3/components/or-inline-input-v3/index.js +3 -1
  64. package/dist/bundled/v3/components/or-inline-textarea-v3/OrInlineTextarea.vue.d.ts +36 -6
  65. package/dist/bundled/v3/components/or-inline-textarea-v3/index.js +3 -1
  66. package/dist/bundled/v3/components/or-input-v3/OrInput.vue.d.ts +43 -8
  67. package/dist/bundled/v3/components/or-input-v3/index.js +3 -1
  68. package/dist/bundled/v3/components/or-pagination-v3/index.js +1 -1
  69. package/dist/bundled/v3/components/or-radio-v3/OrRadio.vue.d.ts +18 -2
  70. package/dist/bundled/v3/components/or-radio-v3/index.js +2 -1
  71. package/dist/bundled/v3/components/or-search-v3/index.js +5 -3
  72. package/dist/bundled/v3/components/or-select-v3/index.js +6 -4
  73. package/dist/bundled/v3/components/or-switch-v3/OrSwitch.vue.d.ts +18 -2
  74. package/dist/bundled/v3/components/or-switch-v3/index.js +2 -1
  75. package/dist/bundled/v3/components/or-tabs-v3/index.js +1 -1
  76. package/dist/bundled/v3/components/or-textarea-v3/OrTextarea.vue.d.ts +45 -6
  77. package/dist/bundled/v3/components/or-textarea-v3/index.js +3 -1
  78. package/dist/bundled/v3/hooks/index.d.ts +3 -0
  79. package/dist/bundled/v3/hooks/index.js +2 -0
  80. package/dist/bundled/v3/hooks/useControlAttributes.d.ts +8 -0
  81. package/dist/bundled/v3/hooks/useIdAttribute.d.ts +2 -0
  82. package/dist/bundled/v3/hooks/useValidationAttributes.d.ts +12 -0
  83. package/dist/bundled/v3/index.js +76 -68
  84. package/dist/bundled/v3/useIdAttribute-b2e42f31.js +21 -0
  85. package/dist/bundled/v3/useValidationAttributes-5428d8fa.js +16 -0
  86. package/dist/esm/v2/{OrCardCollection-3c38fc85.js → OrCardCollection-784318ac.js} +1 -1
  87. package/dist/esm/v2/{OrCheckbox-567e387c.js → OrCheckbox-7317fe1a.js} +32 -17
  88. package/dist/esm/v2/{OrConfirm-e2ab9b4c.js → OrConfirm-3d064f6c.js} +1 -1
  89. package/dist/esm/v2/{OrInlineInput-10205811.js → OrInlineInput-7c4f1f92.js} +38 -22
  90. package/dist/esm/v2/{OrInlineTextarea-7658611e.js → OrInlineTextarea-3381e2a9.js} +34 -18
  91. package/dist/esm/v2/{OrInput-ada3a970.js → OrInput-e10cc643.js} +38 -30
  92. package/dist/esm/v2/{OrPagination-c0dbec6a.js → OrPagination-291bd1b9.js} +1 -1
  93. package/dist/esm/v2/{OrRadio-848ce55d.js → OrRadio-b0a560d2.js} +30 -15
  94. package/dist/esm/v2/{OrSearch-0f08f2f5.js → OrSearch-1490c00b.js} +1 -1
  95. package/dist/esm/v2/{OrSelect-1d705445.js → OrSelect-1fbeed4f.js} +2 -2
  96. package/dist/esm/v2/{OrSwitch-13b6a7ee.js → OrSwitch-133052ca.js} +30 -15
  97. package/dist/esm/v2/{OrTabs-71bd3fd2.js → OrTabs-e5b81f4b.js} +1 -1
  98. package/dist/esm/v2/{OrTextarea-6712a150.js → OrTextarea-a7c846da.js} +39 -20
  99. package/dist/esm/v2/components/index.js +15 -13
  100. package/dist/esm/v2/components/or-card-collection-v3/index.js +5 -3
  101. package/dist/esm/v2/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -2
  102. package/dist/esm/v2/components/or-checkbox-v3/index.js +2 -1
  103. package/dist/esm/v2/components/or-confirm-v3/index.js +4 -2
  104. package/dist/esm/v2/components/or-inline-input-v3/OrInlineInput.vue.d.ts +36 -6
  105. package/dist/esm/v2/components/or-inline-input-v3/index.js +3 -1
  106. package/dist/esm/v2/components/or-inline-textarea-v3/OrInlineTextarea.vue.d.ts +36 -6
  107. package/dist/esm/v2/components/or-inline-textarea-v3/index.js +3 -1
  108. package/dist/esm/v2/components/or-input-v3/OrInput.vue.d.ts +43 -8
  109. package/dist/esm/v2/components/or-input-v3/index.js +3 -1
  110. package/dist/esm/v2/components/or-pagination-v3/index.js +1 -1
  111. package/dist/esm/v2/components/or-radio-v3/OrRadio.vue.d.ts +18 -2
  112. package/dist/esm/v2/components/or-radio-v3/index.js +2 -1
  113. package/dist/esm/v2/components/or-search-v3/index.js +4 -2
  114. package/dist/esm/v2/components/or-select-v3/index.js +5 -3
  115. package/dist/esm/v2/components/or-switch-v3/OrSwitch.vue.d.ts +18 -2
  116. package/dist/esm/v2/components/or-switch-v3/index.js +2 -1
  117. package/dist/esm/v2/components/or-tabs-v3/index.js +1 -1
  118. package/dist/esm/v2/components/or-textarea-v3/OrTextarea.vue.d.ts +45 -6
  119. package/dist/esm/v2/components/or-textarea-v3/index.js +3 -1
  120. package/dist/esm/v2/hooks/index.d.ts +3 -0
  121. package/dist/esm/v2/hooks/index.js +2 -0
  122. package/dist/esm/v2/hooks/useControlAttributes.d.ts +8 -0
  123. package/dist/esm/v2/hooks/useIdAttribute.d.ts +2 -0
  124. package/dist/esm/v2/hooks/useValidationAttributes.d.ts +12 -0
  125. package/dist/esm/v2/index.js +15 -13
  126. package/dist/esm/v2/useIdAttribute-859439f0.js +21 -0
  127. package/dist/esm/v2/useValidationAttributes-d1abbe34.js +16 -0
  128. package/dist/esm/v3/{OrCardCollection-dbb3e839.js → OrCardCollection-110b3a0b.js} +1 -1
  129. package/dist/esm/v3/{OrCheckbox-3e139eac.js → OrCheckbox-7144da06.js} +36 -19
  130. package/dist/esm/v3/{OrConfirm-1bcd39b1.js → OrConfirm-1a38ed1b.js} +1 -1
  131. package/dist/esm/v3/{OrInlineInput-507fc99c.js → OrInlineInput-a6b19dbe.js} +37 -20
  132. package/dist/esm/v3/{OrInlineTextarea-53a9e027.js → OrInlineTextarea-9eb60363.js} +37 -20
  133. package/dist/esm/v3/{OrInput-9c0426b9.js → OrInput-e07ec00c.js} +37 -26
  134. package/dist/esm/v3/{OrPagination-a703307d.js → OrPagination-5e01a0a5.js} +1 -1
  135. package/dist/esm/v3/{OrRadio-54b6d0de.js → OrRadio-39d1905d.js} +34 -17
  136. package/dist/esm/v3/{OrSearch-9885d178.js → OrSearch-a60f67f0.js} +1 -1
  137. package/dist/esm/v3/{OrSelect-dfa4885f.js → OrSelect-2c70e384.js} +2 -2
  138. package/dist/esm/v3/{OrSwitch-cca30aa0.js → OrSwitch-3e9a699d.js} +34 -18
  139. package/dist/esm/v3/{OrTabs-d0ee6cef.js → OrTabs-91618aab.js} +1 -1
  140. package/dist/esm/v3/{OrTextarea-bb9ef3f2.js → OrTextarea-fd6b9f31.js} +42 -22
  141. package/dist/esm/v3/components/index.js +15 -13
  142. package/dist/esm/v3/components/or-card-collection-v3/index.js +5 -3
  143. package/dist/esm/v3/components/or-checkbox-v3/OrCheckbox.vue.d.ts +18 -2
  144. package/dist/esm/v3/components/or-checkbox-v3/index.js +2 -1
  145. package/dist/esm/v3/components/or-confirm-v3/index.js +4 -2
  146. package/dist/esm/v3/components/or-inline-input-v3/OrInlineInput.vue.d.ts +36 -6
  147. package/dist/esm/v3/components/or-inline-input-v3/index.js +3 -1
  148. package/dist/esm/v3/components/or-inline-textarea-v3/OrInlineTextarea.vue.d.ts +36 -6
  149. package/dist/esm/v3/components/or-inline-textarea-v3/index.js +3 -1
  150. package/dist/esm/v3/components/or-input-v3/OrInput.vue.d.ts +43 -8
  151. package/dist/esm/v3/components/or-input-v3/index.js +3 -1
  152. package/dist/esm/v3/components/or-pagination-v3/index.js +1 -1
  153. package/dist/esm/v3/components/or-radio-v3/OrRadio.vue.d.ts +18 -2
  154. package/dist/esm/v3/components/or-radio-v3/index.js +2 -1
  155. package/dist/esm/v3/components/or-search-v3/index.js +4 -2
  156. package/dist/esm/v3/components/or-select-v3/index.js +5 -3
  157. package/dist/esm/v3/components/or-switch-v3/OrSwitch.vue.d.ts +18 -2
  158. package/dist/esm/v3/components/or-switch-v3/index.js +2 -1
  159. package/dist/esm/v3/components/or-tabs-v3/index.js +1 -1
  160. package/dist/esm/v3/components/or-textarea-v3/OrTextarea.vue.d.ts +45 -6
  161. package/dist/esm/v3/components/or-textarea-v3/index.js +3 -1
  162. package/dist/esm/v3/hooks/index.d.ts +3 -0
  163. package/dist/esm/v3/hooks/index.js +2 -0
  164. package/dist/esm/v3/hooks/useControlAttributes.d.ts +8 -0
  165. package/dist/esm/v3/hooks/useIdAttribute.d.ts +2 -0
  166. package/dist/esm/v3/hooks/useValidationAttributes.d.ts +12 -0
  167. package/dist/esm/v3/index.js +15 -13
  168. package/dist/esm/v3/useIdAttribute-859439f0.js +21 -0
  169. package/dist/esm/v3/useValidationAttributes-d1abbe34.js +16 -0
  170. package/package.json +2 -3
  171. package/src/components/or-checkbox-v3/OrCheckbox.vue +28 -10
  172. package/src/components/or-inline-input-v3/OrInlineInput.vue +32 -13
  173. package/src/components/or-inline-textarea-v3/OrInlineTextarea.vue +32 -13
  174. package/src/components/or-input-v3/OrInput.stories3.ts +4 -4
  175. package/src/components/or-input-v3/OrInput.vue +31 -19
  176. package/src/components/or-pagination-v3/OrPagination.vue +1 -1
  177. package/src/components/or-radio-v3/OrRadio.vue +27 -9
  178. package/src/components/or-switch-v3/OrSwitch.vue +27 -9
  179. package/src/components/or-tabs-v3/OrTabs.vue +1 -1
  180. package/src/components/or-textarea-v3/OrTextarea.stories3.ts +4 -4
  181. package/src/components/or-textarea-v3/OrTextarea.vue +36 -14
  182. package/src/hooks/index.ts +3 -0
  183. package/src/hooks/useControlAttributes.ts +19 -0
  184. package/src/hooks/useIdAttribute.ts +9 -0
  185. package/src/hooks/useValidationAttributes.ts +25 -0
@@ -1,11 +1,12 @@
1
1
  <template>
2
2
  <div
3
3
  ref="root"
4
+ v-bind="$attrs"
4
5
  :class="rootStyles"
5
6
  >
6
7
  <template v-if="label">
7
8
  <OrLabel
8
- :control-id="controlId"
9
+ :control-id="controlAttributes.id"
9
10
  :variant="'input'"
10
11
  :required="required"
11
12
  :disabled="disabled"
@@ -25,9 +26,9 @@
25
26
  :disabled="disabled"
26
27
  >
27
28
  <textarea
28
- :id="controlId"
29
+ ref="control"
29
30
  v-model="proxyModelValue"
30
- v-bind="$attrs"
31
+ v-bind="controlAttributes"
31
32
  :class="controlStyles"
32
33
  :placeholder="placeholder"
33
34
  :required="required"
@@ -70,8 +71,8 @@
70
71
  </template>
71
72
 
72
73
  <script lang="ts">
73
- import { computed, defineComponent, getCurrentInstance, PropType, ref } from 'vue-demi';
74
- import { useClassAttribute } from '../../hooks';
74
+ import { computed, defineComponent, PropType, reactive, ref } from 'vue-demi';
75
+ import { useClassAttribute, useControlAttributes, useIdAttribute, useValidationAttributes } from '../../hooks';
75
76
  import { OrErrorV3 as OrError } from '../or-error-v3';
76
77
  import { OrHintV3 as OrHint } from '../or-hint-v3';
77
78
  import { OrInputBoxV3 as OrInputBox } from '../or-input-box-v3';
@@ -132,6 +133,11 @@ export default defineComponent({
132
133
  default: false,
133
134
  },
134
135
 
136
+ readonly: {
137
+ type: Boolean,
138
+ default: false,
139
+ },
140
+
135
141
  disabled: {
136
142
  type: Boolean,
137
143
  default: false,
@@ -150,13 +156,15 @@ export default defineComponent({
150
156
 
151
157
  expose: [
152
158
  'root',
159
+
160
+ 'focus',
161
+ 'blur',
153
162
  ],
154
163
 
155
164
  setup(props, context) {
156
- const currentInstance = getCurrentInstance()!;
157
-
158
165
  // Refs
159
166
  const root = ref<HTMLElement>();
167
+ const control = ref<HTMLTextAreaElement>();
160
168
 
161
169
  // Styles
162
170
  const classAttribute = useClassAttribute();
@@ -172,7 +180,11 @@ export default defineComponent({
172
180
  ]);
173
181
 
174
182
  // State
175
- const controlId = ref(context.attrs.id as string ?? currentInstance.uid.toString());
183
+ const controlAttributes = reactive({
184
+ id: useIdAttribute(),
185
+ ...useControlAttributes(),
186
+ ...useValidationAttributes(),
187
+ });
176
188
 
177
189
  const proxyModelValue = computed({
178
190
  get: () => {
@@ -185,22 +197,32 @@ export default defineComponent({
185
197
  },
186
198
  });
187
199
 
200
+ const currentLength = computed(() => proxyModelValue.value?.toString().length ?? 0);
201
+ const maxLength = computed(() => controlAttributes.maxlength);
202
+
188
203
  const invalid = computed(() => !!props.error);
189
- const readonly = computed(() => context.attrs.readonly as boolean);
190
204
 
191
- const currentLength = computed(() => proxyModelValue.value?.toString().length ?? 0);
192
- const maxLength = computed(() => context.attrs.maxlength as number | undefined);
205
+ // Methods
206
+ function focus(): void {
207
+ control.value?.focus();
208
+ }
209
+
210
+ function blur(): void {
211
+ control.value?.blur();
212
+ }
193
213
 
194
214
  return {
195
215
  root,
216
+ control,
196
217
  rootStyles,
197
218
  controlStyles,
198
- controlId,
219
+ controlAttributes,
199
220
  proxyModelValue,
200
- invalid,
201
- readonly,
202
221
  currentLength,
203
222
  maxLength,
223
+ invalid,
224
+ focus,
225
+ blur,
204
226
  };
205
227
  },
206
228
  });
@@ -1,5 +1,8 @@
1
1
  export { useClassAttribute } from './useClassAttribute';
2
+ export { useControlAttributes } from './useControlAttributes';
2
3
  export { useElevation } from './useElevation';
4
+ export { useIdAttribute } from './useIdAttribute';
3
5
  export { useOverflow } from './useOverflow';
4
6
  export { useResponsive } from './useResponsive';
5
7
  export { default as useToggle } from './useToggle';
8
+ export { useValidationAttributes } from './useValidationAttributes';
@@ -0,0 +1,19 @@
1
+ import { computed, ComputedRef, useAttrs } from 'vue-demi';
2
+
3
+ interface ControlAttributes {
4
+ readonly: ComputedRef<boolean | undefined>;
5
+ disabled: ComputedRef<boolean | undefined>;
6
+
7
+ 'force-state': ComputedRef<string | undefined>;
8
+ }
9
+
10
+ export function useControlAttributes(): ControlAttributes {
11
+ const attributes = useAttrs();
12
+
13
+ return {
14
+ readonly: computed(() => attributes['readonly'] as boolean | undefined),
15
+ disabled: computed(() => attributes['disabled'] as boolean | undefined),
16
+
17
+ 'force-state': computed(() => attributes['force-state'] as string | undefined),
18
+ };
19
+ }
@@ -0,0 +1,9 @@
1
+ import { computed, ComputedRef, getCurrentInstance, useAttrs } from 'vue-demi';
2
+
3
+ export function useIdAttribute(): ComputedRef<string | undefined> {
4
+ const attributes = useAttrs(), component = getCurrentInstance();
5
+
6
+ return computed(() => {
7
+ return attributes['id'] as string | undefined ?? component?.uid.toString();
8
+ });
9
+ }
@@ -0,0 +1,25 @@
1
+ import { computed, ComputedRef, useAttrs } from 'vue-demi';
2
+
3
+ interface ValidationAttributes {
4
+ required: ComputedRef<boolean | undefined>;
5
+ minlength: ComputedRef<number | undefined>;
6
+ maxlength: ComputedRef<number | undefined>;
7
+ pattern: ComputedRef<string | undefined>;
8
+ min: ComputedRef<number | undefined>;
9
+ max: ComputedRef<number | undefined>;
10
+ step: ComputedRef<number | undefined>;
11
+ }
12
+
13
+ export function useValidationAttributes(): ValidationAttributes {
14
+ const attributes = useAttrs();
15
+
16
+ return {
17
+ required: computed(() => attributes['required'] as boolean | undefined),
18
+ minlength: computed(() => attributes['minlength'] as number | undefined),
19
+ maxlength: computed(() => attributes['maxlength'] as number | undefined),
20
+ pattern: computed(() => attributes['pattern'] as string | undefined),
21
+ min: computed(() => attributes['min'] as number | undefined),
22
+ max: computed(() => attributes['max'] as number | undefined),
23
+ step: computed(() => attributes['step'] as number | undefined),
24
+ };
25
+ }