its_ui_vite 1.0.4 → 1.0.6

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/README.md CHANGED
@@ -78,6 +78,7 @@ slots: ['без имени']
78
78
 
79
79
  width?: string,
80
80
  type?: string,
81
+ iconPosition?: Array<'left' | 'right'>,
81
82
  size?: 'lg' | 'md' | 'sm',
82
83
  name?: string,
83
84
  disabled?: Boolean,
@@ -116,6 +117,8 @@ slots: ['без имени' <!-- есть дефольное значение (p
116
117
  variant: 'default' | 'multiple',
117
118
  size?: 'lg' | 'md' | 'sm',
118
119
  placeholder?: string,
120
+ iconPosition?: Array<'left' | 'right'>,
121
+ iconName?: string,
119
122
  disabled?: Boolean,
120
123
  autocomplete?: Boolean,
121
124
  selectAll?: Boolean,
@@ -123,6 +126,8 @@ slots: ['без имени' <!-- есть дефольное значение (p
123
126
  locale?: string,
124
127
  transformVal?: Boolean,
125
128
  }
129
+
130
+ slots: ['customIcon' <!-- есть дефольное значение -->]
126
131
  ```
127
132
 
128
133
  * CTooltip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "its_ui_vite",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "main": "./src/libIndex.js",
5
5
  "module": "./src/libIndex.js",
6
6
  "files": [
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="svg" v-html="iconHTML">
2
+ <div class="svg" :style="`--svg-size: ${size}px`" v-html="iconHTML">
3
3
 
4
4
  </div>
5
5
  </template>
@@ -21,6 +21,14 @@ const iconHTML = computed(() => {
21
21
  });
22
22
 
23
23
  </script>
24
- <style lang="scss">
24
+ <style lang="scss" scoped>
25
+ .svg {
26
+ width: var(--svg-size, 20px);
27
+ height: var(--svg-size, 20px);
28
+ }
25
29
 
30
+ .svg:deep(svg) {
31
+ width: var(--svg-size, 20px);
32
+ height: var(--svg-size, 20px);
33
+ }
26
34
  </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :class="['c-input__wrap', status, size, {disabled}]" :style="`--c-input-width: ${width}`">
2
+ <div :class="['c-input__wrap', status, size, iconPositionClass, {disabled}]" :style="`--c-input-width: ${width}`">
3
3
  <input
4
4
  class="c-input"
5
5
  :type="type"
@@ -29,11 +29,12 @@
29
29
  </template>
30
30
 
31
31
  <script setup lang="ts">
32
- import { InputTypeHTMLAttribute } from 'vue';
32
+ import { computed, InputTypeHTMLAttribute } from 'vue'
33
33
  import CIcon from './CIcons/index.vue'
34
34
 
35
35
  type TProps = {
36
36
  status?: 'static' | 'focus' | 'error' | 'success',
37
+ iconPosition?: Array<'left' | 'right'>
37
38
  size?: 'lg' | 'md' | 'sm',
38
39
  width?: string,
39
40
  disabled?: boolean,
@@ -43,7 +44,7 @@ type TProps = {
43
44
  modelValue?: any,
44
45
  }
45
46
 
46
- const pops = withDefaults(defineProps<TProps>(), {
47
+ const props = withDefaults(defineProps<TProps>(), {
47
48
  status: 'static',
48
49
  size: 'lg',
49
50
  width: '350px',
@@ -58,6 +59,11 @@ const emits = defineEmits<{
58
59
  (name: 'update:modelValue', value: any): void
59
60
  }>()
60
61
 
62
+ const iconPositionClass = computed(() => {
63
+ const strClass = props?.iconPosition?.map((iconPosition) => `icon-${iconPosition}`).join(' ')
64
+ return strClass || ''
65
+ })
66
+
61
67
  </script>
62
68
 
63
69
  <style lang="scss">
@@ -148,28 +154,60 @@ const emits = defineEmits<{
148
154
  // prop.size
149
155
  &.lg {
150
156
  --padding: 15px 25px;
157
+ --padding-icon: 45px;
158
+ --distance-icon: 15px;
151
159
  --font-size: 21px;
152
160
  --radius: 8px
153
161
  }
154
162
 
155
163
  &.md {
156
164
  --padding: 10px 17px;
165
+ --padding-icon: 45px;
166
+ --distance-icon: 15px;
157
167
  --font-size: 21px;
158
168
  --radius: 5px
159
169
  }
160
170
 
161
171
  &.sm {
162
172
  --padding: 10px 12px;
173
+ --padding-icon: 40px;
174
+ --distance-icon: 10px;
163
175
  --font-size: 14px;
164
176
  --radius: 5px
165
177
  }
166
178
  // ./prop.size
179
+
180
+ // prop.iconPosition
181
+ &.icon-left {
182
+ .c-input {
183
+ padding-left: var(--padding-icon);
184
+ }
185
+
186
+ .c-input__custom-icon {
187
+ left: var(--distance-icon);
188
+ right: auto;
189
+ opacity: 1;
190
+ }
191
+ }
192
+
193
+ &.icon-right {
194
+ .c-input {
195
+ padding-right: var(--padding-icon);
196
+ }
197
+
198
+ .c-input__custom-icon {
199
+ opacity: 1;
200
+ pointer-events: all;
201
+ cursor: pointer;
202
+ }
203
+ }
204
+ // ./prop.iconPosition
167
205
  }
168
206
 
169
207
  &__icon {
170
208
  position: absolute;
171
209
  top: 50%;
172
- right: 15px;
210
+ right: var(--distance-icon);;
173
211
  transform: translate(0, -50%);
174
212
 
175
213
  display: flex;
@@ -4,9 +4,19 @@
4
4
  :style="`--transition: ${transition}ms; --width: ${width}; --list-indent-y: ${listIndentY}px`"
5
5
  :class="[classes.root, variant, size, { disabled }]"
6
6
  >
7
- <CInput :placeholder="activePlaceholder" :disabled="disabled" :size="size" :width="width" v-model.trim="findValue" :class="[classes.input, {open: isOpen}]">
7
+ <CInput
8
+ :placeholder="activePlaceholder"
9
+ :disabled="disabled"
10
+ :size="size"
11
+ :width="width"
12
+ :iconPosition="iconInfo.position.value"
13
+ v-model.trim="findValue"
14
+ :class="[classes.input, {open: isOpen}]"
15
+ >
8
16
  <template #customIcon>
9
- <CIcons :class="['c-select__inp_icon']" :iconId="isMultiple ? 'arrow' : 'lens'" />
17
+ <slot name="customIcon">
18
+ <CIcon :class="['c-select__inp_icon']" :size="24" :name="iconInfo.name.value" />
19
+ </slot>
10
20
  </template>
11
21
  </CInput>
12
22
 
@@ -19,7 +29,7 @@
19
29
  <CCheckbox
20
30
  :class="classes.option"
21
31
  size='sm'
22
- :modelValue="options.length === activeOptions.size"
32
+ :modelValue="options?.length === activeOptions.size"
23
33
  >
24
34
  <span class="c-select__list_item-text">
25
35
  {{ text.selectAll }}
@@ -54,9 +64,10 @@
54
64
  <script setup lang="ts">
55
65
  import CInput from './CInput.vue'
56
66
  import CCheckbox from './CCheckbox.vue'
57
- import CIcons from './CIcons/index.vue'
58
- import CScroll from './CScroll.vue';
67
+ import CIcon from './CIcons/CIcon.vue'
68
+ import CScroll from './CScroll.vue'
59
69
 
70
+ import { TIcon } from '../assets/icon/icons-manifest'
60
71
  import { fixDblEvent } from '../assets/js/helpers';
61
72
  import { computed, ref, watch, onMounted, onUnmounted } from 'vue';
62
73
 
@@ -75,6 +86,9 @@ type TProps = {
75
86
  autocomplete?: boolean,
76
87
  disabled?: boolean,
77
88
  transformVal?: boolean,
89
+ iconPosition?: Array<'left' | 'right'>,
90
+ iconName?: keyof TIcon,
91
+ isOpen?: boolean,
78
92
  locale?: 'rus' | 'usa' | 'tur' | 'spa',
79
93
  placeholder?: string,
80
94
  width?: string,
@@ -89,6 +103,7 @@ const props = withDefaults(defineProps<TProps>(), {
89
103
  autocomplete: false,
90
104
  disabled: false,
91
105
  transformVal: false,
106
+ isOpen: false,
92
107
  locale: 'rus',
93
108
  placeholder: 'выберите вариант',
94
109
  width: '100%',
@@ -96,15 +111,16 @@ const props = withDefaults(defineProps<TProps>(), {
96
111
  })
97
112
 
98
113
  const emit = defineEmits<{
99
- (name: 'update:modelValue', value: any[])
100
- (name: 'change_cselect', value: any[])
114
+ (name: 'update:modelValue', value: any[]),
115
+ (name: 'change_cselect', value: any[]),
116
+ (name: 'update:isOpen', value: boolean)
101
117
  }>();
102
118
 
103
119
  const transition = 200,
104
120
  listIndentY = 12
105
121
 
106
122
  let findValue = ref(''),
107
- isOpen = ref(false),
123
+ isOpen = ref(props.isOpen || false),
108
124
  scrollY = ref(0),
109
125
  root = ref(),
110
126
  activePlaceholder = ref(props.placeholder),
@@ -156,6 +172,22 @@ const text = computed(() => {
156
172
  return lang[props.locale]
157
173
  })
158
174
 
175
+ const iconInfo = {
176
+ position: computed(() => {
177
+ const defaultIconPosition: Array<'left' | 'right'> = [isMultiple.value ? 'right' : 'left'];
178
+ return props.iconPosition || defaultIconPosition
179
+ }),
180
+
181
+ name: computed(() => {
182
+ const strIconName = String(props?.iconName)
183
+ const propIcon = {[strIconName]: true}
184
+
185
+ const defaultIcon = isMultiple ? {'Dropdown': true} : {'Search': true}
186
+
187
+ return props.iconName ? propIcon : defaultIcon
188
+ })
189
+ }
190
+
159
191
  const foundOptions = computed(() => {
160
192
  const reg = new RegExp(findValue.value.replace(/\W/g, '\\$&'), 'i')
161
193
  scrollY.value = Math.random();
@@ -305,12 +337,14 @@ function handleClick(evt: MouseEvent) {
305
337
  if (isRoot && domElements) {
306
338
  setListPosition()
307
339
  isOpen.value = isToggle ? !isOpen.value : true
340
+ emit('update:isOpen', isOpen.value)
308
341
 
309
342
  return
310
343
  }
311
344
 
312
345
  if (isOpen.value) {
313
346
  isOpen.value = false
347
+ emit('update:isOpen', isOpen.value)
314
348
 
315
349
  if (isMultiple.value) dispatchEmit()
316
350
  }
@@ -349,35 +383,20 @@ function dispatchEmit() {
349
383
  }
350
384
 
351
385
  // prop.variant
352
- &.default {
353
- .c-select__inp .c-input {
354
- padding-left: var(--icon-indent);
355
- }
356
-
357
- .c-input__custom-icon {
358
- left: var(--icon-position);
359
- right: auto;
360
- }
361
- }
386
+ &.default {}
362
387
 
363
388
  &.multiple {
364
389
  .c-select__inp {
365
390
  &.open {
366
- .c-input__custom-icon svg {
391
+ .c-input__custom-icon .c-select__inp_icon svg {
367
392
  transform: rotate(0deg);
368
393
  }
369
394
  }
370
395
 
371
- .c-input {
372
- padding-right: var(--icon-indent);
373
- }
374
-
375
396
  .c-input__custom-icon {
376
- right: var(--icon-position);
377
-
378
397
  pointer-events: all;
379
398
 
380
- svg {
399
+ .c-select__inp_icon svg {
381
400
  transform: rotate(180deg);
382
401
  }
383
402
  }
@@ -538,7 +538,15 @@
538
538
  </div>
539
539
 
540
540
  <div class="table__item">
541
- <CInput v-model="inpError" :status="errorStatus" />
541
+ <CInput v-model="inpError" :status="errorStatus" />
542
+ </div>
543
+
544
+ <div class="table__item">
545
+ <CInput v-model="inpError" size="md" :icon-position="['right', 'left']" :status="errorStatus">
546
+ <template #customIcon>
547
+ <CIcon :name="{'Bar-chart': true}" />
548
+ </template>
549
+ </CInput>
542
550
  </div>
543
551
  </div>
544
552
  <!-- ./col -->
@@ -554,7 +562,11 @@
554
562
  </div>
555
563
 
556
564
  <div class="table__item">
557
- <CInput v-model="inpError" size="sm" :status="errorStatus" />
565
+ <CInput v-model="inpError" size="sm" :icon-position="['right', 'left']" :status="errorStatus">
566
+ <template #customIcon>
567
+ <CIcon :name="{'Bar-chart': true}" />
568
+ </template>
569
+ </CInput>
558
570
  </div>
559
571
  </div>
560
572
  <!-- ./col -->
@@ -715,9 +727,9 @@
715
727
 
716
728
  <!-- col -->
717
729
  <div class="table__col">
718
-
730
+ <h4>isOpen: {{ selectIsOpen }}</h4>
719
731
  <div class="table__item">
720
- <CSelect variant="multiple" @change_cselect="(evt) => log(['CSelect multiple', evt])" size="sm" :select-all="true" :options="option.slice(-2)" :model-value="VModelOption" />
732
+ <CSelect variant="multiple" @change_cselect="(evt) => log(['CSelect multiple', evt])" size="sm" :select-all="true" :options="option.slice(-2)" iconName="Cart" v-model:is-open="selectIsOpen" :model-value="VModelOption" />
721
733
  </div>
722
734
  <h2 @click="VModelOption.length ? VModelOption.splice(0) : VModelOption.push('jj889')">{{ VModelOption }}</h2>
723
735
 
@@ -927,6 +939,7 @@ export default {
927
939
  iconContent: iconContent,
928
940
 
929
941
  isToggleTabs: true,
942
+ selectIsOpen: false,
930
943
 
931
944
  option: [
932
945
  {