@redseed/redseed-ui-vue3 2.24.2 → 2.25.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.
package/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import _ from 'lodash'
2
2
  window._ = _
3
3
 
4
+ import lottie from 'lottie-web'
5
+ window.lottie = lottie
6
+
4
7
  export * from './src/components/Avatar'
5
8
  export * from './src/components/Badge'
6
9
  export * from './src/components/Breadcrumbs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redseed/redseed-ui-vue3",
3
- "version": "2.24.2",
3
+ "version": "2.25.0",
4
4
  "description": "RedSeed UI Vue 3 components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,240 @@
1
+ <script setup>
2
+ import { ref, computed } from 'vue'
3
+ import FormFieldSlot from './FormFieldSlot.vue'
4
+ import Loader from '../Loader/Loader.vue'
5
+ import { PlusIcon, DocumentIcon, ExclamationCircleIcon, XMarkIcon } from '@heroicons/vue/24/outline'
6
+
7
+ defineOptions({
8
+ inheritAttrs: false,
9
+ })
10
+
11
+ const props = defineProps({
12
+ removable: {
13
+ type: Boolean,
14
+ default: false,
15
+ },
16
+ })
17
+
18
+ const emit = defineEmits(['remove'])
19
+
20
+ const stateDefault = computed(() => {
21
+ return !stateUploading.value
22
+ && !stateProcessing.value
23
+ && !stateError.value
24
+ && !stateSuccess.value
25
+ })
26
+
27
+ const stateUploading = ref(false)
28
+ const stateProcessing = ref(false)
29
+ const stateError = ref(false)
30
+ const stateSuccess = ref(false)
31
+
32
+ const states = {
33
+ uploading: stateUploading,
34
+ processing: stateProcessing,
35
+ error: stateError,
36
+ success: stateSuccess,
37
+ }
38
+
39
+ function setState(state) {
40
+ Object.keys(states).forEach(key => {
41
+ states[key].value = key === state
42
+ })
43
+ }
44
+
45
+ function setStateDefault() {
46
+ setState('default')
47
+ }
48
+
49
+ function setStateUploading() {
50
+ setState('uploading')
51
+ }
52
+
53
+ function setStateProcessing() {
54
+ setState('processing')
55
+ }
56
+
57
+ function setStateError() {
58
+ setState('error')
59
+ }
60
+
61
+ function setStateSuccess() {
62
+ setState('success')
63
+ }
64
+
65
+ const uploaderContainerClass = computed(() => [
66
+ 'rsui-form-field-uploader__container',
67
+ {
68
+ 'rsui-form-field-uploader__container--success': stateSuccess.value,
69
+ }
70
+ ])
71
+
72
+ const uploaderContentClass = computed(() => [
73
+ 'rsui-form-field-uploader__content',
74
+ {
75
+ 'rsui-form-field-uploader__content--success': stateSuccess.value,
76
+ }
77
+ ])
78
+
79
+ const uploaderStateIconClass = computed(() => [
80
+ 'rsui-form-field-uploader__state-icon',
81
+ {
82
+ 'rsui-form-field-uploader__state-icon--success': stateSuccess.value,
83
+ }
84
+ ])
85
+
86
+ function removeAction() {
87
+ setStateDefault()
88
+ emit('remove')
89
+ }
90
+ </script>
91
+ <template>
92
+ <FormFieldSlot
93
+ :id="$attrs.id"
94
+ :class="[$attrs.class, 'rsui-form-field-uploader']"
95
+ :required="$attrs.required"
96
+ :compact="$attrs.compact"
97
+ >
98
+ <template #label v-if="$slots.label">
99
+ <slot name="label"></slot>
100
+ </template>
101
+
102
+ <template #help v-if="$slots.help">
103
+ <slot name="help"></slot>
104
+ </template>
105
+
106
+ <template #error v-if="$slots.error">
107
+ <slot name="error"></slot>
108
+ </template>
109
+
110
+ <div :class="uploaderContainerClass">
111
+ <div :class="uploaderContentClass">
112
+ <div :class="uploaderStateIconClass">
113
+ <slot name="state-icon-default" v-if="stateDefault">
114
+ <PlusIcon />
115
+ </slot>
116
+ <slot name="state-icon-uploading" v-if="stateUploading">
117
+ <Loader />
118
+ </slot>
119
+ <slot name="state-icon-processing" v-if="stateProcessing">
120
+ <Loader />
121
+ </slot>
122
+ <slot name="state-icon-error" v-if="stateError">
123
+ <ExclamationCircleIcon />
124
+ </slot>
125
+ <slot name="state-icon-success" v-if="stateSuccess">
126
+ <DocumentIcon />
127
+ </slot>
128
+ </div>
129
+
130
+ <div class="rsui-form-field-uploader__state-text">
131
+ <slot name="state-text-default" v-if="stateDefault">
132
+ Media
133
+ </slot>
134
+ <slot name="state-text-uploading" v-if="stateUploading">
135
+ Uploading...
136
+ </slot>
137
+ <slot name="state-text-processing" v-if="stateProcessing">
138
+ Processing upload...
139
+ </slot>
140
+ <slot name="state-text-error" v-if="stateError">
141
+ Something went wrong
142
+ </slot>
143
+ <slot name="state-text-success" v-if="stateSuccess"></slot>
144
+ </div>
145
+
146
+ <div v-if="stateSuccess && $slots['state-file-size']"
147
+ class="rsui-form-field-uploader__state-file-size"
148
+ >
149
+ <slot name="state-file-size"></slot>
150
+ </div>
151
+
152
+ <div v-if="!stateSuccess"
153
+ class="rsui-form-field-uploader__uploader"
154
+ >
155
+ <slot name="uploader"
156
+ :setStateDefault="setStateDefault"
157
+ :setStateUploading="setStateUploading"
158
+ :setStateProcessing="setStateProcessing"
159
+ :setStateError="setStateError"
160
+ :setStateSuccess="setStateSuccess"
161
+ ></slot>
162
+ </div>
163
+
164
+ </div>
165
+ <div v-if="stateSuccess && removable"
166
+ class="rsui-form-field-uploader__action"
167
+ >
168
+ <div class="rsui-form-field-uploader__action-icon"
169
+ @click="removeAction"
170
+ >
171
+ <slot name="state-action">
172
+ <XMarkIcon />
173
+ </slot>
174
+ </div>
175
+ </div>
176
+ </div>
177
+ </FormFieldSlot>
178
+ </template>
179
+ <style lang="scss" scoped>
180
+ .rsui-form-field-uploader {
181
+ &__container {
182
+ @apply w-fit max-w-80 bg-rsui-grey-100;
183
+ @apply relative select-none;
184
+ @apply rounded-md border border-rsui-grey-300 border-dashed;
185
+ @apply flex flex-nowrap justify-center items-center gap-4;
186
+ &--success {
187
+ @apply border-rsui-light border-solid pr-4;
188
+ }
189
+ }
190
+
191
+ &__content {
192
+ @apply relative flex flex-nowrap justify-center items-center gap-4;
193
+ @apply px-4 py-2.5 text-rsui-default;
194
+
195
+ &--success {
196
+ @apply pr-0;
197
+ }
198
+ }
199
+
200
+ &__state-icon {
201
+ @apply shrink-0 size-6;
202
+
203
+ &--success {
204
+ @apply text-rsui-light;
205
+ }
206
+
207
+ :deep(svg) {
208
+ @apply size-6 stroke-2;
209
+ }
210
+ }
211
+
212
+ &__state-text {
213
+ @apply line-clamp-2;
214
+ }
215
+
216
+ &__state-file-size {
217
+ @apply shrink-0 text-rsui-medium;
218
+ }
219
+
220
+ &__uploader {
221
+ @apply size-full absolute inset-0 z-1 cursor-pointer;
222
+
223
+ :deep(*) {
224
+ @apply size-full cursor-pointer;
225
+ }
226
+ }
227
+
228
+ &__action {
229
+ @apply shrink-0 size-6;
230
+ }
231
+
232
+ &__action-icon {
233
+ @apply size-6 cursor-pointer text-rsui-light;
234
+
235
+ :deep(svg) {
236
+ @apply size-6 stroke-2;
237
+ }
238
+ }
239
+ }
240
+ </style>
@@ -11,7 +11,7 @@ import FormFieldSlot from './FormFieldSlot.vue'
11
11
  import FormFieldText from './FormFieldText.vue'
