@milaboratories/uikit 1.2.18 → 1.2.19
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/CHANGELOG.md +6 -0
- package/dist/pl-uikit.js +1532 -1501
- package/dist/pl-uikit.umd.cjs +4 -4
- package/dist/src/components/PlDropdown/PlDropdown.vue.d.ts +5 -1
- package/dist/src/components/PlDropdownRef/PlDropdownRef.vue.d.ts +109 -0
- package/dist/src/components/PlDropdownRef/__tests__/PlDropdownRef.spec.d.ts +1 -0
- package/dist/src/components/PlDropdownRef/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/types.d.ts +6 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/assets/icons/icon-assets/24_link-disabled.svg +4 -0
- package/src/assets/icons/icon-assets-min/24_link-disabled.svg +1 -0
- package/src/assets/icons/icons-24-generated.json +1 -0
- package/src/assets/icons/icons-24-generated.scss +1 -0
- package/src/assets/icons.scss +0 -4
- package/src/assets/masks.scss +0 -4
- package/src/components/PlDropdown/PlDropdown.vue +11 -6
- package/src/components/PlDropdown/pl-dropdown.scss +13 -32
- package/src/components/PlDropdownRef/PlDropdownRef.vue +90 -0
- package/src/components/PlDropdownRef/__tests__/PlDropdownRef.spec.ts +55 -0
- package/src/components/PlDropdownRef/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/types.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/uikit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/pl-uikit.umd.js",
|
|
6
6
|
"module": "dist/pl-uikit.js",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"vite": "^5.4.8",
|
|
31
31
|
"vue-tsc": "^2.1.6",
|
|
32
32
|
"yarpm": "^1.2.0",
|
|
33
|
+
"svgo": "^3.3.2",
|
|
33
34
|
"@milaboratories/helpers": "^1.6.5",
|
|
34
35
|
"@platforma-sdk/model": "^1.5.40"
|
|
35
36
|
},
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M11.2215 15.2214L13.5701 12.8728C15.2299 11.213 15.2299 8.52208 13.5701 6.86235C11.9104 5.20262 9.21946 5.20262 7.55973 6.86235L3.31709 11.105C1.65736 12.7647 1.65736 15.4557 3.31709 17.1154C4.38619 18.1845 5.88315 18.5649 7.25677 18.2567L8.45261 19.4526C6.38306 20.2767 3.93154 19.8512 2.25643 18.1761C0.0109174 15.9305 0.0109177 12.2898 2.25643 10.0443L6.49907 5.80169C8.74459 3.55617 12.3853 3.55618 14.6308 5.80169C16.8763 8.0472 16.8763 11.6879 14.6308 13.9334L12.2821 16.2821L11.2215 15.2214Z" fill="#CFD1DB"/>
|
|
3
|
+
<path d="M17.4594 18.1761C15.2139 20.4216 11.5732 20.4216 9.32772 18.1761C7.08221 15.9305 7.08221 12.2898 9.32772 10.0443L11.686 7.68602L12.7467 8.74668L10.3884 11.105C8.72865 12.7647 8.72865 15.4557 10.3884 17.1154C12.0481 18.7751 14.7391 18.7751 16.3988 17.1154L20.6414 12.8728C22.3012 11.213 22.3012 8.52208 20.6414 6.86235C19.5764 5.79734 18.0868 5.41573 16.7175 5.7175L15.5197 4.51969C17.5864 3.70296 20.0307 4.1303 21.7021 5.80169C23.9476 8.0472 23.9476 11.6879 21.7021 13.9334L17.4594 18.1761Z" fill="#CFD1DB"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="#CFD1DB" d="m11.222 15.221 2.348-2.348a4.25 4.25 0 1 0-6.01-6.01l-4.243 4.242a4.25 4.25 0 0 0 3.94 7.152l1.196 1.196a5.751 5.751 0 0 1-6.197-9.409L6.5 5.802a5.75 5.75 0 0 1 8.132 8.131l-2.349 2.35z"/><path fill="#CFD1DB" d="M17.46 18.176a5.75 5.75 0 1 1-8.132-8.132l2.358-2.358 1.06 1.06-2.358 2.359a4.25 4.25 0 1 0 6.01 6.01l4.243-4.242a4.25 4.25 0 0 0-3.923-7.155L15.52 4.52a5.751 5.751 0 0 1 6.182 9.413z"/></svg>
|
package/src/assets/icons.scss
CHANGED
|
@@ -11,10 +11,6 @@
|
|
|
11
11
|
@include icon(url("./images/16_attention.svg"), var(--icon-size));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
&--clear {
|
|
15
|
-
@include icon(url("./images/16_clear.svg"), var(--icon-size));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
&--chevron-right {
|
|
19
15
|
@include icon(url("./images/16_chevron-right.svg"), var(--icon-size));
|
|
20
16
|
}
|
package/src/assets/masks.scss
CHANGED
|
@@ -15,10 +15,6 @@
|
|
|
15
15
|
@include mask(url("./images/16_attention.svg"), var(--mask-size));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
&--clear {
|
|
19
|
-
@include mask(url("./images/16_clear.svg"), var(--mask-size));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
&--chevron-right {
|
|
23
19
|
@include mask(url("./images/16_chevron-right.svg"), var(--mask-size));
|
|
24
20
|
}
|
|
@@ -67,9 +67,13 @@ const props = withDefaults(
|
|
|
67
67
|
*/
|
|
68
68
|
disabled?: boolean;
|
|
69
69
|
/**
|
|
70
|
-
* Custom icon class for the dropdown arrow (optional)
|
|
70
|
+
* Custom icon (16px) class for the dropdown arrow (optional)
|
|
71
71
|
*/
|
|
72
72
|
arrowIcon?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Custom icon (24px) class for the dropdown arrow (optional)
|
|
75
|
+
*/
|
|
76
|
+
arrowIconLarge?: string;
|
|
73
77
|
/**
|
|
74
78
|
* Option list item size
|
|
75
79
|
*/
|
|
@@ -84,6 +88,7 @@ const props = withDefaults(
|
|
|
84
88
|
required: false,
|
|
85
89
|
disabled: false,
|
|
86
90
|
arrowIcon: undefined,
|
|
91
|
+
arrowIconLarge: undefined,
|
|
87
92
|
optionSize: 'small',
|
|
88
93
|
},
|
|
89
94
|
);
|
|
@@ -301,14 +306,14 @@ watchPostEffect(() => {
|
|
|
301
306
|
|
|
302
307
|
<div v-if="!data.open" @click="setFocusOnInput">
|
|
303
308
|
<LongText class="input-value"> {{ textValue }} </LongText>
|
|
304
|
-
<div v-if="clearable" class="close" @click.stop="clear" />
|
|
305
309
|
</div>
|
|
306
310
|
|
|
307
|
-
<div
|
|
308
|
-
|
|
309
|
-
<div class="ui-dropdown__append">
|
|
310
|
-
<div v-if="clearable && hasValue" class="icon icon--clear" @click.stop="clear" />
|
|
311
|
+
<div class="ui-dropdown__controls">
|
|
312
|
+
<div v-if="clearable && hasValue" class="icon-16 icon-clear" @click.stop="clear" />
|
|
311
313
|
<slot name="append" />
|
|
314
|
+
<div v-if="arrowIconLarge" class="arrow-icon" :class="[`icon-24 ${arrowIconLarge}`]" @click.stop="toggleOpen" />
|
|
315
|
+
<div v-else-if="arrowIcon" class="arrow-icon" :class="[`icon-16 ${arrowIcon}`]" @click.stop="toggleOpen" />
|
|
316
|
+
<div v-else class="arrow-icon arrow-icon-default" @click.stop="toggleOpen" />
|
|
312
317
|
</div>
|
|
313
318
|
</div>
|
|
314
319
|
<label v-if="label">
|
|
@@ -163,12 +163,6 @@
|
|
|
163
163
|
color: var(--color-placeholder);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
|
|
167
|
-
&:hover {
|
|
168
|
-
.clear {
|
|
169
|
-
display: block;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
166
|
}
|
|
173
167
|
|
|
174
168
|
&__helper {
|
|
@@ -179,43 +173,30 @@
|
|
|
179
173
|
@include field-error();
|
|
180
174
|
}
|
|
181
175
|
|
|
182
|
-
&
|
|
183
|
-
padding-right: 24px;
|
|
176
|
+
&__controls {
|
|
184
177
|
display: flex;
|
|
185
178
|
flex-direction: row;
|
|
186
179
|
align-items: center;
|
|
187
|
-
gap:
|
|
188
|
-
|
|
180
|
+
gap: 6px;
|
|
181
|
+
margin-left: auto;
|
|
182
|
+
|
|
183
|
+
.icon-clear {
|
|
189
184
|
cursor: pointer;
|
|
190
185
|
}
|
|
191
|
-
|
|
186
|
+
|
|
187
|
+
.mask-16,.mask-24 {
|
|
192
188
|
background-color: var(--control-mask-fill);
|
|
193
189
|
cursor: pointer;
|
|
194
190
|
}
|
|
195
191
|
}
|
|
196
192
|
|
|
197
|
-
.arrow {
|
|
198
|
-
position: absolute;
|
|
199
|
-
@include abs-center-y;
|
|
200
|
-
right: 12px;
|
|
201
|
-
background-color: var(--control-mask-fill);
|
|
202
|
-
@include mask(url('@/assets/images/16_chevron-down.svg'), 16px);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.arrow-altered {
|
|
206
|
-
position: absolute;
|
|
207
|
-
@include abs-center-y;
|
|
208
|
-
right: 12px;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.clear {
|
|
212
|
-
display: none;
|
|
213
|
-
position: absolute;
|
|
214
|
-
@include abs-center-y;
|
|
215
|
-
right: 36px;
|
|
216
|
-
z-index: 1;
|
|
217
|
-
@include icon(url('@/assets/images/16_clear.svg'), 16px); // @todo mask-image
|
|
193
|
+
.arrow-icon {
|
|
218
194
|
cursor: pointer;
|
|
195
|
+
// Default "arrow" icon (16x16)
|
|
196
|
+
&.arrow-icon-default {
|
|
197
|
+
background-color: var(--control-mask-fill);
|
|
198
|
+
@include mask(url('@/assets/images/16_chevron-down.svg'), 16px);
|
|
199
|
+
}
|
|
219
200
|
}
|
|
220
201
|
|
|
221
202
|
&.open,
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A component for selecting one value from a list of options
|
|
4
|
+
*/
|
|
5
|
+
export default {
|
|
6
|
+
name: 'PlDropdownRef',
|
|
7
|
+
};
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import type { ModelRef, RefOption } from '@/types';
|
|
12
|
+
import { PlDropdown } from '../PlDropdown';
|
|
13
|
+
import { computed } from 'vue';
|
|
14
|
+
|
|
15
|
+
defineEmits<{
|
|
16
|
+
/**
|
|
17
|
+
* Emitted when the model value is updated.
|
|
18
|
+
*/
|
|
19
|
+
(e: 'update:modelValue', value: ModelRef | undefined): void;
|
|
20
|
+
}>();
|
|
21
|
+
|
|
22
|
+
const props = withDefaults(
|
|
23
|
+
defineProps<{
|
|
24
|
+
/**
|
|
25
|
+
* The current selected ref of the dropdown.
|
|
26
|
+
*/
|
|
27
|
+
modelValue: ModelRef | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The label text for the dropdown field (optional)
|
|
30
|
+
*/
|
|
31
|
+
label?: string;
|
|
32
|
+
/**
|
|
33
|
+
* List of available ref options for the dropdown
|
|
34
|
+
*/
|
|
35
|
+
options: Readonly<RefOption[]>;
|
|
36
|
+
/**
|
|
37
|
+
* A helper text displayed below the dropdown when there are no errors (optional).
|
|
38
|
+
*/
|
|
39
|
+
helper?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Error message displayed below the dropdown (optional)
|
|
42
|
+
*/
|
|
43
|
+
error?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Placeholder text shown when no value is selected.
|
|
46
|
+
*/
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Enables a button to clear the selected value (default: false)
|
|
50
|
+
*/
|
|
51
|
+
clearable?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* If `true`, the dropdown component is marked as required.
|
|
54
|
+
*/
|
|
55
|
+
required?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* If `true`, the dropdown component is disabled and cannot be interacted with.
|
|
58
|
+
*/
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Option list item size
|
|
62
|
+
*/
|
|
63
|
+
optionSize?: 'small' | 'medium';
|
|
64
|
+
}>(),
|
|
65
|
+
{
|
|
66
|
+
label: '',
|
|
67
|
+
helper: undefined,
|
|
68
|
+
error: undefined,
|
|
69
|
+
placeholder: '...',
|
|
70
|
+
clearable: false,
|
|
71
|
+
required: false,
|
|
72
|
+
disabled: false,
|
|
73
|
+
arrowIcon: undefined,
|
|
74
|
+
optionSize: 'small',
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const options = computed(() =>
|
|
79
|
+
props.options.map((opt) => ({
|
|
80
|
+
label: opt.label,
|
|
81
|
+
value: opt.ref,
|
|
82
|
+
})),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const arrowIcon = computed(() => (props.disabled ? 'icon-link-disabled' : 'icon-link'));
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<PlDropdown v-bind="props" :options="options" :arrow-icon-large="arrowIcon" @update:model-value="$emit('update:modelValue', $event)"> </PlDropdown>
|
|
90
|
+
</template>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { mount } from '@vue/test-utils';
|
|
4
|
+
import PlDropdownRef from '../PlDropdownRef.vue';
|
|
5
|
+
|
|
6
|
+
describe('PlDropdownRef', () => {
|
|
7
|
+
it('modelValue', async () => {
|
|
8
|
+
const wrapper = mount(PlDropdownRef, {
|
|
9
|
+
props: {
|
|
10
|
+
modelValue: {
|
|
11
|
+
__isRef: true as const,
|
|
12
|
+
blockId: '2',
|
|
13
|
+
name: 'Ref to block 2',
|
|
14
|
+
},
|
|
15
|
+
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }),
|
|
16
|
+
options: [
|
|
17
|
+
{
|
|
18
|
+
label: 'Ref 1',
|
|
19
|
+
ref: {
|
|
20
|
+
__isRef: true as const,
|
|
21
|
+
blockId: '1',
|
|
22
|
+
name: 'Ref to block 1',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: 'Ref 2',
|
|
27
|
+
ref: {
|
|
28
|
+
__isRef: true as const,
|
|
29
|
+
blockId: '2',
|
|
30
|
+
name: 'Ref to block 2',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await wrapper.find('input').trigger('focus');
|
|
38
|
+
|
|
39
|
+
expect(await wrapper.findAll('.dropdown-list-item').length).toBe(2);
|
|
40
|
+
|
|
41
|
+
await wrapper
|
|
42
|
+
.findAll('.dropdown-list-item')
|
|
43
|
+
.filter((node) => node.text().match(/Ref 2/))
|
|
44
|
+
.at(0)
|
|
45
|
+
?.trigger('click');
|
|
46
|
+
|
|
47
|
+
expect(wrapper.props('modelValue')).toStrictEqual({
|
|
48
|
+
__isRef: true as const,
|
|
49
|
+
blockId: '2',
|
|
50
|
+
name: 'Ref to block 2',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
expect(await wrapper.findAll('.dropdown-list-item').length).toBe(0); // options are closed after click
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PlDropdownRef } from './PlDropdownRef.vue';
|
package/src/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ export * from './components/PlBtnGroup';
|
|
|
30
30
|
export * from './components/PlTextField';
|
|
31
31
|
export * from './components/PlTextArea';
|
|
32
32
|
export * from './components/PlDropdown';
|
|
33
|
+
export * from './components/PlDropdownRef';
|
|
33
34
|
export * from './components/PlDropdownLine';
|
|
34
35
|
export * from './components/PlTooltip';
|
|
35
36
|
export * from './components/PlProgressBar';
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ImportFileHandle, Platforma, StorageHandle } from '@platforma-sdk/model';
|
|
1
|
+
import type { ImportFileHandle, Platforma, StorageHandle, Ref as ModelRef } from '@platforma-sdk/model';
|
|
2
2
|
import type { Ref, ComputedRef } from 'vue';
|
|
3
3
|
|
|
4
4
|
export type Size = 'small' | 'medium' | 'large';
|
|
@@ -37,6 +37,13 @@ export type ListOption<T = unknown> =
|
|
|
37
37
|
value: T;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
export type { ModelRef };
|
|
41
|
+
|
|
42
|
+
export type RefOption = {
|
|
43
|
+
readonly label: string;
|
|
44
|
+
readonly ref: ModelRef;
|
|
45
|
+
};
|
|
46
|
+
|
|
40
47
|
export type ListOptionNormalized<T = unknown> = {
|
|
41
48
|
label: string;
|
|
42
49
|
description?: string;
|