sprintify-ui 0.0.41 → 0.0.42

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 (89) hide show
  1. package/dist/sprintify-ui.es.js +6033 -5518
  2. package/dist/types/src/components/BaseAutocomplete.vue.d.ts +32 -12
  3. package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +28 -28
  4. package/dist/types/src/components/BaseBelongsTo.vue.d.ts +35 -35
  5. package/dist/types/src/components/BaseButtonGroup.vue.d.ts +46 -8
  6. package/dist/types/src/components/BaseDatePicker.vue.d.ts +18 -9
  7. package/dist/types/src/components/BaseDateSelect.vue.d.ts +14 -5
  8. package/dist/types/src/components/BaseField.vue.d.ts +151 -0
  9. package/dist/types/src/components/BaseFieldI18n.vue.d.ts +93 -0
  10. package/dist/types/src/components/BaseForm.vue.d.ts +267 -0
  11. package/dist/types/src/components/BaseFormField.d.ts +81 -0
  12. package/dist/types/src/components/BaseHasMany.vue.d.ts +31 -31
  13. package/dist/types/src/components/BaseInput.vue.d.ts +1 -1
  14. package/dist/types/src/components/BaseInputError.vue.d.ts +48 -0
  15. package/dist/types/src/components/BaseInputPercent.vue.d.ts +1 -1
  16. package/dist/types/src/components/BaseLocaleForm.vue.d.ts +420 -0
  17. package/dist/types/src/components/BaseMediaLibrary.vue.d.ts +46 -24
  18. package/dist/types/src/components/BaseNumberForm.vue.d.ts +382 -0
  19. package/dist/types/src/components/BasePassword.vue.d.ts +10 -14
  20. package/dist/types/src/components/BasePasswordForm.vue.d.ts +365 -0
  21. package/dist/types/src/components/BaseRadioGroup.vue.d.ts +23 -4
  22. package/dist/types/src/components/BaseSelect.vue.d.ts +20 -1
  23. package/dist/types/src/components/BaseSwitch.vue.d.ts +155 -23
  24. package/dist/types/src/components/BaseTagAutocomplete.vue.d.ts +31 -12
  25. package/dist/types/src/components/BaseTagAutocompleteFetch.vue.d.ts +20 -20
  26. package/dist/types/src/components/BaseTextarea.vue.d.ts +9 -0
  27. package/dist/types/src/components/BaseTextareaAutoresize.vue.d.ts +18 -0
  28. package/dist/types/src/components/BaseTextareaForm.vue.d.ts +394 -0
  29. package/dist/types/src/components/index.d.ts +4 -1
  30. package/dist/types/src/composables/field.d.ts +17 -0
  31. package/dist/types/src/index.d.ts +3 -0
  32. package/dist/types/src/types/index.d.ts +11 -0
  33. package/package.json +4 -1
  34. package/src/components/BaseAutocomplete.stories.js +56 -51
  35. package/src/components/BaseAutocomplete.vue +25 -8
  36. package/src/components/BaseAutocompleteFetch.stories.js +67 -65
  37. package/src/components/BaseAutocompleteFetch.vue +9 -29
  38. package/src/components/BaseBelongsTo.stories.js +72 -82
  39. package/src/components/BaseBelongsTo.vue +10 -11
  40. package/src/components/BaseButtonGroup.stories.js +11 -10
  41. package/src/components/BaseButtonGroup.vue +22 -9
  42. package/src/components/BaseCharacterCounter.stories.js +1 -1
  43. package/src/components/BaseDatePicker.stories.js +13 -9
  44. package/src/components/BaseDatePicker.vue +25 -8
  45. package/src/components/BaseDateSelect.stories.js +15 -9
  46. package/src/components/BaseDateSelect.vue +20 -8
  47. package/src/components/BaseField.vue +109 -0
  48. package/src/components/BaseFieldI18n.stories.js +38 -0
  49. package/src/components/BaseFieldI18n.vue +162 -0
  50. package/src/components/BaseFileUploader.stories.js +3 -3
  51. package/src/components/BaseFileUploader.vue +3 -3
  52. package/src/components/BaseForm.vue +298 -0
  53. package/src/components/BaseFormField.ts +117 -0
  54. package/src/components/BaseHasMany.stories.js +25 -10
  55. package/src/components/BaseHasMany.vue +9 -9
  56. package/src/components/BaseInput.stories.js +27 -14
  57. package/src/components/BaseInput.vue +17 -8
  58. package/src/components/BaseInputError.vue +7 -0
  59. package/src/components/BaseInputPercent.stories.js +10 -3
  60. package/src/components/BaseInputPercent.vue +2 -1
  61. package/src/components/BaseLocaleForm.vue +142 -0
  62. package/src/components/BaseMediaLibrary.stories.js +7 -6
  63. package/src/components/BaseMediaLibrary.vue +32 -31
  64. package/src/components/BaseMenu.vue +1 -1
  65. package/src/components/BaseNumberForm.vue +67 -0
  66. package/src/components/BasePassword.stories.js +9 -4
  67. package/src/components/BasePassword.vue +49 -44
  68. package/src/components/BasePasswordForm.vue +59 -0
  69. package/src/components/BaseRadioGroup.stories.js +9 -8
  70. package/src/components/BaseRadioGroup.vue +17 -3
  71. package/src/components/BaseSelect.stories.js +15 -2
  72. package/src/components/BaseSelect.vue +26 -10
  73. package/src/components/BaseSwitch.stories.js +7 -0
  74. package/src/components/BaseSwitch.vue +134 -124
  75. package/src/components/BaseTagAutocomplete.stories.js +21 -14
  76. package/src/components/BaseTagAutocomplete.vue +25 -14
  77. package/src/components/BaseTagAutocompleteFetch.stories.js +37 -21
  78. package/src/components/BaseTagAutocompleteFetch.vue +5 -5
  79. package/src/components/BaseTextarea.stories.js +11 -3
  80. package/src/components/BaseTextarea.vue +20 -6
  81. package/src/components/BaseTextareaAutoresize.stories.js +11 -2
  82. package/src/components/BaseTextareaAutoresize.vue +28 -4
  83. package/src/components/BaseTextareaForm.vue +101 -0
  84. package/src/components/BaseTimeline.vue +1 -1
  85. package/src/components/BaseTimelineItem.vue +4 -4
  86. package/src/components/index.ts +6 -0
  87. package/src/composables/field.ts +100 -0
  88. package/src/index.ts +11 -1
  89. package/src/types/index.ts +12 -0
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <div>
3
+ <BaseInputLabel
4
+ v-if="labelValue"
5
+ :label="labelValue"
6
+ :required="required"
7
+ />
8
+
9
+ <BasePassword
10
+ ref="input"
11
+ :model-value="modelValue"
12
+ :name="name"
13
+ :disabled="disabled"
14
+ :placeholder="placeholder"
15
+ :required="required"
16
+ class="rounded"
17
+ :class="[
18
+ {
19
+ 'border-red-600': hasError(),
20
+ 'border-slate-300': !hasError(),
21
+ },
22
+ inputClass,
23
+ ]"
24
+ @update:model-value="onInput"
25
+ />
26
+
27
+ <BaseInputError v-if="hasError()" class="mt-1">
28
+ {{ errorMessage() }}
29
+ </BaseInputError>
30
+ </div>
31
+ </template>
32
+
33
+ <script lang="ts">
34
+ import { defineComponent, PropType } from 'vue';
35
+ import BaseFormField from './BaseFormField';
36
+ import BaseInputError from './BaseInputError.vue';
37
+ import BaseInputLabel from './BaseInputLabel.vue';
38
+ import BasePassword from './BasePassword.vue';
39
+
40
+ export default defineComponent({
41
+ components: { BaseInputLabel, BasePassword, BaseInputError },
42
+ extends: BaseFormField,
43
+ props: {
44
+ modelValue: {
45
+ required: true,
46
+ type: [String, null] as PropType<string | null>,
47
+ },
48
+ inputClass: {
49
+ default: undefined,
50
+ type: String,
51
+ },
52
+ },
53
+ methods: {
54
+ onInput(value: string | null) {
55
+ this.inputListener(value);
56
+ },
57
+ },
58
+ });
59
+ </script>
@@ -1,4 +1,6 @@
1
+ import { options } from '../../.storybook/utils';
1
2
  import BaseRadioGroup from './BaseRadioGroup.vue';
