@300codes/design-system 1.2.10 → 1.2.12
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,9 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import type { ButtonHTMLAttributes } from 'vue';
|
|
2
3
|
import type { IconSize } from '../../types/icon';
|
|
3
4
|
import BaseIcon from '../BaseIcon/BaseIcon.vue';
|
|
4
5
|
|
|
5
6
|
export interface FlatIconButtonProps {
|
|
6
7
|
iconName: string;
|
|
8
|
+
type?: ButtonHTMLAttributes['type'],
|
|
7
9
|
iconPath?: string;
|
|
8
10
|
iconSize?: IconSize;
|
|
9
11
|
label: string;
|
|
@@ -11,6 +13,7 @@ export interface FlatIconButtonProps {
|
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
withDefaults(defineProps<FlatIconButtonProps>(), {
|
|
16
|
+
type: 'button',
|
|
14
17
|
iconPath: '/icons',
|
|
15
18
|
iconSize: 'sm',
|
|
16
19
|
disabled: false,
|
|
@@ -23,7 +26,7 @@ const emit = defineEmits<{
|
|
|
23
26
|
|
|
24
27
|
<template>
|
|
25
28
|
<button
|
|
26
|
-
type="
|
|
29
|
+
:type="type"
|
|
27
30
|
:class="['flatIconButton inline-flex items-center justify-center', disabled ? 'cursor-not-allowed' : 'cursor-pointer']"
|
|
28
31
|
:aria-label="label"
|
|
29
32
|
:disabled="disabled"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, nextTick } from 'vue';
|
|
3
3
|
import TextInput from '../TextInput/TextInput.vue';
|
|
4
|
+
import FlatIconButton from '../FlatIconButton/FlatIconButton.vue';
|
|
4
5
|
|
|
5
6
|
export interface SearchInputProps {
|
|
6
7
|
name: string;
|
|
@@ -11,13 +12,11 @@ export interface SearchInputProps {
|
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
size?: 'sm' | 'md' | 'lg';
|
|
13
14
|
iconPath?: string;
|
|
14
|
-
clearAriaLabel?: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
withDefaults(defineProps<SearchInputProps>(), {
|
|
18
18
|
size: 'md',
|
|
19
19
|
iconPath: '/icons',
|
|
20
|
-
clearAriaLabel: 'Clear search',
|
|
21
20
|
id: undefined,
|
|
22
21
|
placeholder: undefined,
|
|
23
22
|
autocomplete: undefined,
|
|
@@ -34,44 +33,50 @@ const model = defineModel<string>({ required: true });
|
|
|
34
33
|
|
|
35
34
|
const textInputRef = ref<{ el: HTMLInputElement | undefined }>();
|
|
36
35
|
|
|
37
|
-
async function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
textInputRef.value?.el?.focus();
|
|
43
|
-
} else {
|
|
44
|
-
emit('enter');
|
|
45
|
-
}
|
|
36
|
+
async function clearSearch() {
|
|
37
|
+
model.value = '';
|
|
38
|
+
emit('clear');
|
|
39
|
+
await nextTick();
|
|
40
|
+
textInputRef.value?.el?.focus();
|
|
46
41
|
}
|
|
47
42
|
</script>
|
|
48
43
|
|
|
49
44
|
<template>
|
|
50
|
-
<
|
|
51
|
-
|
|
45
|
+
<TextInput
|
|
46
|
+
:id="id"
|
|
47
|
+
ref="textInputRef"
|
|
48
|
+
v-model="model"
|
|
49
|
+
:name="name"
|
|
50
|
+
:placeholder="placeholder"
|
|
51
|
+
:autocomplete="autocomplete"
|
|
52
|
+
:required="required"
|
|
53
|
+
:disabled="disabled"
|
|
54
|
+
:size="size"
|
|
55
|
+
:icon-right="{ name: 'search', iconPath: iconPath, size: 'md', type: 'submit' }"
|
|
52
56
|
role="search"
|
|
57
|
+
:class="['searchInput', { 'searchInput--typing': model.length }]"
|
|
58
|
+
@focus="emit('focus', $event)"
|
|
59
|
+
@blur="emit('blur', $event)"
|
|
60
|
+
@enter="emit('enter')"
|
|
61
|
+
@click-icon="emit('enter')"
|
|
53
62
|
>
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
@focus="emit('focus', $event)"
|
|
67
|
-
@blur="emit('blur', $event)"
|
|
68
|
-
@enter="emit('enter')"
|
|
69
|
-
@click-icon="handleClickIcon"
|
|
70
|
-
/>
|
|
71
|
-
</div>
|
|
63
|
+
<template #after>
|
|
64
|
+
<FlatIconButton
|
|
65
|
+
v-if="model.length"
|
|
66
|
+
icon-size="md"
|
|
67
|
+
icon-name="close-circle"
|
|
68
|
+
:icon-path="iconPath"
|
|
69
|
+
label="Wyczyść pole wyszukiwania"
|
|
70
|
+
class="absolute top-1/2 -translate-y-1/2 right-12"
|
|
71
|
+
@click="clearSearch"
|
|
72
|
+
/>
|
|
73
|
+
</template>
|
|
74
|
+
</TextInput>
|
|
72
75
|
</template>
|
|
73
76
|
|
|
74
77
|
<style scoped>
|
|
78
|
+
@reference "tailwindcss";
|
|
79
|
+
|
|
75
80
|
.searchInput {
|
|
76
81
|
--input-bg: var(--searchInput-bg, #f3f5f7);
|
|
77
82
|
--input-border-color: var(--searchInput-border, #b0babf);
|
|
@@ -80,4 +85,8 @@ async function handleClickIcon(side: 'left' | 'right') {
|
|
|
80
85
|
--input-radius: var(--searchInput-radius, 3rem);
|
|
81
86
|
--input-radius-mobile: var(--searchInput-radius, 3rem);
|
|
82
87
|
}
|
|
88
|
+
|
|
89
|
+
.searchInput--typing :deep(.textInput__field) {
|
|
90
|
+
@apply pr-18;
|
|
91
|
+
}
|
|
83
92
|
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, ref, type Ref } from 'vue';
|
|
2
|
+
import { ButtonHTMLAttributes, computed, ref, type Ref } from 'vue';
|
|
3
3
|
import type { IconSize } from '../../types/icon';
|
|
4
4
|
import FlatIconButton from '../FlatIconButton/FlatIconButton.vue';
|
|
5
5
|
|
|
@@ -8,6 +8,7 @@ export type FilterType = 'number' | 'number-dash' | 'alpha' | 'alpha-space';
|
|
|
8
8
|
|
|
9
9
|
export interface TextInputIcon {
|
|
10
10
|
name: string;
|
|
11
|
+
type?: ButtonHTMLAttributes['type'];
|
|
11
12
|
iconPath?: string;
|
|
12
13
|
size?: IconSize;
|
|
13
14
|
ariaLabel?: string;
|
|
@@ -122,27 +123,31 @@ defineExpose<{ el: Ref<HTMLInputElement | undefined> }>({ el });
|
|
|
122
123
|
@focus="onFocus"
|
|
123
124
|
@input="onInput"
|
|
124
125
|
@keyup.enter="emit('enter')"
|
|
125
|
-
|
|
126
|
+
/>
|
|
126
127
|
|
|
127
128
|
<FlatIconButton
|
|
128
129
|
v-if="iconLeft"
|
|
130
|
+
:type="iconLeft.type"
|
|
129
131
|
:icon-name="iconLeft.name"
|
|
130
132
|
:icon-path="iconLeft.iconPath"
|
|
131
133
|
:icon-size="iconLeft.size"
|
|
132
134
|
:label="iconLeft.ariaLabel || iconLeft.name"
|
|
133
|
-
:class="['absolute top-1/2 -translate-y-1/2 left-
|
|
135
|
+
:class="['absolute top-1/2 -translate-y-1/2 left-4', iconLeft.class]"
|
|
134
136
|
@click="emit('clickIcon', 'left')"
|
|
135
137
|
/>
|
|
136
138
|
|
|
137
139
|
<FlatIconButton
|
|
138
140
|
v-if="iconRight"
|
|
141
|
+
:type="iconRight.type"
|
|
139
142
|
:icon-name="iconRight.name"
|
|
140
143
|
:icon-path="iconRight.iconPath"
|
|
141
144
|
:icon-size="iconRight.size"
|
|
142
145
|
:label="iconRight.ariaLabel || iconRight.name"
|
|
143
|
-
:class="['absolute top-1/2 -translate-y-1/2 right-
|
|
146
|
+
:class="['absolute top-1/2 -translate-y-1/2 right-4', iconRight.class]"
|
|
144
147
|
@click="emit('clickIcon', 'right')"
|
|
145
148
|
/>
|
|
149
|
+
|
|
150
|
+
<slot name="after" />
|
|
146
151
|
</div>
|
|
147
152
|
</template>
|
|
148
153
|
|