@bethinkpl/design-system 34.0.4 → 34.0.5
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/dist/design-system.css +1 -1
- package/dist/design-system.js +1020 -1017
- package/dist/design-system.js.map +1 -1
- package/dist/lib/js/components/Chip/Chip.vue.d.ts +4 -0
- package/dist/lib/js/components/Drawer/DrawerHeader/DrawerHeader.vue.d.ts +14 -0
- package/lib/js/components/Chip/Chip.spec.ts +29 -0
- package/lib/js/components/Chip/Chip.stories.ts +3 -2
- package/lib/js/components/Chip/Chip.vue +33 -2
- package/package.json +1 -1
|
@@ -14,8 +14,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
14
14
|
colorHex?: string | null;
|
|
15
15
|
state?: ChipState;
|
|
16
16
|
isRemovable?: boolean;
|
|
17
|
+
isInteractive?: boolean;
|
|
17
18
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
18
19
|
remove: () => void;
|
|
20
|
+
chipClick: (event: Event) => void;
|
|
19
21
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
20
22
|
label?: string | null;
|
|
21
23
|
isLabelUppercase?: boolean;
|
|
@@ -26,8 +28,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
26
28
|
colorHex?: string | null;
|
|
27
29
|
state?: ChipState;
|
|
28
30
|
isRemovable?: boolean;
|
|
31
|
+
isInteractive?: boolean;
|
|
29
32
|
}>>> & Readonly<{
|
|
30
33
|
onRemove?: (() => any) | undefined;
|
|
34
|
+
onChipClick?: ((event: Event) => any) | undefined;
|
|
31
35
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
32
36
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
33
37
|
export default _default;
|
|
@@ -1251,10 +1251,15 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
1251
1251
|
isRemovable: {
|
|
1252
1252
|
type: PropType<boolean>;
|
|
1253
1253
|
};
|
|
1254
|
+
isInteractive: {
|
|
1255
|
+
type: PropType<boolean>;
|
|
1256
|
+
};
|
|
1254
1257
|
}>> & Readonly<{
|
|
1255
1258
|
onRemove?: (() => any) | undefined;
|
|
1259
|
+
onChipClick?: ((event: Event) => any) | undefined;
|
|
1256
1260
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
1257
1261
|
remove: () => void;
|
|
1262
|
+
chipClick: (event: Event) => void;
|
|
1258
1263
|
}, import('vue').PublicProps, {}, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
1259
1264
|
P: {};
|
|
1260
1265
|
B: {};
|
|
@@ -1288,8 +1293,12 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
1288
1293
|
isRemovable: {
|
|
1289
1294
|
type: PropType<boolean>;
|
|
1290
1295
|
};
|
|
1296
|
+
isInteractive: {
|
|
1297
|
+
type: PropType<boolean>;
|
|
1298
|
+
};
|
|
1291
1299
|
}>> & Readonly<{
|
|
1292
1300
|
onRemove?: (() => any) | undefined;
|
|
1301
|
+
onChipClick?: ((event: Event) => any) | undefined;
|
|
1293
1302
|
}>, {}, {}, {}, {}, {}>;
|
|
1294
1303
|
__isFragment?: never;
|
|
1295
1304
|
__isTeleport?: never;
|
|
@@ -1320,10 +1329,15 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
1320
1329
|
isRemovable: {
|
|
1321
1330
|
type: PropType<boolean>;
|
|
1322
1331
|
};
|
|
1332
|
+
isInteractive: {
|
|
1333
|
+
type: PropType<boolean>;
|
|
1334
|
+
};
|
|
1323
1335
|
}>> & Readonly<{
|
|
1324
1336
|
onRemove?: (() => any) | undefined;
|
|
1337
|
+
onChipClick?: ((event: Event) => any) | undefined;
|
|
1325
1338
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
1326
1339
|
remove: () => void;
|
|
1340
|
+
chipClick: (event: Event) => void;
|
|
1327
1341
|
}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
1328
1342
|
$slots: {
|
|
1329
1343
|
accessory?(_: {}): any;
|
|
@@ -13,6 +13,7 @@ interface createComponentOptions {
|
|
|
13
13
|
isRemovable?: boolean;
|
|
14
14
|
size?: string;
|
|
15
15
|
color?: string;
|
|
16
|
+
isInteractive?: boolean;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
describe('Chip', () => {
|
|
@@ -22,6 +23,7 @@ describe('Chip', () => {
|
|
|
22
23
|
isRemovable = false,
|
|
23
24
|
size = CHIP_SIZES.SMALL,
|
|
24
25
|
color = CHIP_COLORS.NEUTRAL,
|
|
26
|
+
isInteractive = false,
|
|
25
27
|
}: createComponentOptions = {}) => {
|
|
26
28
|
return shallowMount(Chip, {
|
|
27
29
|
props: {
|
|
@@ -30,6 +32,7 @@ describe('Chip', () => {
|
|
|
30
32
|
isRemovable,
|
|
31
33
|
size,
|
|
32
34
|
color,
|
|
35
|
+
isInteractive,
|
|
33
36
|
} as any,
|
|
34
37
|
});
|
|
35
38
|
};
|
|
@@ -130,6 +133,32 @@ describe('Chip', () => {
|
|
|
130
133
|
},
|
|
131
134
|
);
|
|
132
135
|
|
|
136
|
+
it('does not have interactive class by default', () => {
|
|
137
|
+
const component = createComponent();
|
|
138
|
+
|
|
139
|
+
expect(component.classes()).not.toContain('-ds-interactive');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('has interactive class when interactive prop is true', () => {
|
|
143
|
+
const component = createComponent({ isInteractive: true });
|
|
144
|
+
|
|
145
|
+
expect(component.classes()).toContain('-ds-interactive');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('emits click event when interactive and clicked', async () => {
|
|
149
|
+
const component = createComponent({ isInteractive: true });
|
|
150
|
+
|
|
151
|
+
await component.trigger('click');
|
|
152
|
+
expect(component.emitted('chipClick')?.length).toBe(1);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('does not emit click event when not interactive and clicked', async () => {
|
|
156
|
+
const component = createComponent({ isInteractive: false });
|
|
157
|
+
|
|
158
|
+
await component.trigger('click');
|
|
159
|
+
expect(component.emitted('chipClick')).toBeUndefined();
|
|
160
|
+
});
|
|
161
|
+
|
|
133
162
|
it("doesn't render remove when size x-small", () => {
|
|
134
163
|
const component = createComponent({ isRemovable: true, size: CHIP_SIZES.X_SMALL });
|
|
135
164
|
|
|
@@ -21,7 +21,7 @@ const StoryTemplate: StoryFn<typeof Chip> = (args) => ({
|
|
|
21
21
|
return args;
|
|
22
22
|
},
|
|
23
23
|
template:
|
|
24
|
-
'<chip :label="label" :is-label-uppercase="isLabelUppercase" :left-icon="ICONS[leftIcon]" :is-removable="isRemovable" :size="size" :color="color" :color-hex="colorHex" :state="state" :radius="radius" />',
|
|
24
|
+
'<chip :label="label" :is-label-uppercase="isLabelUppercase" :left-icon="ICONS[leftIcon]" :is-removable="isRemovable" :size="size" :color="color" :color-hex="colorHex" :state="state" :radius="radius" :is-interactive="isInteractive" />',
|
|
25
25
|
data() {
|
|
26
26
|
return {
|
|
27
27
|
ICONS: Object.freeze(ICONS),
|
|
@@ -34,7 +34,7 @@ const StoryTemplateWithAccessory: StoryFn<typeof Chip> = (args) => ({
|
|
|
34
34
|
return args;
|
|
35
35
|
},
|
|
36
36
|
template:
|
|
37
|
-
'<chip :label="label" :is-label-uppercase="isLabelUppercase" :left-icon="ICONS[leftIcon]" :is-removable="isRemovable" :size="size" :color="color" :color-hex="colorHex" :state="state" :radius="radius">' +
|
|
37
|
+
'<chip :label="label" :is-label-uppercase="isLabelUppercase" :left-icon="ICONS[leftIcon]" :is-removable="isRemovable" :size="size" :color="color" :color-hex="colorHex" :state="state" :radius="radius" :is-interactive="isInteractive">' +
|
|
38
38
|
'<template #accessory><logo-badge :style="svgStyle" /></template>' +
|
|
39
39
|
'</chip>',
|
|
40
40
|
data() {
|
|
@@ -64,6 +64,7 @@ const args = {
|
|
|
64
64
|
color: CHIP_DEFAULT_COLOR,
|
|
65
65
|
colorHex: '',
|
|
66
66
|
isRemovable: false,
|
|
67
|
+
isInteractive: false,
|
|
67
68
|
state: CHIP_STATES.DEFAULT,
|
|
68
69
|
} as Args;
|
|
69
70
|
const argTypes = {
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
'-ds-uppercase': isLabelUppercase,
|
|
9
9
|
'-ds-rounded': radius === CHIP_RADIUSES.ROUNDED,
|
|
10
10
|
'-ds-removable': size !== CHIP_SIZES.X_SMALL && isRemovable,
|
|
11
|
+
'-ds-interactive': isInteractiveComputed,
|
|
11
12
|
}"
|
|
12
13
|
:title="label ?? undefined"
|
|
13
14
|
:style="colorHex ? { backgroundColor: colorHex } : undefined"
|
|
15
|
+
@click="isInteractiveComputed && $emit('chipClick', $event)"
|
|
14
16
|
>
|
|
15
17
|
<span v-if="$slots.accessory || leftIcon" class="ds-chip__leftIcon">
|
|
16
18
|
<slot name="accessory">
|
|
@@ -40,6 +42,7 @@
|
|
|
40
42
|
</template>
|
|
41
43
|
|
|
42
44
|
<style lang="scss" scoped>
|
|
45
|
+
@import '../../../styles/settings/animations';
|
|
43
46
|
@import '../../../styles/settings/spacings';
|
|
44
47
|
@import '../../../styles/settings/radiuses';
|
|
45
48
|
@import '../../../styles/settings/colors/tokens';
|
|
@@ -51,6 +54,7 @@ $chip-colors: (
|
|
|
51
54
|
'label': $color-neutral-text-strong,
|
|
52
55
|
'icon': $color-neutral-icon,
|
|
53
56
|
'background': $color-neutral-background-medium,
|
|
57
|
+
'background-hover': $color-neutral-background-medium-hovered,
|
|
54
58
|
'disabled': (
|
|
55
59
|
'label': $color-neutral-text-strong-disabled,
|
|
56
60
|
'icon': $color-neutral-icon-disabled,
|
|
@@ -61,6 +65,7 @@ $chip-colors: (
|
|
|
61
65
|
'label': $color-neutral-text,
|
|
62
66
|
'icon': $color-neutral-icon,
|
|
63
67
|
'background': $color-neutral-background,
|
|
68
|
+
'background-hover': $color-neutral-background-hovered,
|
|
64
69
|
'disabled': (
|
|
65
70
|
'label': $color-neutral-text-disabled,
|
|
66
71
|
'icon': $color-neutral-icon-disabled,
|
|
@@ -71,6 +76,7 @@ $chip-colors: (
|
|
|
71
76
|
'label': $color-inverted-text,
|
|
72
77
|
'icon': $color-inverted-icon,
|
|
73
78
|
'background': $color-primary-background-strong,
|
|
79
|
+
'background-hover': $color-primary-background-strong-hovered,
|
|
74
80
|
'disabled': (
|
|
75
81
|
'label': $color-inverted-text,
|
|
76
82
|
'icon': $color-inverted-icon,
|
|
@@ -81,6 +87,7 @@ $chip-colors: (
|
|
|
81
87
|
'label': $color-primary-text,
|
|
82
88
|
'icon': $color-primary-icon,
|
|
83
89
|
'background': $color-primary-background,
|
|
90
|
+
'background-hover': $color-primary-background-hovered,
|
|
84
91
|
'disabled': (
|
|
85
92
|
'label': $color-primary-text-disabled,
|
|
86
93
|
'icon': $color-primary-icon-disabled,
|
|
@@ -91,6 +98,7 @@ $chip-colors: (
|
|
|
91
98
|
'label': $color-fail-text,
|
|
92
99
|
'icon': $color-fail-icon,
|
|
93
100
|
'background': $color-fail-background,
|
|
101
|
+
'background-hover': $color-fail-background-hovered,
|
|
94
102
|
'disabled': (
|
|
95
103
|
'label': $color-fail-text-disabled,
|
|
96
104
|
'icon': $color-fail-icon-disabled,
|
|
@@ -101,6 +109,7 @@ $chip-colors: (
|
|
|
101
109
|
'label': $color-danger-text,
|
|
102
110
|
'icon': $color-danger-icon,
|
|
103
111
|
'background': $color-danger-background,
|
|
112
|
+
'background-hover': $color-danger-background-hovered,
|
|
104
113
|
'disabled': (
|
|
105
114
|
'label': $color-danger-text-disabled,
|
|
106
115
|
'icon': $color-danger-icon-disabled,
|
|
@@ -111,6 +120,7 @@ $chip-colors: (
|
|
|
111
120
|
'label': $color-warning-text,
|
|
112
121
|
'icon': $color-warning-icon,
|
|
113
122
|
'background': $color-warning-background,
|
|
123
|
+
'background-hover': $color-warning-background-hovered,
|
|
114
124
|
'disabled': (
|
|
115
125
|
'label': $color-warning-text-disabled,
|
|
116
126
|
'icon': $color-warning-icon-disabled,
|
|
@@ -121,6 +131,7 @@ $chip-colors: (
|
|
|
121
131
|
'label': $color-success-text,
|
|
122
132
|
'icon': $color-success-icon,
|
|
123
133
|
'background': $color-success-background,
|
|
134
|
+
'background-hover': $color-success-background-hovered,
|
|
124
135
|
'disabled': (
|
|
125
136
|
'label': $color-success-text-disabled,
|
|
126
137
|
'icon': $color-success-icon-disabled,
|
|
@@ -131,6 +142,7 @@ $chip-colors: (
|
|
|
131
142
|
'label': $color-info-text,
|
|
132
143
|
'icon': $color-info-icon,
|
|
133
144
|
'background': $color-info-background,
|
|
145
|
+
'background-hover': $color-info-background-hovered,
|
|
134
146
|
'disabled': (
|
|
135
147
|
'label': $color-info-text-disabled,
|
|
136
148
|
'icon': $color-info-icon-disabled,
|
|
@@ -140,11 +152,12 @@ $chip-colors: (
|
|
|
140
152
|
'inverted': (
|
|
141
153
|
'label': $color-neutral-text,
|
|
142
154
|
'icon': $color-neutral-icon,
|
|
143
|
-
'background': $color-
|
|
155
|
+
'background': $color-neutral-background-weak,
|
|
156
|
+
'background-hover': $color-neutral-background-weak-hovered,
|
|
144
157
|
'disabled': (
|
|
145
158
|
'label': $color-neutral-text-disabled,
|
|
146
159
|
'icon': $color-neutral-icon-disabled,
|
|
147
|
-
'background': $color-
|
|
160
|
+
'background': $color-neutral-background-weak,
|
|
148
161
|
),
|
|
149
162
|
),
|
|
150
163
|
'invertedHex': (
|
|
@@ -173,6 +186,14 @@ $chip-colors: (
|
|
|
173
186
|
color: map-get($color-map, 'label');
|
|
174
187
|
}
|
|
175
188
|
|
|
189
|
+
&.-ds-interactive:hover {
|
|
190
|
+
$background-hover: map-get($color-map, 'background-hover');
|
|
191
|
+
|
|
192
|
+
@if $background-hover {
|
|
193
|
+
background-color: $background-hover;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
176
197
|
&.-ds-disabled {
|
|
177
198
|
background-color: map-get(map-get($color-map, 'disabled'), 'background');
|
|
178
199
|
|
|
@@ -194,6 +215,11 @@ $chip-colors: (
|
|
|
194
215
|
gap: $space-4xs;
|
|
195
216
|
padding: $space-4xs $space-2xs;
|
|
196
217
|
|
|
218
|
+
&.-ds-interactive {
|
|
219
|
+
cursor: pointer;
|
|
220
|
+
transition: background-color ease-in-out $default-transition-time;
|
|
221
|
+
}
|
|
222
|
+
|
|
197
223
|
&.-ds-removable {
|
|
198
224
|
padding: $space-5xs $space-5xs $space-5xs $space-2xs;
|
|
199
225
|
}
|
|
@@ -291,6 +317,7 @@ const {
|
|
|
291
317
|
colorHex = null,
|
|
292
318
|
state = CHIP_STATES.DEFAULT,
|
|
293
319
|
isRemovable = false,
|
|
320
|
+
isInteractive = false,
|
|
294
321
|
} = defineProps<{
|
|
295
322
|
label?: string | null;
|
|
296
323
|
isLabelUppercase?: boolean;
|
|
@@ -301,12 +328,16 @@ const {
|
|
|
301
328
|
colorHex?: string | null;
|
|
302
329
|
state?: ChipState;
|
|
303
330
|
isRemovable?: boolean;
|
|
331
|
+
isInteractive?: boolean;
|
|
304
332
|
}>();
|
|
305
333
|
|
|
306
334
|
defineEmits<{
|
|
307
335
|
remove: [];
|
|
336
|
+
chipClick: [event: Event];
|
|
308
337
|
}>();
|
|
309
338
|
|
|
339
|
+
const isInteractiveComputed = computed(() => isInteractive && state !== CHIP_STATES.DISABLED);
|
|
340
|
+
|
|
310
341
|
const colorClassName = computed(() => {
|
|
311
342
|
if (colorHex) {
|
|
312
343
|
return `-ds-color-invertedHex`;
|