@livestorm/ui-vue 1.1.0 → 1.1.2
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/.env +1 -0
- package/.eslintignore +4 -0
- package/.eslintrc.js +47 -0
- package/.pkg +11 -0
- package/babel.config.js +5 -0
- package/build/Dockerfile +31 -0
- package/ci/ci.yml +54 -0
- package/components-vite.js +29 -0
- package/components-webpack.js +29 -0
- package/components.d.ts +4 -0
- package/index.d.ts +3 -0
- package/index.js +24 -0
- package/package.json +12 -16
- package/plugins.js +17 -0
- package/postcss.config.js +1 -0
- package/src/components/BaseAutocomplete/BaseAutocomplete.spec.js +506 -0
- package/src/components/BaseAutocomplete/BaseAutocomplete.stories.js +184 -0
- package/src/components/BaseAutocomplete/BaseAutocomplete.vue +431 -0
- package/src/components/BaseBanner/BaseBanner.spec.js +32 -0
- package/src/components/BaseBanner/BaseBanner.stories.js +133 -0
- package/src/components/BaseBanner/BaseBanner.vue +229 -0
- package/src/components/BaseButton/BaseButton.spec.js +98 -0
- package/src/components/BaseButton/BaseButton.stories.js +291 -0
- package/src/components/BaseButton/BaseButton.vue +193 -0
- package/src/components/BaseButton/__snapshots__/BaseButton.spec.js.snap +37 -0
- package/src/components/BaseButton/__snapshots__/BaseButton.spec.js.snap.old +31 -0
- package/src/components/BaseCheckbox/BaseCheckbox.stories.js +82 -0
- package/src/components/BaseCheckbox/BaseCheckbox.vue +161 -0
- package/src/components/BaseDropdownMenu/BaseDropdownMenu.stories.js +84 -0
- package/src/components/BaseDropdownMenu/BaseDropdownMenu.vue +251 -0
- package/src/components/BaseDropdownMenu/BaseDropdownMenuButton.vue +26 -0
- package/src/components/BaseDropdownMenu/BaseDropdownMenuDivider.vue +10 -0
- package/src/components/BaseDropdownMenu/BaseDropdownMenuItem.vue +206 -0
- package/src/components/BaseDropdownMenu/BaseDropdownMenuSearch.vue +49 -0
- package/src/components/BaseDropdownMenu/BaseDropdownMenuTitle.vue +26 -0
- package/src/components/BaseModal/BaseModal.stories.js +143 -0
- package/src/components/BaseModal/BaseModal.vue +187 -0
- package/src/components/BaseModal/BaseModalContent.vue +164 -0
- package/src/components/BaseModal/BaseModalContentOld.vue +242 -0
- package/src/components/BaseRating/BaseRating.spec.js +46 -0
- package/src/components/BaseRating/BaseRating.stories.js +46 -0
- package/src/components/BaseRating/BaseRating.vue +119 -0
- package/src/components/BaseSelect/BaseSelect.stories.js +177 -0
- package/src/components/BaseSelect/BaseSelect.vue +443 -0
- package/src/components/BaseSelect/BaseSelectGroup.vue +34 -0
- package/src/components/BaseSelect/BaseSelectOption.vue +219 -0
- package/src/components/BaseSwitch/BaseSwitch.stories.js +44 -0
- package/src/components/BaseSwitch/BaseSwitch.vue +114 -0
- package/src/components/BaseTag/BaseTag.stories.js +123 -0
- package/src/components/BaseTag/BaseTag.vue +244 -0
- package/src/css/body.postcss +29 -0
- package/src/css/button.postcss +354 -0
- package/src/css/checkbox-radio.postcss +152 -0
- package/src/css/icon.postcss +9 -0
- package/src/css/loader.postcss +120 -0
- package/src/css/popper.postcss +143 -0
- package/src/css/tailwind-utilities.postcss +1 -0
- package/src/css/tailwind.postcss +2 -0
- package/src/css/transitions.postcss +66 -0
- package/src/mixins/DynamicAction.js +59 -0
- package/src/utils/breakpoints.js +8 -0
- package/src/utils/bus.js +3 -0
- package/src/utils/clipboard.js +38 -0
- package/src/utils/devices.js +134 -0
- package/src/utils/elements.js +25 -0
- package/src/utils/index.js +8 -0
- package/src/utils/responsive.js +61 -0
- package/src/utils/router.js +94 -0
- package/src/utils/slot.js +27 -0
- package/src/utils/stack-view.js +116 -0
- package/src/utils/uid.js +5 -0
- package/style-postcss.d.ts +3 -0
- package/style-postcss.js +2 -0
- package/style.js +12 -0
- package/tailwind.config.base.cjs +88 -0
- package/tailwind.config.js +9 -0
- package/tsconfig.check.json +13 -0
- package/tsconfig.json +66 -0
- package/vite.config.js +43 -0
- package/vitest.setup.js +26 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, toRefs, computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
import { getUid } from '../../utils'
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: Number,
|
|
9
|
+
default: 0,
|
|
10
|
+
},
|
|
11
|
+
name: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: null,
|
|
14
|
+
},
|
|
15
|
+
length: {
|
|
16
|
+
type: Number,
|
|
17
|
+
validator: value => value > 0 && value < 100,
|
|
18
|
+
default: 5,
|
|
19
|
+
},
|
|
20
|
+
itemLabels: {
|
|
21
|
+
type: Array,
|
|
22
|
+
default: null,
|
|
23
|
+
},
|
|
24
|
+
hover: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
readonly: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false,
|
|
31
|
+
},
|
|
32
|
+
itemLabelClass: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: null,
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const emit = defineEmits(['update:modelValue'])
|
|
39
|
+
|
|
40
|
+
const { hover, modelValue, itemLabels, name, readonly } = toRefs(props)
|
|
41
|
+
|
|
42
|
+
const uuid = getUid()
|
|
43
|
+
|
|
44
|
+
const rating = ref(modelValue.value)
|
|
45
|
+
const ratingHover = ref(0)
|
|
46
|
+
const hoverModeIn = ref(false)
|
|
47
|
+
|
|
48
|
+
const radioName = computed(() => name.value ?? `base-rating-${uuid}`)
|
|
49
|
+
|
|
50
|
+
function highlighItem (item) {
|
|
51
|
+
return hover.value && hoverModeIn.value ? item <= ratingHover.value : item <= rating.value
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getItemLabel (item) {
|
|
55
|
+
return itemLabels.value?.[item - 1]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function onClick (item) {
|
|
59
|
+
if (readonly.value) return
|
|
60
|
+
rating.value = item
|
|
61
|
+
hoverModeIn.value = false
|
|
62
|
+
emit('update:modelValue', rating.value)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function onMouseenter (item) {
|
|
66
|
+
ratingHover.value = item
|
|
67
|
+
hoverModeIn.value = true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function onMouseleave (item) {
|
|
71
|
+
hoverModeIn.value = false
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<div
|
|
78
|
+
class="base-rating flex gap-3"
|
|
79
|
+
@mouseleave="onMouseleave"
|
|
80
|
+
>
|
|
81
|
+
<div
|
|
82
|
+
v-for="item in length"
|
|
83
|
+
:key="`${radioName}-${item}`"
|
|
84
|
+
class="item"
|
|
85
|
+
:class="{
|
|
86
|
+
active: highlighItem(item),
|
|
87
|
+
'pointer-events-none': readonly
|
|
88
|
+
}"
|
|
89
|
+
data-testid="base-rating-item"
|
|
90
|
+
@mouseenter="onMouseenter(item)"
|
|
91
|
+
>
|
|
92
|
+
<label
|
|
93
|
+
:for="`${radioName}-${item}`"
|
|
94
|
+
class="flex flex-col items-center h-full cursor-pointer"
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
data-testid="base-rating-star-icon"
|
|
98
|
+
class="i-ls-star-fill w-8 h-8"
|
|
99
|
+
:class="[highlighItem(item) ? 'text-livestorm-700' : 'text-grey-300']"
|
|
100
|
+
:fill-color="highlighItem(item) ? 'currentColor' : null"
|
|
101
|
+
/>
|
|
102
|
+
<span
|
|
103
|
+
v-if="getItemLabel(item)"
|
|
104
|
+
class="flex-1 flex items-center justify-center min-w-[52px] text-11-regular text-center text-grey-700 mt-2"
|
|
105
|
+
:class="itemLabelClass"
|
|
106
|
+
>{{ getItemLabel(item) }}</span>
|
|
107
|
+
</label>
|
|
108
|
+
<input
|
|
109
|
+
:id="`${radioName}-${item}`"
|
|
110
|
+
class="hidden"
|
|
111
|
+
:name="radioName"
|
|
112
|
+
type="radio"
|
|
113
|
+
:value="item"
|
|
114
|
+
:readonly="readonly"
|
|
115
|
+
@click="onClick(item)"
|
|
116
|
+
>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import BaseSelect from './BaseSelect.vue'
|
|
2
|
+
import { icons } from '@/../../frontend/.storybook/icons'
|
|
3
|
+
import { action } from '@storybook/addon-actions'
|
|
4
|
+
import { withDesign } from 'storybook-addon-designs'
|
|
5
|
+
|
|
6
|
+
const actions = {
|
|
7
|
+
onInput: action('input'),
|
|
8
|
+
onChange: action('change'),
|
|
9
|
+
onShow: action('show'),
|
|
10
|
+
onHide: action('hide'),
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: 'common/vue/components/BaseSelect',
|
|
15
|
+
component: BaseSelect,
|
|
16
|
+
argTypes: {
|
|
17
|
+
icon: {
|
|
18
|
+
control: {
|
|
19
|
+
type: 'select',
|
|
20
|
+
},
|
|
21
|
+
options: icons,
|
|
22
|
+
},
|
|
23
|
+
placement: {
|
|
24
|
+
control: {
|
|
25
|
+
type: 'select',
|
|
26
|
+
},
|
|
27
|
+
options: ['auto',
|
|
28
|
+
'auto-start',
|
|
29
|
+
'auto-end',
|
|
30
|
+
'top',
|
|
31
|
+
'top-start',
|
|
32
|
+
'top-end',
|
|
33
|
+
'right',
|
|
34
|
+
'right-start',
|
|
35
|
+
'right-end',
|
|
36
|
+
'bottom',
|
|
37
|
+
'bottom-start',
|
|
38
|
+
'bottom-end',
|
|
39
|
+
'left',
|
|
40
|
+
'left-start',
|
|
41
|
+
'left-end'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
decorators: [withDesign, () => ({
|
|
45
|
+
template: '<div style="height: calc(100vh - 40px); width: 100%; display: flex; align-items: center; justify-content: center;"><story/></div>',
|
|
46
|
+
})],
|
|
47
|
+
parameters: {
|
|
48
|
+
design: {
|
|
49
|
+
type: 'figma',
|
|
50
|
+
url: 'https://www.figma.com/file/JY03TRyhauKw0jjoHFFtmMHV/2.-Design-system---Components?node-id=14451%3A175462&t=KIMktHECqTQ06AoK-0',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const Template = (args) => {
|
|
56
|
+
return {
|
|
57
|
+
setup () {
|
|
58
|
+
return {
|
|
59
|
+
args,
|
|
60
|
+
...actions,
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
data: () => ({ currentValue: null }),
|
|
64
|
+
template: `
|
|
65
|
+
<BaseSelect
|
|
66
|
+
v-bind="args"
|
|
67
|
+
@input="onInput"
|
|
68
|
+
@change="onChange"
|
|
69
|
+
@show="onShow"
|
|
70
|
+
@hide="onHide"
|
|
71
|
+
v-model="currentValue"
|
|
72
|
+
:shown="true"
|
|
73
|
+
>
|
|
74
|
+
<BaseSelectOption
|
|
75
|
+
value="option1"
|
|
76
|
+
label="Option 1"
|
|
77
|
+
/>
|
|
78
|
+
<BaseSelectOption
|
|
79
|
+
value="option2"
|
|
80
|
+
label="Option 2"
|
|
81
|
+
/>
|
|
82
|
+
<BaseSelectOption
|
|
83
|
+
value="option3"
|
|
84
|
+
label="Option 3"
|
|
85
|
+
/>
|
|
86
|
+
<BaseSelectOption
|
|
87
|
+
value="option4"
|
|
88
|
+
label="Option 4"
|
|
89
|
+
/>
|
|
90
|
+
<BaseSelectOption
|
|
91
|
+
value="option5"
|
|
92
|
+
label="Option 5"
|
|
93
|
+
/>
|
|
94
|
+
<BaseSelectOption
|
|
95
|
+
value="option6"
|
|
96
|
+
label="Option 6"
|
|
97
|
+
/>
|
|
98
|
+
<BaseSelectOption
|
|
99
|
+
value="option7"
|
|
100
|
+
label="Option 7"
|
|
101
|
+
/>
|
|
102
|
+
<BaseSelectOption
|
|
103
|
+
value="option8"
|
|
104
|
+
label="Option 8"
|
|
105
|
+
/>
|
|
106
|
+
<BaseSelectOption
|
|
107
|
+
value="option9"
|
|
108
|
+
label="Option 9"
|
|
109
|
+
/>
|
|
110
|
+
<BaseSelectOption
|
|
111
|
+
value="option10"
|
|
112
|
+
label="Option 10"
|
|
113
|
+
/>
|
|
114
|
+
</BaseSelect>
|
|
115
|
+
`,
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const TemplateLongOptions = (args) => {
|
|
120
|
+
return {
|
|
121
|
+
setup () {
|
|
122
|
+
return {
|
|
123
|
+
args,
|
|
124
|
+
...actions,
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
data: () => ({ currentValue: null }),
|
|
128
|
+
template: `
|
|
129
|
+
<BaseSelect
|
|
130
|
+
v-bind="args"
|
|
131
|
+
@input="onInput"
|
|
132
|
+
@change="onChange"
|
|
133
|
+
@show="onShow"
|
|
134
|
+
@hide="onHide"
|
|
135
|
+
v-model="currentValue"
|
|
136
|
+
:shown="true"
|
|
137
|
+
>
|
|
138
|
+
<BaseSelectOption
|
|
139
|
+
value="lorem-ipsum-dolor-sit-amet-consetetur-sadipscing-1"
|
|
140
|
+
label="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat 1"
|
|
141
|
+
/>
|
|
142
|
+
<BaseSelectOption
|
|
143
|
+
value="lorem-ipsum-dolor-sit-amet-consetetur-sadipscing-2"
|
|
144
|
+
label="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat 2"
|
|
145
|
+
/>
|
|
146
|
+
<BaseSelectOption
|
|
147
|
+
value="lorem-ipsum-dolor-sit-amet-consetetur-sadipscing-3"
|
|
148
|
+
label="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat 3"
|
|
149
|
+
/>
|
|
150
|
+
</BaseSelect>
|
|
151
|
+
`,
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const SingleChoice = Template.bind({})
|
|
156
|
+
export const MultiChoices = Template.bind({})
|
|
157
|
+
export const WithSearch = Template.bind({})
|
|
158
|
+
export const LongOptions = TemplateLongOptions.bind({})
|
|
159
|
+
|
|
160
|
+
SingleChoice.args = {
|
|
161
|
+
placeholder: 'Choose an option',
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
MultiChoices.args = {
|
|
165
|
+
placeholder: 'Choose options',
|
|
166
|
+
multi: true,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
WithSearch.args = {
|
|
170
|
+
...SingleChoice.args,
|
|
171
|
+
searchEnabled: true,
|
|
172
|
+
searchPlaceholder: 'Search an option',
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
LongOptions.args = {
|
|
176
|
+
...SingleChoice.args,
|
|
177
|
+
}
|