3
+ import { createFieldStory } from '@/../.storybook/utils';
2
4
 
3
5
  export default {
4
6
  title: 'Form/BaseRadioGroup',
@@ -8,14 +10,7 @@ export default {
8
10
  name: 'character',
9
11
  labelKey: 'label',
10
12
  valueKey: 'value',
11
- options: [
12
- { label: 'Dark Vader', value: 'dark_vader' },
13
- { label: 'Darth Maul', value: 'darth_maul' },
14
- { label: 'Dark Sidious', value: 'dark_sidious' },
15
- { label: 'Obi Wan Kenobi', value: 'obiwan' },
16
- { label: 'Anakin Skywalker', value: 'anakin' },
17
- { label: 'Mace Windu', value: 'windu' },
18
- ],
13
+ options: options,
19
14
  },
20
15
  decorators: [() => ({ template: '<div class="mb-36"><story/></div>' })],
21
16
  };
@@ -86,3 +81,9 @@ export const SlotOption = (args) => ({
86
81
  </BaseRadioGroup>
87
82
  `,
88
83
  });
84
+
85
+ export const Field = createFieldStory({
86
+ component: BaseRadioGroup,
87
+ componentName: 'BaseRadioGroup',
88
+ label: 'Choose your character',
89
+ });
@@ -10,13 +10,13 @@
10
10
  <input
11
11
  :id="name + '-' + option.value"
12
12
  type="radio"
13
- :name="name"
13
+ :name="nameInternal"
14
14
  :checked="isSelected(option)"
15
- :required="required"
15
+ :required="requiredInternal"
16
16
  :disabled="disabled"
17
17
  :value="option.value"
18
18
  :class="inputClass"
19
- @input="emit('update:modelValue', option.option)"
19
+ @input="emitUpdate(option.option)"
20
20
  />
21
21
 
22
22
  <slot name="option" :option="option">
@@ -32,6 +32,7 @@
32
32
  import { PropType } from 'vue';
33
33
  import { Option } from '@/types';
34
34
  import { useHasOptions } from '@/composables/hasOptions';
35
+ import { useField } from '@/composables/field';
35
36
 
36
37
  const props = defineProps({
37
38
  modelValue: {
@@ -70,10 +71,23 @@ const props = defineProps({
70
71
  default: 'mt-0.5 border-slate-300',
71
72
  type: String,
72
73
  },
74
+ hasError: {
75
+ default: false,
76
+ type: Boolean,
77
+ },
73
78
  });
74
79
 
75
80
  const emit = defineEmits(['update:modelValue']);
76
81
 
82
+ const { nameInternal, requiredInternal, emitUpdate } = useField({
83
+ name: computed(() => props.name),
84
+ required: computed(() => props.required),
85
+ hasError: computed(() => props.hasError),
86
+ emit: emit,
87
+ errorType: 'alert',
88
+ labelClass: 'mb-3 font-medium',
89
+ });
90
+
77
91
  const { normalizedOptions, isSelected } = useHasOptions(
78
92
  computed(() => props.modelValue),
79
93
  computed(() => props.options),
@@ -1,11 +1,12 @@
1
1
  import BaseSelect from './BaseSelect.vue';
2
2
  import BaseInputLabel from './BaseInputLabel.vue';
3
+ import ShowValue from '../../.storybook/components/ShowValue.vue';
4
+ import { createFieldStory } from '../../.storybook/utils.js';
3
5
 
4
6
  export default {
5
7
  title: 'Form/BaseSelect',
6
8
  component: BaseSelect,
7
9
  args: {
8
- name: 'name',
9
10
  class: 'w-full',
10
11
  },
11
12
  };
@@ -14,6 +15,7 @@ const Template = (args) => ({
14
15
  components: {
15
16
  BaseSelect,
16
17
  BaseInputLabel,
18
+ ShowValue,
17
19
  },
18
20
  setup() {
19
21
  function onSubmit() {
@@ -43,7 +45,7 @@ const Template = (args) => ({
43
45
  </BaseSelect>
44
46
  <button type="submit" class="btn btn-primary mt-5">Submit</button>
45
47
  </form>
46
- <pre class="mt-4 bg-slate-800 font-light text-xs p-3 rounded text-white">{{ {value} }}</pre>
48
+ <ShowValue :value="value" />
47
49
  `,
48
50
  });
