@weni/unnnic-system 2.34.1-alpha.0 → 2.34.1-alpha.1

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": "@weni/unnnic-system",
3
- "version": "2.34.1-alpha.0",
3
+ "version": "2.34.1-alpha.1",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -118,9 +118,6 @@ export default {
118
118
  return !!this.$slots.label;
119
119
  },
120
120
  },
121
- methods: {
122
- fullySanitize,
123
- },
124
121
  watch: {
125
122
  val() {
126
123
  this.$emit('update:modelValue', fullySanitize(this.val));
@@ -132,6 +129,9 @@ export default {
132
129
  mounted() {
133
130
  this.val = this.modelValue;
134
131
  },
132
+ methods: {
133
+ fullySanitize,
134
+ },
135
135
  };
136
136
  </script>
137
137
 
@@ -0,0 +1,195 @@
1
+ <template>
2
+ <section
3
+ v-onClickOutside="() => (active = false)"
4
+ class="unnnic-select-time"
5
+ >
6
+ <DropdownSkeleton
7
+ ref="dropdown-skeleton"
8
+ type="manual"
9
+ :modelValue="active"
10
+ position="bottom"
11
+ >
12
+ <TextInput
13
+ :modelValue="modelValue"
14
+ :iconRight="active ? 'keyboard_arrow_up' : 'keyboard_arrow_down'"
15
+ @focus="active = true"
16
+ @blur="handleBlur"
17
+ @update:model-value="handleInput"
18
+ @keydown.enter="handleBlur({ close: true })"
19
+ />
20
+
21
+ <template #inside="props">
22
+ <section
23
+ :style="{ width: props.width }"
24
+ class="unnnic-select-time__options"
25
+ >
26
+ <section
27
+ v-for="hour in hoursTimes"
28
+ :ref="`hour-${hour.value}`"
29
+ :key="hour.value"
30
+ :class="{
31
+ 'unnnic-select-time__options__item': true,
32
+ 'unnnic-select-time__options__item--selected':
33
+ modelValue === hour.value,
34
+ }"
35
+ @click="handleClickTimeOption(hour.value)"
36
+ >
37
+ {{ hour.label }}
38
+ </section>
39
+ </section>
40
+ </template>
41
+ </DropdownSkeleton>
42
+ </section>
43
+ </template>
44
+
45
+ <script>
46
+ import { vOnClickOutside } from '@vueuse/components';
47
+
48
+ import DropdownSkeleton from '../Dropdown/DropdownSkeleton.vue';
49
+ import TextInput from '../Input/TextInput.vue';
50
+ import { hoursTimes } from '../../utils/hours';
51
+
52
+ export default {
53
+ name: 'SelectTime',
54
+ components: {
55
+ DropdownSkeleton,
56
+ TextInput,
57
+ },
58
+
59
+ directives: {
60
+ onClickOutside: vOnClickOutside,
61
+ },
62
+ props: {
63
+ modelValue: {
64
+ type: String,
65
+ default: '',
66
+ },
67
+ },
68
+ emits: ['update:modelValue'],
69
+ data() {
70
+ return {
71
+ active: false,
72
+ hoursTimes,
73
+ };
74
+ },
75
+ methods: {
76
+ handleInput(text) {
77
+ const { value } =
78
+ this.hoursTimes.find((hour) => hour.value.includes(text)) || {};
79
+
80
+ if (value) {
81
+ const hourRef = this.$refs[`hour-${value}`][0];
82
+ if (hourRef) {
83
+ hourRef.scrollIntoView({ behavior: 'smooth' });
84
+ }
85
+ }
86
+
87
+ this.$emit('update:modelValue', text);
88
+ },
89
+
90
+ handleBlur({ close = false } = {}) {
91
+ if (this.modelValue) {
92
+ const cleanValue = this.modelValue.replace(/[^0-9]/g, '');
93
+
94
+ if (cleanValue.length > 0) {
95
+ let formattedTime = '';
96
+
97
+ if (cleanValue.length === 4) {
98
+ // Format: 0101 -> 01:01, 1310 -> 13:10
99
+ const hours = cleanValue.substring(0, 2);
100
+ const minutes = cleanValue.substring(2, 4);
101
+
102
+ if (parseInt(hours) <= 23 && parseInt(minutes) <= 59) {
103
+ formattedTime = `${hours}:${minutes}`;
104
+ }
105
+ } else if (cleanValue.length === 3) {
106
+ // Format: 123 -> 01:23
107
+ const hours = `0${cleanValue.substring(0, 1)}`;
108
+ const minutes = cleanValue.substring(1, 3);
109
+
110
+ if (parseInt(minutes) <= 59) {
111
+ formattedTime = `${hours}:${minutes}`;
112
+ }
113
+ } else if (cleanValue.length === 2) {
114
+ // Format: 12 -> 12:00
115
+ const hours = cleanValue;
116
+ formattedTime = `${hours}:00`;
117
+ } else if (cleanValue.length === 1) {
118
+ // Format: 1 -> 01:00
119
+ const hours = `0${cleanValue}`;
120
+ formattedTime = `${hours}:00`;
121
+ }
122
+
123
+ this.$emit('update:modelValue', formattedTime);
124
+ }
125
+ }
126
+
127
+ if (close) {
128
+ this.active = false;
129
+ }
130
+ },
131
+ handleClickTimeOption(value) {
132
+ this.$emit('update:modelValue', value);
133
+ this.active = false;
134
+ },
135
+ },
136
+ };
137
+ </script>
138
+
139
+ <style lang="scss" scoped>
140
+ @use '@/assets/scss/unnnic' as *;
141
+ .unnnic-select-time {
142
+ &__options {
143
+ @function calc-max-height($value) {
144
+ @return ($value * $unnnic-font-size) - ($unnnic-spacing-xs * 2);
145
+ }
146
+ margin-top: $unnnic-spacing-nano;
147
+ border-radius: $unnnic-border-radius-sm;
148
+ box-shadow: $unnnic-shadow-level-near;
149
+ background-color: $unnnic-color-background-snow;
150
+ cursor: pointer;
151
+ display: grid;
152
+ max-height: calc-max-height(9.25);
153
+ overflow-y: auto;
154
+
155
+ &__item {
156
+ margin: 0px $unnnic-spacing-nano;
157
+ background-color: $unnnic-color-background-snow;
158
+ padding: $unnnic-spacing-stack-nano $unnnic-inline-xs;
159
+ max-width: 100%;
160
+ font-family: $unnnic-font-family-secondary;
161
+ color: $unnnic-color-neutral-darkest;
162
+ font-weight: $unnnic-font-weight-regular;
163
+
164
+ white-space: nowrap;
165
+ text-overflow: ellipsis;
166
+ overflow: hidden;
167
+ -webkit-line-clamp: 1;
168
+
169
+ &:hover {
170
+ border-radius: $unnnic-border-radius-sm;
171
+ background-color: $unnnic-color-neutral-light;
172
+ }
173
+
174
+ &--selected {
175
+ color: $unnnic-color-weni-600;
176
+ font-weight: $unnnic-font-weight-bold;
177
+ }
178
+ }
179
+
180
+ &::-webkit-scrollbar {
181
+ width: $unnnic-spacing-inline-nano;
182
+ }
183
+
184
+ &::-webkit-scrollbar-thumb {
185
+ background: $unnnic-color-neutral-cleanest;
186
+ border-radius: $unnnic-border-radius-pill;
187
+ }
188
+
189
+ &::-webkit-scrollbar-track {
190
+ background: $unnnic-color-neutral-soft;
191
+ border-radius: $unnnic-border-radius-pill;
192
+ }
193
+ }
194
+ }
195
+ </style>
@@ -86,6 +86,7 @@ import ModalNext from './ModalNext/ModalNext.vue';
86
86
  import ModalDialog from './ModalDialog/ModalDialog.vue';
87
87
  import Tour from './Tour/Tour.vue';
88
88
  import Navigator from './Navigator/index.vue';
89
+ import SelectTime from './SelectTime/index.vue';
89
90
 
90
91
  export const components = {
91
92
  unnnicFormElement: formElement,
@@ -177,6 +178,7 @@ export const components = {
177
178
  unnnicTableNext: TableNext,
178
179
  unnnicTour: Tour,
179
180
  unnnicNavigator: Navigator,
181
+ unnnicSelectTime: SelectTime,
180
182
  };
181
183
 
182
184
  export const unnnicFontSize = fontSize;
@@ -269,3 +271,4 @@ export const unnnicDrawer = Drawer;
269
271
  export const unnnicTableNext = TableNext;
270
272
  export const unnnicTour = Tour;
271
273
  export const unnnicNavigator = Navigator;
274
+ export const unnnicSelectTime = SelectTime;
@@ -187,8 +187,8 @@ export const MessageStatus = {
187
187
  components: { UnnnicChatsMessage },
188
188
  template: `
189
189
  <div style="display: flex; flex-direction: column; gap: 12px">
190
- <UnnnicChatsMessage v-bind="args" status="send">
191
- Send status
190
+ <UnnnicChatsMessage v-bind="args" status="sent">
191
+ Sent status
192
192
  </UnnnicChatsMessage>
193
193
  <UnnnicChatsMessage v-bind="args" status="received">
194
194
  Received status
@@ -0,0 +1,25 @@
1
+ import unnnicSelectTime from '../components/SelectTime/index.vue';
2
+
3
+ export default {
4
+ title: 'Select/SelectTime',
5
+ component: unnnicSelectTime,
6
+ argTypes: {},
7
+ render: (args) => ({
8
+ components: {
9
+ unnnicSelectTime,
10
+ },
11
+ setup() {
12
+ return { args };
13
+ },
14
+ data() {
15
+ return {
16
+ exampleValue: '',
17
+ };
18
+ },
19
+ template: `
20
+ <unnnicSelectTime v-bind="args" v-model="exampleValue" />
21
+ `,
22
+ }),
23
+ };
24
+
25
+ export const Default = {};
@@ -0,0 +1,388 @@
1
+ const hoursTimes = [
2
+ {
3
+ label: '00:00',
4
+ value: '00:00',
5
+ },
6
+ {
7
+ label: '00:15',
8
+ value: '00:15',
9
+ },
10
+ {
11
+ label: '00:30',
12
+ value: '00:30',
13
+ },
14
+ {
15
+ label: '00:45',
16
+ value: '00:45',
17
+ },
18
+ {
19
+ label: '01:00',
20
+ value: '01:00',
21
+ },
22
+ {
23
+ label: '01:15',
24
+ value: '01:15',
25
+ },
26
+ {
27
+ label: '01:30',
28
+ value: '01:30',
29
+ },
30
+ {
31
+ label: '01:45',
32
+ value: '01:45',
33
+ },
34
+ {
35
+ label: '02:00',
36
+ value: '02:00',
37
+ },
38
+ {
39
+ label: '02:15',
40
+ value: '02:15',
41
+ },
42
+ {
43
+ label: '02:30',
44
+ value: '02:30',
45
+ },
46
+ {
47
+ label: '02:45',
48
+ value: '02:45',
49
+ },
50
+ {
51
+ label: '03:00',
52
+ value: '03:00',
53
+ },
54
+ {
55
+ label: '03:15',
56
+ value: '03:15',
57
+ },
58
+ {
59
+ label: '03:30',
60
+ value: '03:30',
61
+ },
62
+ {
63
+ label: '03:45',
64
+ value: '03:45',
65
+ },
66
+ {
67
+ label: '04:00',
68
+ value: '04:00',
69
+ },
70
+ {
71
+ label: '04:15',
72
+ value: '04:15',
73
+ },
74
+ {
75
+ label: '04:30',
76
+ value: '04:30',
77
+ },
78
+ {
79
+ label: '04:45',
80
+ value: '04:45',
81
+ },
82
+ {
83
+ label: '05:00',
84
+ value: '05:00',
85
+ },
86
+ {
87
+ label: '05:15',
88
+ value: '05:15',
89
+ },
90
+ {
91
+ label: '05:30',
92
+ value: '05:30',
93
+ },
94
+ {
95
+ label: '05:45',
96
+ value: '05:45',
97
+ },
98
+ {
99
+ label: '06:00',
100
+ value: '06:00',
101
+ },
102
+ {
103
+ label: '06:15',
104
+ value: '06:15',
105
+ },
106
+ {
107
+ label: '06:30',
108
+ value: '06:30',
109
+ },
110
+ {
111
+ label: '06:45',
112
+ value: '06:45',
113
+ },
114
+ {
115
+ label: '07:00',
116
+ value: '07:00',
117
+ },
118
+ {
119
+ label: '07:15',
120
+ value: '07:15',
121
+ },
122
+ {
123
+ label: '07:30',
124
+ value: '07:30',
125
+ },
126
+ {
127
+ label: '07:45',
128
+ value: '07:45',
129
+ },
130
+ {
131
+ label: '08:00',
132
+ value: '08:00',
133
+ },
134
+ {
135
+ label: '08:15',
136
+ value: '08:15',
137
+ },
138
+ {
139
+ label: '08:30',
140
+ value: '08:30',
141
+ },
142
+ {
143
+ label: '08:45',
144
+ value: '08:45',
145
+ },
146
+ {
147
+ label: '09:00',
148
+ value: '09:00',
149
+ },
150
+ {
151
+ label: '09:15',
152
+ value: '09:15',
153
+ },
154
+ {
155
+ label: '09:30',
156
+ value: '09:30',
157
+ },
158
+ {
159
+ label: '09:45',
160
+ value: '09:45',
161
+ },
162
+ {
163
+ label: '10:00',
164
+ value: '10:00',
165
+ },
166
+ {
167
+ label: '10:15',
168
+ value: '10:15',
169
+ },
170
+ {
171
+ label: '10:30',
172
+ value: '10:30',
173
+ },
174
+ {
175
+ label: '10:45',
176
+ value: '10:45',
177
+ },
178
+ {
179
+ label: '11:00',
180
+ value: '11:00',
181
+ },
182
+ {
183
+ label: '11:15',
184
+ value: '11:15',
185
+ },
186
+ {
187
+ label: '11:30',
188
+ value: '11:30',
189
+ },
190
+ {
191
+ label: '11:45',
192
+ value: '11:45',
193
+ },
194
+ {
195
+ label: '12:00',
196
+ value: '12:00',
197
+ },
198
+ {
199
+ label: '12:15',
200
+ value: '12:15',
201
+ },
202
+ {
203
+ label: '12:30',
204
+ value: '12:30',
205
+ },
206
+ {
207
+ label: '12:45',
208
+ value: '12:45',
209
+ },
210
+ {
211
+ label: '13:00',
212
+ value: '13:00',
213
+ },
214
+ {
215
+ label: '13:15',
216
+ value: '13:15',
217
+ },
218
+ {
219
+ label: '13:30',
220
+ value: '13:30',
221
+ },
222
+ {
223
+ label: '13:45',
224
+ value: '13:45',
225
+ },
226
+ {
227
+ label: '14:00',
228
+ value: '14:00',
229
+ },
230
+ {
231
+ label: '14:15',
232
+ value: '14:15',
233
+ },
234
+ {
235
+ label: '14:30',
236
+ value: '14:30',
237
+ },
238
+ {
239
+ label: '14:45',
240
+ value: '14:45',
241
+ },
242
+ {
243
+ label: '15:00',
244
+ value: '15:00',
245
+ },
246
+ {
247
+ label: '15:15',
248
+ value: '15:15',
249
+ },
250
+ {
251
+ label: '15:30',
252
+ value: '15:30',
253
+ },
254
+ {
255
+ label: '15:45',
256
+ value: '15:45',
257
+ },
258
+ {
259
+ label: '16:00',
260
+ value: '16:00',
261
+ },
262
+ {
263
+ label: '16:15',
264
+ value: '16:15',
265
+ },
266
+ {
267
+ label: '16:30',
268
+ value: '16:30',
269
+ },
270
+ {
271
+ label: '16:45',
272
+ value: '16:45',
273
+ },
274
+ {
275
+ label: '17:00',
276
+ value: '17:00',
277
+ },
278
+ {
279
+ label: '17:15',
280
+ value: '17:15',
281
+ },
282
+ {
283
+ label: '17:30',
284
+ value: '17:30',
285
+ },
286
+ {
287
+ label: '17:45',
288
+ value: '17:45',
289
+ },
290
+ {
291
+ label: '18:00',
292
+ value: '18:00',
293
+ },
294
+ {
295
+ label: '18:15',
296
+ value: '18:15',
297
+ },
298
+ {
299
+ label: '18:30',
300
+ value: '18:30',
301
+ },
302
+ {
303
+ label: '18:45',
304
+ value: '18:45',
305
+ },
306
+ {
307
+ label: '19:00',
308
+ value: '19:00',
309
+ },
310
+ {
311
+ label: '19:15',
312
+ value: '19:15',
313
+ },
314
+ {
315
+ label: '19:30',
316
+ value: '19:30',
317
+ },
318
+ {
319
+ label: '19:45',
320
+ value: '19:45',
321
+ },
322
+ {
323
+ label: '20:00',
324
+ value: '20:00',
325
+ },
326
+ {
327
+ label: '20:15',
328
+ value: '20:15',
329
+ },
330
+ {
331
+ label: '20:30',
332
+ value: '20:30',
333
+ },
334
+ {
335
+ label: '20:45',
336
+ value: '20:45',
337
+ },
338
+ {
339
+ label: '21:00',
340
+ value: '21:00',
341
+ },
342
+ {
343
+ label: '21:15',
344
+ value: '21:15',
345
+ },
346
+ {
347
+ label: '21:30',
348
+ value: '21:30',
349
+ },
350
+ {
351
+ label: '21:45',
352
+ value: '21:45',
353
+ },
354
+ {
355
+ label: '22:00',
356
+ value: '22:00',
357
+ },
358
+ {
359
+ label: '22:15',
360
+ value: '22:15',
361
+ },
362
+ {
363
+ label: '22:30',
364
+ value: '22:30',
365
+ },
366
+ {
367
+ label: '22:45',
368
+ value: '22:45',
369
+ },
370
+ {
371
+ label: '23:00',
372
+ value: '23:00',
373
+ },
374
+ {
375
+ label: '23:15',
376
+ value: '23:15',
377
+ },
378
+ {
379
+ label: '23:30',
380
+ value: '23:30',
381
+ },
382
+ {
383
+ label: '23:45',
384
+ value: '23:45',
385
+ },
386
+ ];
387
+
388
+ export { hoursTimes };