12
12
  import FormFieldTextarea from './FormFieldTextarea.vue'
13
13
  import FormFieldTextSuffix from './FormFieldTextSuffix.vue'
14
-
14
+ import FormFieldUploaderWrapper from './FormFieldUploaderWrapper.vue'
15
15
  export {
16
16
  FormFieldCheckbox,
17
17
  FormFieldEmail,
@@ -26,4 +26,5 @@ export {
26
26
  FormFieldText,
27
27
  FormFieldTextarea,
28
28
  FormFieldTextSuffix,
29
- }
29
+ FormFieldUploaderWrapper,
30
+ }
@@ -31,7 +31,7 @@ const defaultColor = computed(() => !props.secondary && !props.tertiary && !prop
31
31
  const loaderClass = computed(() => [
32
32
  'rsui-loader',
33
33
  {
34
- 'rsui-loader--primary': props.primary || defaultColor.value,
34
+ 'rsui-loader--primary': props.primary,
35
35
  'rsui-loader--secondary': props.secondary,
36
36
  'rsui-loader--tertiary': props.tertiary,
37
37
  'rsui-loader--danger': props.danger,
@@ -51,6 +51,9 @@ useLottie(loaderElement, LottieCubes)
51
51
  <style lang="scss" scoped>
52
52
  .rsui-loader {
53
53
  @apply max-w-24 max-h-24 min-w-3 min-h-3 transition;
54
+ :deep(path) {
55
+ @apply fill-rsui-default;
56
+ }
54
57
  &--primary {
55
58
  :deep(path) {
56
59
  @apply fill-primary;