49
51
 
@@ -65,3 +67,14 @@ Disabled.args = {
65
67
  placeholder: 'Choose a language',
66
68
  disabled: true,
67
69
  };
70
+
71
+ export const Field = createFieldStory({
72
+ component: BaseSelect,
73
+ componentName: 'BaseSelect',
74
+ template: `<BaseSelect v-model="value" v-bind="args" class="w-full">
75
+ <option value="javascript">JavaScript</option>
76
+ <option value="typescript">Typescript</option>
77
+ <option value="golang">Golang</option>
78
+ </BaseSelect>`,
79
+ label: 'Choose your favorite programing language',
80
+ });
@@ -2,14 +2,17 @@
2
2
  <select
3
3
  ref="select"
4
4
  :value="modelValueInternal"
5
- :name="name"
5
+ :name="nameInternal"
6
6
  :disabled="disabled"
7
- :required="required"
8
- class="rounded border border-slate-300 disabled:cursor-not-allowed disabled:text-slate-300 disabled:opacity-100"
9
- :class="[!modelValue && required ? 'text-slate-400' : '']"
7
+ :required="requiredInternal"
8
+ class="rounded border disabled:cursor-not-allowed disabled:text-slate-300 disabled:opacity-100"
9
+ :class="[
10
+ !modelValue && requiredInternal ? 'text-slate-400' : '',
11
+ hasErrorInternal ? 'border-red-600' : 'border-slate-300',
12
+ ]"
10
13
  @change="onChange($event)"
