@onereach/ui-components 2.68.1-beta.2071.0 → 2.69.0-beta.2073.0
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/bundled/v2/{OrCardCollection-a9a779ea.js → OrCardCollection-dac9fd1e.js} +1 -1
- package/dist/bundled/v2/{OrConfirm-18c534df.js → OrConfirm-ff57274f.js} +1 -1
- package/dist/bundled/v2/{OrInput-8b90e08f.js → OrInput-4b82eb59.js} +4 -4
- package/dist/bundled/v2/{OrSearch-9d402f56.js → OrSearch-e34afaee.js} +1 -1
- package/dist/bundled/v2/{OrSelect-f37e751b.js → OrSelect-a2dbc872.js} +3 -3
- package/dist/bundled/v2/components/index.js +6 -6
- package/dist/bundled/v2/components/or-card-collection-v3/index.js +2 -2
- package/dist/bundled/v2/components/or-confirm-v3/index.js +2 -2
- package/dist/bundled/v2/components/or-empty-state-v3/OrEmptyState.stories3.d.ts +24 -0
- package/dist/bundled/v2/components/or-empty-state-v3/OrEmptyState.vue.d.ts +101 -0
- package/dist/bundled/v2/components/or-empty-state-v3/index.d.ts +3 -0
- package/dist/bundled/v2/components/or-empty-state-v3/index.js +162 -0
- package/dist/bundled/v2/components/or-empty-state-v3/props.d.ts +4 -0
- package/dist/bundled/v2/components/or-empty-state-v3/styles.d.ts +10 -0
- package/dist/bundled/v2/components/or-empty-state-v3/types.d.ts +2 -0
- package/dist/bundled/v2/components/or-input-v3/index.js +1 -1
- package/dist/bundled/v2/components/or-search-v3/index.js +2 -2
- package/dist/bundled/v2/components/or-select-v3/index.js +3 -3
- package/dist/bundled/v2/components/or-tag-v3/OrTag.stories3.d.ts +5 -0
- package/dist/bundled/v2/hooks/index.js +1 -1
- package/dist/bundled/v2/index.js +7 -7
- package/dist/bundled/v2/{useOverflow-43299d81.js → useOverflow-dc93a300.js} +10 -6
- package/dist/bundled/v3/{OrCardCollection.vue_vue_type_script_lang-3993a015.js → OrCardCollection.vue_vue_type_script_lang-7a07be47.js} +1 -1
- package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-289b5600.js → OrConfirm.vue_vue_type_script_lang-2e7fa659.js} +1 -1
- package/dist/bundled/v3/{OrInput-fa782fc1.js → OrInput-e97211bb.js} +1 -1
- package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-ed78b21f.js → OrSearch.vue_vue_type_script_lang-1d2a20e0.js} +1 -1
- package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-c74a63e1.js → OrSelect.vue_vue_type_script_lang-619d6eb7.js} +2 -2
- package/dist/bundled/v3/components/index.js +6 -6
- package/dist/bundled/v3/components/or-card-collection-v3/index.js +2 -2
- package/dist/bundled/v3/components/or-confirm-v3/index.js +2 -2
- package/dist/bundled/v3/components/or-empty-state-v3/OrEmptyState.stories3.d.ts +24 -0
- package/dist/bundled/v3/components/or-empty-state-v3/OrEmptyState.vue.d.ts +101 -0
- package/dist/bundled/v3/components/or-empty-state-v3/index.d.ts +3 -0
- package/dist/bundled/v3/components/or-empty-state-v3/index.js +134 -0
- package/dist/bundled/v3/components/or-empty-state-v3/props.d.ts +4 -0
- package/dist/bundled/v3/components/or-empty-state-v3/styles.d.ts +10 -0
- package/dist/bundled/v3/components/or-empty-state-v3/types.d.ts +2 -0
- package/dist/bundled/v3/components/or-search-v3/index.js +2 -2
- package/dist/bundled/v3/components/or-select-v3/index.js +3 -3
- package/dist/bundled/v3/components/or-tag-v3/OrTag.stories3.d.ts +5 -0
- package/dist/bundled/v3/hooks/index.js +1 -1
- package/dist/bundled/v3/index.js +12 -12
- package/dist/bundled/v3/{useOverflow-2468b718.js → useOverflow-06bcc7d7.js} +10 -6
- package/dist/esm/v2/{OrCardCollection-4f001551.js → OrCardCollection-e46b220e.js} +1 -1
- package/dist/esm/v2/{OrConfirm-b0b2e43c.js → OrConfirm-74e21c56.js} +1 -1
- package/dist/esm/v2/{OrInput-2f16a7ac.js → OrInput-b8a1627f.js} +4 -4
- package/dist/esm/v2/{OrSearch-ddb7c1fe.js → OrSearch-0c0d1773.js} +1 -1
- package/dist/esm/v2/{OrSelect-528c7480.js → OrSelect-acc13b49.js} +3 -3
- package/dist/esm/v2/components/index.js +6 -6
- package/dist/esm/v2/components/or-card-collection-v3/index.js +2 -2
- package/dist/esm/v2/components/or-confirm-v3/index.js +2 -2
- package/dist/esm/v2/components/or-empty-state-v3/OrEmptyState.stories3.d.ts +24 -0
- package/dist/esm/v2/components/or-empty-state-v3/OrEmptyState.vue.d.ts +101 -0
- package/dist/esm/v2/components/or-empty-state-v3/index.d.ts +3 -0
- package/dist/esm/v2/components/or-empty-state-v3/index.js +159 -0
- package/dist/esm/v2/components/or-empty-state-v3/props.d.ts +4 -0
- package/dist/esm/v2/components/or-empty-state-v3/styles.d.ts +10 -0
- package/dist/esm/v2/components/or-empty-state-v3/types.d.ts +2 -0
- package/dist/esm/v2/components/or-input-v3/index.js +1 -1
- package/dist/esm/v2/components/or-search-v3/index.js +2 -2
- package/dist/esm/v2/components/or-select-v3/index.js +3 -3
- package/dist/esm/v2/components/or-tag-v3/OrTag.stories3.d.ts +5 -0
- package/dist/esm/v2/hooks/index.js +1 -1
- package/dist/esm/v2/index.js +6 -6
- package/dist/esm/{v3/useOverflow-ac506c65.js → v2/useOverflow-a3dc6212.js} +10 -6
- package/dist/esm/v3/{OrCardCollection-5a0febaf.js → OrCardCollection-5924d035.js} +1 -1
- package/dist/esm/v3/{OrConfirm-906427ef.js → OrConfirm-a3f312a6.js} +1 -1
- package/dist/esm/v3/{OrInput-41691fb3.js → OrInput-e2ac1182.js} +1 -1
- package/dist/esm/v3/{OrSearch-cdde55ce.js → OrSearch-01225d82.js} +1 -1
- package/dist/esm/v3/{OrSelect-d9c76482.js → OrSelect-fbf4a140.js} +3 -3
- package/dist/esm/v3/components/index.js +6 -6
- package/dist/esm/v3/components/or-card-collection-v3/index.js +2 -2
- package/dist/esm/v3/components/or-confirm-v3/index.js +2 -2
- package/dist/esm/v3/components/or-empty-state-v3/OrEmptyState.stories3.d.ts +24 -0
- package/dist/esm/v3/components/or-empty-state-v3/OrEmptyState.vue.d.ts +101 -0
- package/dist/esm/v3/components/or-empty-state-v3/index.d.ts +3 -0
- package/dist/esm/v3/components/or-empty-state-v3/index.js +135 -0
- package/dist/esm/v3/components/or-empty-state-v3/props.d.ts +4 -0
- package/dist/esm/v3/components/or-empty-state-v3/styles.d.ts +10 -0
- package/dist/esm/v3/components/or-empty-state-v3/types.d.ts +2 -0
- package/dist/esm/v3/components/or-input-v3/index.js +1 -1
- package/dist/esm/v3/components/or-search-v3/index.js +2 -2
- package/dist/esm/v3/components/or-select-v3/index.js +3 -3
- package/dist/esm/v3/components/or-tag-v3/OrTag.stories3.d.ts +5 -0
- package/dist/esm/v3/hooks/index.js +1 -1
- package/dist/esm/v3/index.js +6 -6
- package/dist/esm/{v2/useOverflow-ac506c65.js → v3/useOverflow-a3dc6212.js} +10 -6
- package/package.json +1 -1
- package/src/components/or-empty-state-v3/OrEmptyState.stories3.ts +87 -0
- package/src/components/or-empty-state-v3/OrEmptyState.vue +121 -0
- package/src/components/or-empty-state-v3/index.ts +3 -0
- package/src/components/or-empty-state-v3/props.ts +4 -0
- package/src/components/or-empty-state-v3/styles.ts +76 -0
- package/src/components/or-empty-state-v3/types.ts +3 -0
- package/src/components/or-input-v3/OrInput.vue +1 -1
- package/src/components/or-select-v3/OrSelect.vue +1 -1
- package/src/components/or-tag-v3/OrTag.stories3.ts +112 -0
- package/src/hooks/useOverflow.ts +5 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/vue3';
|
|
2
|
+
import OrEmptyState from './OrEmptyState.vue';
|
|
3
|
+
import successPng from '../../assets/success.png';
|
|
4
|
+
import { EmptyStateSize } from './props';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Empty State',
|
|
8
|
+
component: OrEmptyState,
|
|
9
|
+
argTypes: {
|
|
10
|
+
size: {
|
|
11
|
+
control: {
|
|
12
|
+
type: 'inline-radio',
|
|
13
|
+
labels: {
|
|
14
|
+
[EmptyStateSize.M]: 'Medium',
|
|
15
|
+
[EmptyStateSize.L]: 'Large',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
options: Object.values(EmptyStateSize),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
parameters: {
|
|
22
|
+
layout: 'centered',
|
|
23
|
+
},
|
|
24
|
+
} as Meta<typeof OrEmptyState>
|
|
25
|
+
|
|
26
|
+
const Template: StoryFn<typeof OrEmptyState> = (args) => ({
|
|
27
|
+
components: { OrEmptyState },
|
|
28
|
+
setup() {
|
|
29
|
+
return { args };
|
|
30
|
+
},
|
|
31
|
+
template: `
|
|
32
|
+
<OrEmptyState v-bind="args"/>
|
|
33
|
+
`,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const Default = Template.bind({});
|
|
37
|
+
Default.args = {
|
|
38
|
+
heading: 'No aliens detected',
|
|
39
|
+
text: 'Invite some aliens to your planet.'
|
|
40
|
+
};
|
|
41
|
+
Default.parameters = {
|
|
42
|
+
layout: 'fullscreen',
|
|
43
|
+
};
|
|
44
|
+
Default.decorators = [
|
|
45
|
+
() => ({
|
|
46
|
+
template: `
|
|
47
|
+
<div class="
|
|
48
|
+
demo-wrapper w-full min-h-[200px] h-screen box-border relative
|
|
49
|
+
gap-sm p-md bg-surface-variant
|
|
50
|
+
flex flex-col
|
|
51
|
+
text-body-2-regular">
|
|
52
|
+
<div>
|
|
53
|
+
Note: This frame is added for demo purpose.<br>
|
|
54
|
+
The OrEmptyState component is transparent and has <code>width:100%</code> and <code>flex-grow:1</code> attributes.<br>
|
|
55
|
+
It is recommended to put it inside a column flex container or a row flex container that wraps.
|
|
56
|
+
</div>
|
|
57
|
+
<div class="demo-container grow bg-background dark:bg-background-dark flex flex-col"><story /></div>
|
|
58
|
+
</div>
|
|
59
|
+
`
|
|
60
|
+
})
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
export const ImageIcon = Template.bind({});
|
|
64
|
+
ImageIcon.args = {
|
|
65
|
+
heading: 'Planet populated',
|
|
66
|
+
text: 'So many aliens on this planet!',
|
|
67
|
+
imageSrc: successPng,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const LargeSize = Template.bind({});
|
|
71
|
+
LargeSize.args = {
|
|
72
|
+
...ImageIcon.args,
|
|
73
|
+
size: EmptyStateSize.L,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const ExtraContentInSlot: StoryFn<typeof OrEmptyState> = (args) => ({
|
|
77
|
+
components: { OrEmptyState },
|
|
78
|
+
setup() {
|
|
79
|
+
return { args };
|
|
80
|
+
},
|
|
81
|
+
template: `
|
|
82
|
+
<OrEmptyState v-bind="args" heading="Alien not found" text="Pass formatted content via a default slot.">
|
|
83
|
+
Alien named <b>Garry</b> not found.<br>
|
|
84
|
+
The text in the slot is by default formatted as a component's text prop.
|
|
85
|
+
</OrEmptyState>
|
|
86
|
+
`,
|
|
87
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="static"
|
|
4
|
+
:class="rootClasses">
|
|
5
|
+
<img v-if="imageSrc"
|
|
6
|
+
:src="imageSrc"
|
|
7
|
+
:class="imageClasses"
|
|
8
|
+
alt="">
|
|
9
|
+
<div :class="headingClasses">
|
|
10
|
+
{{ heading }}
|
|
11
|
+
</div>
|
|
12
|
+
<div v-if="$slots.default" :class="slotClasses">
|
|
13
|
+
<!-- @slot Additional content can be inserted via default slot. The slot uses the same font as a `text` prop. -->
|
|
14
|
+
<slot/>
|
|
15
|
+
</div>
|
|
16
|
+
<div :class="textClasses">
|
|
17
|
+
{{ text }}
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { defineComponent, PropType } from 'vue-demi';
|
|
24
|
+
import { EmptyStateSize } from '.';
|
|
25
|
+
import {
|
|
26
|
+
EmptyStateContent,
|
|
27
|
+
EmptyStateContentSizes,
|
|
28
|
+
EmptyStateHeading,
|
|
29
|
+
EmptyStateHeadingSizes,
|
|
30
|
+
EmptyStateImage,
|
|
31
|
+
EmptyStateImageSizes,
|
|
32
|
+
EmptyStateRoot,
|
|
33
|
+
EmptyStateText,
|
|
34
|
+
EmptyStateTextSizes
|
|
35
|
+
} from './styles';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The component to display when there is no content on a page,
|
|
39
|
+
* no records found or selected, or while the data is being loaded.
|
|
40
|
+
* Provides a hint to the user on what to do.
|
|
41
|
+
* Consists of text message, optional icon and optional loader.
|
|
42
|
+
*/
|
|
43
|
+
export default defineComponent({
|
|
44
|
+
name: 'OrEmptyState',
|
|
45
|
+
props: {
|
|
46
|
+
/**
|
|
47
|
+
* Size of the component, affects font and icon size.
|
|
48
|
+
* Use Large if the component takes all screen space,
|
|
49
|
+
* and Medium if it is a part of the complex layout.
|
|
50
|
+
*/
|
|
51
|
+
size: {
|
|
52
|
+
type: String as PropType<EmptyStateSize>,
|
|
53
|
+
default: EmptyStateSize.M,
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* The heading of the empty state block.
|
|
57
|
+
*/
|
|
58
|
+
heading: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: '',
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Additional text such as a hint for a user with proposed next steps.
|
|
64
|
+
*/
|
|
65
|
+
text: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: '',
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Path to the image to display above the heading.
|
|
71
|
+
* Image height is fixed depending on `size` prop, width is undefined to preserve aspect ratio.
|
|
72
|
+
*/
|
|
73
|
+
imageSrc: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: undefined,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
computed: {
|
|
79
|
+
rootClasses(): string[] {
|
|
80
|
+
return [
|
|
81
|
+
'or-empty-state',
|
|
82
|
+
...EmptyStateRoot,
|
|
83
|
+
];
|
|
84
|
+
},
|
|
85
|
+
imageClasses(): string[] {
|
|
86
|
+
return [
|
|
87
|
+
'or-empty-state_image',
|
|
88
|
+
...EmptyStateImage,
|
|
89
|
+
...EmptyStateImageSizes[this.size],
|
|
90
|
+
|
|
91
|
+
];
|
|
92
|
+
},
|
|
93
|
+
headingClasses(): string[] {
|
|
94
|
+
return [
|
|
95
|
+
'or-empty-state_heading',
|
|
96
|
+
...EmptyStateHeading,
|
|
97
|
+
...EmptyStateHeadingSizes[this.size],
|
|
98
|
+
|
|
99
|
+
];
|
|
100
|
+
},
|
|
101
|
+
textClasses(): string[] {
|
|
102
|
+
return [
|
|
103
|
+
'or-empty-state_text',
|
|
104
|
+
...EmptyStateText,
|
|
105
|
+
...EmptyStateTextSizes[this.size],
|
|
106
|
+
|
|
107
|
+
];
|
|
108
|
+
},
|
|
109
|
+
slotClasses(): string[] {
|
|
110
|
+
return [
|
|
111
|
+
'or-empty-state_content',
|
|
112
|
+
...EmptyStateContent,
|
|
113
|
+
...EmptyStateContentSizes[this.size],
|
|
114
|
+
];
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
</script>
|
|
119
|
+
|
|
120
|
+
<style scoped>
|
|
121
|
+
</style>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { EmptyStateSize } from './props';
|
|
2
|
+
|
|
3
|
+
export const EmptyStateRoot: string[] = [
|
|
4
|
+
// Layout
|
|
5
|
+
'grow',
|
|
6
|
+
'flex',
|
|
7
|
+
'flex-col',
|
|
8
|
+
'justify-center',
|
|
9
|
+
'items-center',
|
|
10
|
+
|
|
11
|
+
// Box
|
|
12
|
+
'w-full',
|
|
13
|
+
|
|
14
|
+
// Sizing
|
|
15
|
+
'gap-sm',
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export const EmptyStateImage = [
|
|
19
|
+
// Sizing
|
|
20
|
+
'mb-sm',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const EmptyStateImageSizes: Record<EmptyStateSize, string[]> = {
|
|
24
|
+
[EmptyStateSize.L]: [
|
|
25
|
+
// Box
|
|
26
|
+
'h-3xl',
|
|
27
|
+
],
|
|
28
|
+
[EmptyStateSize.M]: [
|
|
29
|
+
// Box
|
|
30
|
+
'h-2xl',
|
|
31
|
+
],
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const EmptyStateHeading: string[] = [
|
|
35
|
+
// Theme
|
|
36
|
+
'text-on-background',
|
|
37
|
+
'dark:text-on-background-dark'
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export const EmptyStateHeadingSizes: Record<EmptyStateSize, string[]> = {
|
|
41
|
+
[EmptyStateSize.L]: [
|
|
42
|
+
// Typography
|
|
43
|
+
'text-headline-2',
|
|
44
|
+
'font-headline-2',
|
|
45
|
+
],
|
|
46
|
+
[EmptyStateSize.M]: [
|
|
47
|
+
// Typography
|
|
48
|
+
'text-headline-4',
|
|
49
|
+
'font-headline-4',
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const EmptyStateText: string[] = [
|
|
54
|
+
'text-center',
|
|
55
|
+
|
|
56
|
+
// Theme
|
|
57
|
+
'text-outline',
|
|
58
|
+
'dark:text-outline-dark',
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
export const EmptyStateContent = EmptyStateText;
|
|
62
|
+
|
|
63
|
+
export const EmptyStateTextSizes: Record<EmptyStateSize, string[]> = {
|
|
64
|
+
[EmptyStateSize.L]: [
|
|
65
|
+
// Typography
|
|
66
|
+
'text-body-2-regular',
|
|
67
|
+
'font-body-2-regular',
|
|
68
|
+
],
|
|
69
|
+
[EmptyStateSize.M]: [
|
|
70
|
+
// Typography
|
|
71
|
+
'text-caption-regular',
|
|
72
|
+
'font-caption-regular',
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const EmptyStateContentSizes = EmptyStateTextSizes;
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
@blur="$emit('blur', $event)"
|
|
42
42
|
>
|
|
43
43
|
|
|
44
|
-
<div :class="['layout-row']">
|
|
44
|
+
<div :class="['layout-row', 'm-[-4px] md:m-[-2px]']">
|
|
45
45
|
<template v-if="type === 'password'">
|
|
46
46
|
<OrIconButton
|
|
47
47
|
:icon="{ icon: disclosed ? 'visibility_off' : 'visibility', variant: 'filled' }"
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { action } from '@storybook/addon-actions';
|
|
2
2
|
import { Meta, StoryFn } from '@storybook/vue3';
|
|
3
|
+
import Faker from 'faker';
|
|
3
4
|
import OrTagDocs from './OrTag.docs.mdx';
|
|
4
5
|
import OrTag from './OrTag.vue';
|
|
5
6
|
import { TagColor, TagVariant } from './props';
|
|
7
|
+
import { OrButtonV3 as OrButton } from '../or-button-v3';
|
|
8
|
+
import { OrPopoverV3 as OrPopover } from '../or-popover-v3';
|
|
9
|
+
import { useOverflow } from '../../hooks';
|
|
10
|
+
import { ref } from 'vue-demi';
|
|
6
11
|
|
|
7
12
|
export default {
|
|
8
13
|
title: 'Components/Tag',
|
|
@@ -77,6 +82,97 @@ const Template: StoryFn<typeof OrTag> = (args) => ({
|
|
|
77
82
|
`,
|
|
78
83
|
});
|
|
79
84
|
|
|
85
|
+
const ContainerTemplate: StoryFn<typeof OrTag> = (args) => ({
|
|
86
|
+
components: {
|
|
87
|
+
OrTag,
|
|
88
|
+
OrButton,
|
|
89
|
+
OrPopover,
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
setup() {
|
|
93
|
+
const container = ref<HTMLElement>();
|
|
94
|
+
const button = ref<InstanceType<typeof OrButton>>();
|
|
95
|
+
const popover = ref<InstanceType<typeof OrPopover>>();
|
|
96
|
+
|
|
97
|
+
const { innerItems, outerItems } = useOverflow(container);
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
args,
|
|
101
|
+
container,
|
|
102
|
+
button,
|
|
103
|
+
popover,
|
|
104
|
+
innerItems,
|
|
105
|
+
outerItems,
|
|
106
|
+
handleClick: action('click'),
|
|
107
|
+
handleFocus: action('focus'),
|
|
108
|
+
handleBlur: action('blur'),
|
|
109
|
+
handleReset: action('reset'),
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
computed: {
|
|
114
|
+
tagsArr(): string[] {
|
|
115
|
+
return [
|
|
116
|
+
args.default,
|
|
117
|
+
...(typeof args.tags === 'string' ? args.tags.split(' ') : []),
|
|
118
|
+
];
|
|
119
|
+
},
|
|
120
|
+
hiddenTagsArr(): string[] {
|
|
121
|
+
return this.tagsArr.slice(this.innerItems?.length);
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
template: `
|
|
126
|
+
<div class="w-[512px] flex flex-row items-center overflow-hidden gap-xs">
|
|
127
|
+
<div
|
|
128
|
+
ref="container"
|
|
129
|
+
class="relative flex flex-row grow items-center overflow-hidden gap-xs"
|
|
130
|
+
>
|
|
131
|
+
<OrTag
|
|
132
|
+
v-for="tag in tagsArr"
|
|
133
|
+
v-bind="args"
|
|
134
|
+
@click="handleClick"
|
|
135
|
+
@focus="handleFocus"
|
|
136
|
+
@blur="handleBlur"
|
|
137
|
+
@reset="handleReset"
|
|
138
|
+
>
|
|
139
|
+
{{ tag }}
|
|
140
|
+
</OrTag>
|
|
141
|
+
</div>
|
|
142
|
+
<template v-if="outerItems?.length">
|
|
143
|
+
<OrButton
|
|
144
|
+
ref="button"
|
|
145
|
+
class="typography-caption-regular text-on-background dark:text-on-background-dark"
|
|
146
|
+
color="inherit"
|
|
147
|
+
variant="link"
|
|
148
|
+
@click="popover.open()"
|
|
149
|
+
>
|
|
150
|
+
+{{outerItems.length}}
|
|
151
|
+
</OrButton>
|
|
152
|
+
<OrPopover
|
|
153
|
+
ref="popover"
|
|
154
|
+
:trigger="button?.root"
|
|
155
|
+
>
|
|
156
|
+
<div
|
|
157
|
+
class="max-w-[192px] p-[16px] flex flex-row flex-wrap items-center overflow-hidden gap-xs"
|
|
158
|
+
>
|
|
159
|
+
<OrTag
|
|
160
|
+
v-for="tag in hiddenTagsArr"
|
|
161
|
+
v-bind="args"
|
|
162
|
+
@click="handleClick"
|
|
163
|
+
@focus="handleFocus"
|
|
164
|
+
@blur="handleBlur"
|
|
165
|
+
@reset="handleReset"
|
|
166
|
+
>
|
|
167
|
+
{{ tag }}
|
|
168
|
+
</OrTag>
|
|
169
|
+
</div>
|
|
170
|
+
</OrPopover>
|
|
171
|
+
</template>
|
|
172
|
+
</div>
|
|
173
|
+
`,
|
|
174
|
+
});
|
|
175
|
+
|
|
80
176
|
export const Default = Template.bind({});
|
|
81
177
|
|
|
82
178
|
Default.args = {
|
|
@@ -99,3 +195,19 @@ WithCustomColor.args = {
|
|
|
99
195
|
// Props
|
|
100
196
|
color: '#0000ff',
|
|
101
197
|
};
|
|
198
|
+
|
|
199
|
+
export const InsideContainer = ContainerTemplate.bind({});
|
|
200
|
+
|
|
201
|
+
InsideContainer.argTypes = {
|
|
202
|
+
tags: {
|
|
203
|
+
control: { type: 'text' },
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
InsideContainer.args = {
|
|
208
|
+
// Slots
|
|
209
|
+
default: 'First tag',
|
|
210
|
+
|
|
211
|
+
// Args
|
|
212
|
+
tags: Faker.lorem.words(32),
|
|
213
|
+
};
|
package/src/hooks/useOverflow.ts
CHANGED
|
@@ -21,9 +21,12 @@ export function useOverflow(
|
|
|
21
21
|
|
|
22
22
|
if (container) {
|
|
23
23
|
const update = [...container.children].reduce(({ innerItems, outerItems }, child) => {
|
|
24
|
-
const item = child as HTMLElement
|
|
24
|
+
const item = child as HTMLElement;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const { x: itemOffset, width: itemWidth } = item.getBoundingClientRect();
|
|
27
|
+
const { x: containerOffset, width: containerWidth } = container.getBoundingClientRect();
|
|
28
|
+
|
|
29
|
+
if (itemOffset + itemWidth >= containerOffset + containerWidth) {
|
|
27
30
|
item.style.setProperty('visibility', 'hidden');
|
|
28
31
|
|
|
29
32
|
return {
|