11
14
  >
12
- <template v-if="required">
15
+ <template v-if="requiredInternal">
13
16
  <option disabled hidden :value="EMPTY_VALUE_INTERNAL">
14
17
  {{ placeholder ? placeholder : $t('sui.select_an_option') }}
15
18
  </option>
@@ -27,6 +30,7 @@
27
30
  import { PropType, Ref } from 'vue';
28
31
  import { get, isEqual } from 'lodash';
29
32
  import { useMounted } from '@vueuse/core';
33
+ import { useField } from '@/composables/field';
30
34
 
31
35
  type Option = string | number | null;
32
36
 
@@ -54,6 +58,10 @@ const props = defineProps({
54
58
  default: false,
55
59
  type: Boolean,
56
60
  },
61
+ hasError: {
62
+ default: false,
63
+ type: Boolean,
64
+ },
57
65
  });
58
66
 
59
67
  const mounted = useMounted();
@@ -61,6 +69,14 @@ const select = ref(null) as Ref<HTMLSelectElement | null>;
61
69
 
62
70
  const emit = defineEmits(['update:modelValue']);
63
71
 
72
+ const { nameInternal, requiredInternal, hasErrorInternal, emitUpdate } =
73
+ useField({
74
+ name: computed(() => props.name),
75
+ required: computed(() => props.required),
76
+ hasError: computed(() => props.hasError),
77
+ emit: emit,
78
+ });
79
+
64
80
  function isEmptyExternal(value: string | number | null | undefined) {
65
81
  if (value === undefined || value === EMPTY_VALUE_EXTERNAL) {
66
82
  return true;
@@ -131,9 +147,9 @@ function validateAndFixModelVale() {
131
147
  return;
132
148
  }
133
149
  if (isEmptyInternal(props.modelValue)) {
134
- emit('update:modelValue', EMPTY_VALUE_EXTERNAL);
150
+ emitUpdate(EMPTY_VALUE_EXTERNAL);
135
151
  } else if (!validModelValue()) {
136
- emit('update:modelValue', EMPTY_VALUE_EXTERNAL);
152
+ emitUpdate(EMPTY_VALUE_EXTERNAL);
137
153
  }
138
154
  }
139
155
 
@@ -144,16 +160,16 @@ function validateAndFixModelVale() {
144
160
  */
145
161
  function onChange(event: Event) {
146
162
  if (event === null) {
147
- emit('update:modelValue', EMPTY_VALUE_EXTERNAL);
163
+ emitUpdate(EMPTY_VALUE_EXTERNAL);
148
164
  }
149
165
 
150
166
  const value = get(event, 'target.value', null);
151
167
 
152
168
  if (isEmptyExternal(value)) {
153
- emit('update:modelValue', EMPTY_VALUE_EXTERNAL);
169
+ emitUpdate(EMPTY_VALUE_EXTERNAL);
154
170
  return;
155
171
  }
156
172
 
157
- emit('update:modelValue', value);
173
+ emitUpdate(value);
158
174
  }
159
175
  </script>
@@ -1,5 +1,6 @@
1
1
  import BaseSwitch from './BaseSwitch.vue';
2
2
  import BaseContainer from './BaseContainer.vue';
3
+ import { createFieldStory } from '../../.storybook/utils';
3
4
 
4
5
  export default {
5
6
  title: 'Form/BaseSwitch',
@@ -99,3 +100,9 @@ const Sizes = (args) => ({
99
100
 
100
101
  export const AllSizes = Sizes.bind({});
101
102
  AllSizes.args = {};
103
+
104
+ export const Field = createFieldStory({
105
+ component: BaseSwitch,
106
+ componentName: 'BaseSwitch',
107
+ label: 'Activate',
108
+ });
@@ -31,135 +31,145 @@
31
31
  </SwitchGroup>
32
32
  </template>
33
33
 
34
- <script lang="ts">
34
+ <script lang="ts" setup>
35
+ import { useField } from '@/composables/field';
35
36
  import { Switch, SwitchGroup, SwitchLabel } from '@headlessui/vue';
36
- import { defineComponent, PropType } from 'vue';
37
+ import { PropType } from 'vue';
37
38
 
38
- export default defineComponent({
39
- components: {
40
- // eslint-disable-next-line vue/no-reserved-component-names
41
- Switch,
42
- SwitchGroup,
43
- SwitchLabel,
39
+ const props = defineProps({
40
+ modelValue: {
41
+ default: false,
42
+ type: Boolean,
44
43
  },
45
- props: {
46
- modelValue: {
47
- default: false,
48
- type: Boolean,
49
- },
50
- color: {
51
- default: 'primary',
52
- type: String as PropType<
53
- 'primary' | 'info' | 'danger' | 'warning' | 'success' | 'dark' | 'light'
54
- >,
55
- },
56
- size: {
57
- default: 'base',
58
- type: String as PropType<'xs' | 'sm' | 'base' | 'lg' | 'xl'>,
59
- },
44
+ name: {
45
+ default: undefined,
46
+ type: String,
60
47
  },
61
- emits: ['update:modelValue'],
62
- computed: {
63
- bg() {
64
- if (this.color == 'primary') {
65
- return 'bg-primary-500';
66
- }
67
- if (this.color == 'info') {
68
- return 'bg-blue-500';
69
- }
70
- if (this.color == 'danger') {
71
- return 'bg-red-500';
72
- }
73
- if (this.color == 'warning') {
74
- return 'bg-yellow-500';
75
- }
76
- if (this.color == 'success') {
77
- return 'bg-green-500';
78
- }
79
- if (this.color == 'light') {
80
- return 'bg-slate-500';
81
- }
82
- return 'bg-slate-900';
83
- },
84
- focus() {
85
- if (this.color == 'primary') {
86
- return 'focus:ring-primary-500';
87
- }
88
- if (this.color == 'info') {
89
- return 'focus:ring-blue-500';
90
- }
91
- if (this.color == 'danger') {
92
- return 'focus:ring-red-500';
93
- }
94
- if (this.color == 'warning') {
95
- return 'focus:ring-yellow-500';
96
- }
97
- if (this.color == 'success') {
98
- return 'focus:ring-green-500';
99
- }
100
- if (this.color == 'light') {
101
- return 'focus:ring-slate-500';
102
- }
103
- return 'focus:ring-slate-900';
104
- },
105
- sizePx() {
106
- if (this.size == 'xs') {
107
- return 12;
108
- }
109
- if (this.size == 'sm') {
110
- return 16;
111
- }
112
- if (this.size == 'base') {
113
- return 20;
114
- }
115
- if (this.size == 'lg') {
116
- return 24;
117
- }
118
- if (this.size == 'xl') {
119
- return 32;
120
- }
121
- return 16;
122
- },
123
- padding() {
124
- if (this.size == 'xs') {
125
- return 2;
126
- }
127
- if (this.size == 'sm') {
128
- return 2.5;
129
- }
130
- if (this.size == 'base') {
131
- return 3;
132
- }
133
- if (this.size == 'lg') {
134
- return 3;
135
- }
136
- if (this.size == 'xl') {
137
- return 4;
138
- }
139
- return 2;
140
- },
141
- height() {
142
- return this.sizePx + 2 * this.padding;
143
- },
144
- distance() {
145
- return 2 * this.sizePx;
146
- },
147
- width() {
148
- return this.distance + 2 * this.padding;
149
- },
150
- translateX() {
151
- if (this.modelValue) {
152
- return this.padding + this.distance - this.sizePx;
153
- }
154
-
155
- return this.padding;
156
- },
48
+ color: {
49
+ default: 'primary',
50
+ type: String as PropType<
51
+ 'primary' | 'info' | 'danger' | 'warning' | 'success' | 'dark' | 'light'
52
+ >,
53
+ },
54
+ size: {
55
+ default: 'base',
56
+ type: String as PropType<'xs' | 'sm' | 'base' | 'lg' | 'xl'>,
57
+ },
58
+ hasError: {
59
+ default: false,
60
+ type: Boolean,
157
61
  },
158
- methods: {
159
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
160
- update(payload: any) {
161
- this.$emit('update:modelValue', payload);
162
- },
62
+ required: {
63
+ default: false,
64
+ type: Boolean,
163
65
  },
164
66
  });
67
+
68
+ const emit = defineEmits(['update:modelValue']);
69
+
70
+ const { emitUpdate } = useField({
71
+ name: computed(() => props.name),
72
+ required: computed(() => props.required),
73
+ hasError: computed(() => props.hasError),
74
+ emit: emit,
75
+ });
76
+
77
+ const bg = computed(() => {
78
+ if (props.color == 'primary') {
79
+ return 'bg-primary-500';
80
+ }
81
+ if (props.color == 'info') {
82
+ return 'bg-blue-500';
83
+ }
84
+ if (props.color == 'danger') {
85
+ return 'bg-red-500';
86
+ }
87
+ if (props.color == 'warning') {
88
+ return 'bg-yellow-500';
89
+ }
90
+ if (props.color == 'success') {
91
+ return 'bg-green-500';
92
+ }
93
+ if (props.color == 'light') {
94
+ return 'bg-slate-500';
95
+ }
96
+ return 'bg-slate-900';
97
+ });
98
+ const focus = computed(() => {
99
+ if (props.color == 'primary') {
100
+ return 'focus:ring-primary-500';
101
+ }
102
+ if (props.color == 'info') {
103
+ return 'focus:ring-blue-500';
104
+ }
105
+ if (props.color == 'danger') {
106
+ return 'focus:ring-red-500';
107
+ }
108
+ if (props.color == 'warning') {
109
+ return 'focus:ring-yellow-500';
110
+ }
111
+ if (props.color == 'success') {
112
+ return 'focus:ring-green-500';
113
+ }
114
+ if (props.color == 'light') {
115
+ return 'focus:ring-slate-500';
116
+ }
117
+ return 'focus:ring-slate-900';
118
+ });
119
+ const sizePx = computed(() => {
120
+ if (props.size == 'xs') {
121
+ return 12;
122
+ }
123
+ if (props.size == 'sm') {
124
+ return 16;
125
+ }
126
+ if (props.size == 'base') {
127
+ return 20;
128
+ }
129
+ if (props.size == 'lg') {
130
+ return 24;
131
+ }
132
+ if (props.size == 'xl') {
133
+ return 32;
134
+ }
135
+ return 16;
136
+ });
137
+ const padding = computed(() => {
138
+ if (props.size == 'xs') {
139
+ return 2;
140
+ }
141
+ if (props.size == 'sm') {
142
+ return 2.5;
143
+ }
144
+ if (props.size == 'base') {
145
+ return 3;
146
+ }
147
+ if (props.size == 'lg') {
148
+ return 3;
149
+ }
150
+ if (props.size == 'xl') {
151
+ return 4;
152
+ }
153
+ return 2;
154
+ });
155
+ const height = computed(() => {
156
+ return sizePx.value + 2 * padding.value;
157
+ });
158
+ const distance = computed(() => {
159
+ return 2 * sizePx.value;
160
+ });
161
+ const width = computed(() => {
162
+ return distance.value + 2 * padding.value;
163
+ });
164
+ const translateX = computed(() => {
165
+ if (props.modelValue) {
166
+ return padding.value + distance.value - sizePx.value;
167
+ }
168
+
169
+ return padding.value;
170
+ });
171
+
172
+ function update(payload: any) {
173
+ emitUpdate(payload);
174
+ }
165
175
  </script>
@@ -1,4 +1,7 @@
1
+ import { createFieldStory, options } from '../../.storybook/utils';
1
2
  import BaseTagAutocomplete from './BaseTagAutocomplete.vue';
3
+ import ShowValue from '@/../.storybook/components/ShowValue.vue';
4
+ import BaseAppNotifications from './BaseAppNotifications.vue';
2
5
 
3
6
  export default {
4
7
  title: 'Form/BaseTagAutocomplete',
@@ -7,24 +10,20 @@ export default {
7
10
  args: {
8
11
  labelKey: 'label',
9
12
  valueKey: 'value',
10
- options: [
11
- { label: 'Dark Vader', value: 'dark_vader' },
12
- { label: 'Darth Maul', value: 'darth_maul' },
13
- { label: 'Dark Sidious', value: 'dark_sidious' },
14
- ],
13
+ options: options,
15
14
  },
16
15
  decorators: [() => ({ template: '<div class="mb-36"><story/></div>' })],
17
16
  };
18
17
 
19
18
  const Template = (args) => ({
20
- components: { BaseTagAutocomplete },
19
+ components: { BaseTagAutocomplete, ShowValue, BaseAppNotifications },
21
20
  setup() {
22
21
  const value = ref(null);
23
22
  return { args, value };
24
23
  },
25
24
  template: `
26
25
  <BaseTagAutocomplete v-model="value" v-bind="args"></BaseTagAutocomplete>
27
- <p class="mt-5 text-sm">Value: <span class="bg-slate-200 font-mono px-1 py-px rounded">{{ value ?? 'NULL' }}</span></p>
26
+ <ShowValue :value="value" />
28
27
  `,
29
28
  });
30
29
 
@@ -33,9 +32,9 @@ Demo.args = {};
33
32
 
34
33
  export const Disabled = Template.bind({});
35
34
  Disabled.args = {
36
- options: [],
35
+ options: options,
37
36
  disabled: true,
38
- modelValue: [{ label: 'Dark Maul', value: '1' }],
37
+ modelValue: [options[0]],
39
38
  };
40
39
 
41
40
  export const Loading = Template.bind({});
@@ -44,7 +43,7 @@ Loading.args = {
44
43
  };
45
44
 
46
45
  export const SlotOption = (args) => ({
47
- components: { BaseTagAutocomplete },
46
+ components: { BaseTagAutocomplete, ShowValue, BaseAppNotifications },
48
47
  setup() {
49
48
  const value = ref(null);
50
49
 
@@ -82,11 +81,13 @@ export const SlotOption = (args) => ({
82
81
 
83
82
  export const SlotFooter = (args) => {
84
83
  return {
85
- components: { BaseTagAutocomplete },
84
+ components: { BaseTagAutocomplete, ShowValue, BaseAppNotifications },
86
85
  setup() {
87
86
  const value = ref(null);
88
87
  function onClick() {
89
- alert(1);
88
+ setTimeout(() => {
89
+ alert(1);
90
+ }, 300);
90
91
  }
91
92
  return { args, value, onClick };
92
93
  },
@@ -97,7 +98,7 @@ export const SlotFooter = (args) => {
97
98
  >
98
99
  <template #footer>
99
100
  <div class="text-center p-2 border-t">
100
- <button @click=onClick class="btn btn-sm w-full btn-slate-200-outline">This is the footer 💯</button>
101
+ <button type="button" @click=onClick class="btn btn-sm w-full btn-slate-200-outline">This is the footer 💯</button>
101
102
  </div>
102
103
  </template>
103
104
  </BaseTagAutocomplete>
@@ -107,7 +108,7 @@ export const SlotFooter = (args) => {
107
108
 
108
109
  export const SlotEmpty = (args) => {
109
110
  return {
110
- components: { BaseTagAutocomplete },
111
+ components: { BaseTagAutocomplete, ShowValue, BaseAppNotifications },
111
112
  setup() {
112
113
  const value = ref(null);
113
114
  return { args, value };
@@ -125,3 +126,9 @@ export const SlotEmpty = (args) => {
125
126
  `,
126
127
  };
127
128
  };
129
+
130
+ export const Field = createFieldStory({
131
+ component: BaseTagAutocomplete,
132
+ componentName: 'BaseTagAutocomplete',
133
+ label: 'Name',
134
+ });