@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.
Files changed (80) hide show
  1. package/.env +1 -0
  2. package/.eslintignore +4 -0
  3. package/.eslintrc.js +47 -0
  4. package/.pkg +11 -0
  5. package/babel.config.js +5 -0
  6. package/build/Dockerfile +31 -0
  7. package/ci/ci.yml +54 -0
  8. package/components-vite.js +29 -0
  9. package/components-webpack.js +29 -0
  10. package/components.d.ts +4 -0
  11. package/index.d.ts +3 -0
  12. package/index.js +24 -0
  13. package/package.json +12 -16
  14. package/plugins.js +17 -0
  15. package/postcss.config.js +1 -0
  16. package/src/components/BaseAutocomplete/BaseAutocomplete.spec.js +506 -0
  17. package/src/components/BaseAutocomplete/BaseAutocomplete.stories.js +184 -0
  18. package/src/components/BaseAutocomplete/BaseAutocomplete.vue +431 -0
  19. package/src/components/BaseBanner/BaseBanner.spec.js +32 -0
  20. package/src/components/BaseBanner/BaseBanner.stories.js +133 -0
  21. package/src/components/BaseBanner/BaseBanner.vue +229 -0
  22. package/src/components/BaseButton/BaseButton.spec.js +98 -0
  23. package/src/components/BaseButton/BaseButton.stories.js +291 -0
  24. package/src/components/BaseButton/BaseButton.vue +193 -0
  25. package/src/components/BaseButton/__snapshots__/BaseButton.spec.js.snap +37 -0
  26. package/src/components/BaseButton/__snapshots__/BaseButton.spec.js.snap.old +31 -0
  27. package/src/components/BaseCheckbox/BaseCheckbox.stories.js +82 -0
  28. package/src/components/BaseCheckbox/BaseCheckbox.vue +161 -0
  29. package/src/components/BaseDropdownMenu/BaseDropdownMenu.stories.js +84 -0
  30. package/src/components/BaseDropdownMenu/BaseDropdownMenu.vue +251 -0
  31. package/src/components/BaseDropdownMenu/BaseDropdownMenuButton.vue +26 -0
  32. package/src/components/BaseDropdownMenu/BaseDropdownMenuDivider.vue +10 -0
  33. package/src/components/BaseDropdownMenu/BaseDropdownMenuItem.vue +206 -0
  34. package/src/components/BaseDropdownMenu/BaseDropdownMenuSearch.vue +49 -0
  35. package/src/components/BaseDropdownMenu/BaseDropdownMenuTitle.vue +26 -0
  36. package/src/components/BaseModal/BaseModal.stories.js +143 -0
  37. package/src/components/BaseModal/BaseModal.vue +187 -0
  38. package/src/components/BaseModal/BaseModalContent.vue +164 -0
  39. package/src/components/BaseModal/BaseModalContentOld.vue +242 -0
  40. package/src/components/BaseRating/BaseRating.spec.js +46 -0
  41. package/src/components/BaseRating/BaseRating.stories.js +46 -0
  42. package/src/components/BaseRating/BaseRating.vue +119 -0
  43. package/src/components/BaseSelect/BaseSelect.stories.js +177 -0
  44. package/src/components/BaseSelect/BaseSelect.vue +443 -0
  45. package/src/components/BaseSelect/BaseSelectGroup.vue +34 -0
  46. package/src/components/BaseSelect/BaseSelectOption.vue +219 -0
  47. package/src/components/BaseSwitch/BaseSwitch.stories.js +44 -0
  48. package/src/components/BaseSwitch/BaseSwitch.vue +114 -0
  49. package/src/components/BaseTag/BaseTag.stories.js +123 -0
  50. package/src/components/BaseTag/BaseTag.vue +244 -0
  51. package/src/css/body.postcss +29 -0
  52. package/src/css/button.postcss +354 -0
  53. package/src/css/checkbox-radio.postcss +152 -0
  54. package/src/css/icon.postcss +9 -0
  55. package/src/css/loader.postcss +120 -0
  56. package/src/css/popper.postcss +143 -0
  57. package/src/css/tailwind-utilities.postcss +1 -0
  58. package/src/css/tailwind.postcss +2 -0
  59. package/src/css/transitions.postcss +66 -0
  60. package/src/mixins/DynamicAction.js +59 -0
  61. package/src/utils/breakpoints.js +8 -0
  62. package/src/utils/bus.js +3 -0
  63. package/src/utils/clipboard.js +38 -0
  64. package/src/utils/devices.js +134 -0
  65. package/src/utils/elements.js +25 -0
  66. package/src/utils/index.js +8 -0
  67. package/src/utils/responsive.js +61 -0
  68. package/src/utils/router.js +94 -0
  69. package/src/utils/slot.js +27 -0
  70. package/src/utils/stack-view.js +116 -0
  71. package/src/utils/uid.js +5 -0
  72. package/style-postcss.d.ts +3 -0
  73. package/style-postcss.js +2 -0
  74. package/style.js +12 -0
  75. package/tailwind.config.base.cjs +88 -0
  76. package/tailwind.config.js +9 -0
  77. package/tsconfig.check.json +13 -0
  78. package/tsconfig.json +66 -0
  79. package/vite.config.js +43 -0
  80. package/vitest.setup.js +26 -0
@@ -0,0 +1,193 @@
1
+ <template>
2
+ <component
3
+ :is="component.is"
4
+ v-bind="component.props"
5
+ :disabled="finalDisabled ? true : null"
6
+ :class="cssClass"
7
+ :aria-label="labelFinal"
8
+ class="base-button"
9
+ @click="onClick"
10
+ @mouseenter="$emit('mouseenter')"
11
+ @mouseleave="$emit('mouseleave')"
12
+ >
13
+ <div class="button-wrapper">
14
+ <!-- Loading animation -->
15
+ <span
16
+ v-if="loading"
17
+ class="button-loader"
18
+ :class="{ 'left-icon': hasLabel }"
19
+ >
20
+ <span
21
+ class="loader"
22
+ />
23
+ </span>
24
+
25
+ <!-- Content -->
26
+ <template
27
+ v-else-if="!hideLeftIcon"
28
+ >
29
+ <div
30
+ v-if="iconSlot"
31
+ :class="{ 'left-icon': hasLabel }"
32
+ class="button-icon"
33
+ >
34
+ <RenderSlot
35
+ :vnodes="iconSlot"
36
+ />
37
+ </div>
38
+ <div
39
+ v-else-if="imageSource"
40
+ :class="{ 'left-icon': hasLabel }"
41
+ class="button-icon"
42
+ >
43
+ <img :src="imageSource">
44
+ </div>
45
+ <div
46
+ v-else-if="icon"
47
+ :class="[
48
+ icon,
49
+ { 'left-icon': hasLabel },
50
+ ]"
51
+ class="button-icon"
52
+ />
53
+ </template>
54
+ <span
55
+ class="content truncate"
56
+ >
57
+ <RenderSlot
58
+ v-if="!hideLabel"
59
+ :vnodes="defaultSlot"
60
+ />
61
+ </span>
62
+ <div
63
+ v-if="iconRight"
64
+ :class="[
65
+ iconRight,
66
+ { 'right-icon': hasLabel },
67
+ ]"
68
+ class="button-icon"
69
+ />
70
+ <div
71
+ v-if="closable"
72
+ class="button-icon icon-close i-ls-x"
73
+ @click.stop.prevent="$emit('close')"
74
+ />
75
+ </div>
76
+ </component>
77
+ </template>
78
+
79
+ <script>
80
+ import { computed } from 'vue'
81
+ import { useSlotsAsComponents } from '../../utils/slot'
82
+ import DynamicAction from '../../mixins/DynamicAction'
83
+
84
+ export default {
85
+
86
+ mixins: [
87
+ DynamicAction,
88
+ ],
89
+
90
+ props: {
91
+ disabled: {
92
+ type: Boolean,
93
+ default: false,
94
+ },
95
+ hideLabel: {
96
+ type: Boolean,
97
+ default: false,
98
+ },
99
+ hideLeftIcon: {
100
+ type: Boolean,
101
+ default: false,
102
+ },
103
+ icon: {
104
+ type: [String, Boolean],
105
+ default: null,
106
+ },
107
+ iconRight: {
108
+ type: [String, Boolean],
109
+ default: null,
110
+ },
111
+ loading: {
112
+ type: Boolean,
113
+ default: false,
114
+ },
115
+ label: {
116
+ type: String,
117
+ default: null,
118
+ },
119
+ imageSource: {
120
+ type: String,
121
+ default: null,
122
+ },
123
+ alignCenter: {
124
+ type: Boolean,
125
+ default: false,
126
+ },
127
+ closable: {
128
+ type: Boolean,
129
+ default: false,
130
+ },
131
+ },
132
+
133
+ emits: [
134
+ 'click',
135
+ 'close',
136
+ 'mouseenter',
137
+ 'mouseleave',
138
+ ],
139
+
140
+ setup (props) {
141
+ const slots = useSlotsAsComponents()
142
+ const defaultSlot = computed(() => slots.default())
143
+ const iconSlot = computed(() => slots.icon())
144
+ const hasLabel = computed(() => !props.hideLabel && !!defaultSlot.value)
145
+
146
+ return {
147
+ defaultSlot,
148
+ iconSlot,
149
+ hasLabel,
150
+ }
151
+ },
152
+
153
+ computed: {
154
+ cssClass () {
155
+ return {
156
+ loading: this.loading,
157
+ 'hide-label': this.hideLabel,
158
+ 'base-button-square': !this.hasLabel && this.hasIcon,
159
+ 'flex justify-center': this.alignCenter,
160
+ closable: this.closable,
161
+ }
162
+ },
163
+
164
+ finalDisabled () {
165
+ return this.disabled || this.loading
166
+ },
167
+
168
+ hasIcon () {
169
+ return this.icon || this.iconRight
170
+ },
171
+
172
+ isToggle () {
173
+ return this.iconRight?.includes('i-ls-chevron-down') && this.hasLabel
174
+ },
175
+
176
+ labelFinal () {
177
+ return !this.isToggle && (
178
+ ((this.$slots.default?.()[0].text) || this.label)?.trim() || undefined
179
+ )
180
+ },
181
+ },
182
+
183
+ methods: {
184
+ onClick (event) {
185
+ if (this.finalDisabled) {
186
+ event.preventDefault()
187
+ } else {
188
+ this.$emit('click', event)
189
+ }
190
+ },
191
+ },
192
+ }
193
+ </script>
@@ -0,0 +1,37 @@
1
+ // Vitest Snapshot v1
2
+
3
+ exports[`BaseButton > snapshot: a 1`] = `
4
+ "<a href=\\"https://google.com/\\" class=\\"base-button\\">
5
+ <div class=\\"button-wrapper\\">
6
+ <!-- Loading animation -->
7
+ <!-- Content -->
8
+ <!--v-if--><span class=\\"content truncate\\"><span>Google</span></span>
9
+ <!--v-if-->
10
+ <!--v-if-->
11
+ </div>
12
+ </a>"
13
+ `;
14
+
15
+ exports[`BaseButton > snapshot: button 1`] = `
16
+ "<button type=\\"submit\\" class=\\"base-button\\">
17
+ <div class=\\"button-wrapper\\">
18
+ <!-- Loading animation -->
19
+ <!-- Content -->
20
+ <!--v-if--><span class=\\"content truncate\\"><span>Hello</span></span>
21
+ <!--v-if-->
22
+ <!--v-if-->
23
+ </div>
24
+ </button>"
25
+ `;
26
+
27
+ exports[`BaseButton > snapshot: router-link 1`] = `
28
+ "<router-link to=\\"[object Object]\\" class=\\"base-button\\">
29
+ <div class=\\"button-wrapper\\">
30
+ <!-- Loading animation -->
31
+ <!-- Content -->
32
+ <!--v-if--><span class=\\"content truncate\\"><span>My Page</span></span>
33
+ <!--v-if-->
34
+ <!--v-if-->
35
+ </div>
36
+ </router-link>"
37
+ `;
@@ -0,0 +1,31 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`BaseButton snapshot: a 1`] = `
4
+ <a href="https://google.com/" class="base-button">
5
+ <div class="button-wrapper">
6
+ <!----> <span class="content truncate"><span>Google</span></span>
7
+ <!---->
8
+ <!---->
9
+ </div>
10
+ </a>
11
+ `;
12
+
13
+ exports[`BaseButton snapshot: button 1`] = `
14
+ <button type="submit" class="base-button">
15
+ <div class="button-wrapper">
16
+ <!----> <span class="content truncate"><span>Hello</span></span>
17
+ <!---->
18
+ <!---->
19
+ </div>
20
+ </button>
21
+ `;
22
+
23
+ exports[`BaseButton snapshot: router-link 1`] = `
24
+ <router-link to="[object Object]" exact="true" class="base-button">
25
+ <div class="button-wrapper">
26
+ <!----> <span class="content truncate"><span>My Page</span></span>
27
+ <!---->
28
+ <!---->
29
+ </div>
30
+ </router-link>
31
+ `;
@@ -0,0 +1,82 @@
1
+ import BaseCheckbox from './BaseCheckbox.vue'
2
+ import { action } from '@storybook/addon-actions'
3
+
4
+ export default {
5
+ title: 'common/vue/components/BaseCheckbox',
6
+ component: BaseCheckbox,
7
+ }
8
+
9
+ const actions = {
10
+ onChange: action('change'),
11
+ onClick: action('click'),
12
+ }
13
+
14
+ const Template = (args) => ({
15
+ components: { BaseCheckbox },
16
+ setup: () => ({ args, ...actions }),
17
+ template: '<BaseCheckbox v-bind="args" @tooltip-clicked="onClick" @change="onChange" />',
18
+ })
19
+
20
+ export const Checked = Template.bind({})
21
+ Checked.args = {
22
+ forId: 'my-checkbox',
23
+ label: 'This checkbox is checked',
24
+ value: true,
25
+ }
26
+
27
+ export const WithOtherIcon = Template.bind({})
28
+ WithOtherIcon.args = {
29
+ forId: 'my-checkbox',
30
+ label: 'This checkbox is checked',
31
+ icon: 'i-ls-minus',
32
+ value: true,
33
+ }
34
+
35
+ export const Unchecked = Template.bind({})
36
+ Unchecked.args = {
37
+ forId: 'my-checkbox',
38
+ label: 'This checkbox is unchecked',
39
+ value: false,
40
+ }
41
+
42
+ export const WithLabelClass = Template.bind({})
43
+ WithLabelClass.args = {
44
+ forId: 'my-checkbox',
45
+ label: 'This checkbox has a label class',
46
+ labelClass: 'text-16-medium',
47
+ }
48
+
49
+ export const WithInputClass = Template.bind({})
50
+ WithInputClass.args = {
51
+ forId: 'my-checkbox',
52
+ label: 'This checkbox has an input class',
53
+ inputClass: 'error',
54
+ }
55
+
56
+ export const WithTooltip = Template.bind({})
57
+ WithTooltip.args = {
58
+ forId: 'my-checkbox',
59
+ label: 'This checkbox has a tooltip',
60
+ tooltip: 'Checkbox tooltip',
61
+ }
62
+
63
+ export const Required = Template.bind({})
64
+ Required.args = {
65
+ forId: 'my-checkbox',
66
+ label: 'This checkbox is required',
67
+ required: true,
68
+ }
69
+
70
+ export const Disabled = Template.bind({})
71
+ Disabled.args = {
72
+ forId: 'my-checkbox',
73
+ label: 'This checkbox is disabled',
74
+ disabled: true,
75
+ }
76
+
77
+ export const IgnorePointerEvents = Template.bind({})
78
+ IgnorePointerEvents.args = {
79
+ forId: 'my-checkbox',
80
+ label: 'This checkbox ignore pointer events',
81
+ disableChange: true,
82
+ }
@@ -0,0 +1,161 @@
1
+ <template>
2
+ <div
3
+ class="base-checkbox"
4
+ :class="{
5
+ 'base-checkbox-disabled': disabled,
6
+ 'pointer-events-none': disableChange,
7
+ 'base-checkbox-consent' : isConsent,
8
+ }"
9
+ >
10
+ <input
11
+ :id="forId"
12
+ ref="checkbox"
13
+ :checked="checked"
14
+ :disabled="disabled"
15
+ type="checkbox"
16
+ @change="onChange"
17
+ >
18
+ <label :for="forId">
19
+ <span
20
+ class="input-custom !mt-[1px]"
21
+ :class="inputClass"
22
+ >
23
+ <div
24
+ v-if="!disabled || checked"
25
+ :class="icon"
26
+ class="check-checkbox"
27
+ />
28
+ </span>
29
+ <span
30
+ v-if="label"
31
+ class="label-custom"
32
+ >
33
+ <span
34
+ :class="labelClass"
35
+ v-html="required ? `${label} *` : label"
36
+ />
37
+ <span
38
+ v-if="tooltip"
39
+ v-tooltip="tooltip"
40
+ data-testid="open-tooltip"
41
+ @click.stop.prevent="$emit('tooltip-clicked')"
42
+ />
43
+ </span>
44
+ </label>
45
+ </div>
46
+ </template>
47
+
48
+ <script>
49
+ export default {
50
+ inject: {
51
+ BaseFormInputInjection: { default: null },
52
+ },
53
+
54
+ props: {
55
+ // eslint-disable-next-line
56
+ modelValue: {},
57
+
58
+ // eslint-disable-next-line
59
+ value: {
60
+ default: false,
61
+ },
62
+
63
+ label: {
64
+ type: String,
65
+ default: null,
66
+ },
67
+
68
+ labelClass: {
69
+ type: String,
70
+ default: null,
71
+ },
72
+
73
+ inputClass: {
74
+ type: String,
75
+ default: null,
76
+ },
77
+
78
+ forId: {
79
+ type: String,
80
+ required: true,
81
+ },
82
+
83
+ tooltip: {
84
+ type: String,
85
+ default: null,
86
+ },
87
+
88
+ required: {
89
+ type: Boolean,
90
+ default: false,
91
+ },
92
+
93
+ disabled: {
94
+ type: Boolean,
95
+ default: false,
96
+ },
97
+
98
+ disableChange: {
99
+ type: Boolean,
100
+ default: false,
101
+ },
102
+
103
+ isConsent: {
104
+ type: Boolean,
105
+ default: false,
106
+ },
107
+
108
+ icon: {
109
+ type: String,
110
+ default: 'i-ls-check',
111
+ },
112
+ },
113
+
114
+ emits: [
115
+ 'change',
116
+ 'update:modelValue',
117
+ 'tooltip-clicked',
118
+ ],
119
+
120
+ computed: {
121
+ baseFormInputValue () {
122
+ return this.BaseFormInputInjection && this.BaseFormInputInjection.childConfig.value
123
+ },
124
+
125
+ checked () {
126
+ if (this.modelValue !== undefined) {
127
+ return Array.isArray(this.modelValue)
128
+ ? this.modelValue.includes(this.value)
129
+ : this.modelValue === this.value
130
+ } else if (this.BaseFormInputInjection && !!this.baseFormInputValue) {
131
+ return Array.isArray(this.baseFormInputValue)
132
+ ? this.baseFormInputValue.includes(this.value)
133
+ : this.baseFormInputValue === this.value && this.value
134
+ }
135
+ return this.value
136
+ },
137
+ },
138
+
139
+ methods: {
140
+ onChange (event) {
141
+ let newValue = event.target.checked
142
+
143
+ if (this.modelValue !== undefined) {
144
+ newValue = [...this.modelValue]
145
+ if (event.target.checked) {
146
+ newValue.push(this.value)
147
+ } else {
148
+ newValue.splice(newValue.indexOf(this.value), 1)
149
+ }
150
+ }
151
+
152
+ this.$emit('update:modelValue', newValue)
153
+ this.$emit('change', newValue)
154
+
155
+ if (this.BaseFormInputInjection) {
156
+ this.BaseFormInputInjection.setInputModel(newValue)
157
+ }
158
+ },
159
+ },
160
+ }
161
+ </script>
@@ -0,0 +1,84 @@
1
+ import BaseDropdownMenu from './BaseDropdownMenu.vue'
2
+ import { withDesign } from 'storybook-addon-designs'
3
+
4
+ export default {
5
+ title: 'common/vue/components/BaseDropdownMenu',
6
+ component: BaseDropdownMenu,
7
+ decorators: [withDesign],
8
+ parameters: {
9
+ design: {
10
+ type: 'figma',
11
+ url: 'https://www.figma.com/file/JY03TRyhauKw0jjoHFFtmMHV/2.-Design-system---Components?node-id=13845%3A172133&t=Ppfihth2ztZAaEVN-0',
12
+ },
13
+ },
14
+ }
15
+
16
+ const headerTemplate = (args) => ({
17
+ setup: () => ({ args }),
18
+ template: `
19
+ <BaseDropdownMenu v-bind="args" :shown="true">
20
+ <template #popper>
21
+ <BaseDropdownMenuItem
22
+ icon="i-ls-settings"
23
+ label="Access to the event"
24
+ secondary-label="Grab your popcorn"
25
+ additional-info="2"
26
+ secondary-icon="i-ls-external-link"
27
+ >
28
+ <template #additional-left-part>
29
+ <div
30
+ class="status rounded-full w-1 h-1 bg-green-600"
31
+ />
32
+ </template>
33
+ </BaseDropdownMenuItem>
34
+ <BaseDropdownMenuItem
35
+ label="Go to the settings page"
36
+ secondary-label="There are so much settings !"
37
+ disabled
38
+ />
39
+ <BaseDropdownMenuItem
40
+ label="A simple item"
41
+ />
42
+ <BaseDropdownMenuDivider/>
43
+ <BaseDropdownMenuTitle title="A nice title" />
44
+ <BaseDropdownMenuItem
45
+ label="Open chat"
46
+ active
47
+ secondary-icon="i-ls-chevron-right"
48
+ />
49
+ <BaseDropdownMenuItem
50
+ label="An item during loading..."
51
+ loading
52
+ />
53
+ <BaseDropdownMenuSearch class="mb-1" />
54
+ <BaseDropdownMenuItem
55
+ label="Go the the event page"
56
+ href="https://google.com"
57
+ secondary-icon="i-ls-external-link"
58
+ />
59
+ <BaseDropdownMenuItem
60
+ label="Delete user"
61
+ secondary-label="The user could not join the event"
62
+ icon="i-ls-trash text-red-700"
63
+ label-class="text-red-700"
64
+ />
65
+ <BaseDropdownMenuButton class="base-button-primary w-full my-2">Click on me</BaseDropdownMenuButton>
66
+ </template>
67
+ </BaseDropdownMenu>
68
+ `,
69
+ })
70
+
71
+ export const Common = headerTemplate.bind({})
72
+ Common.args = {}
73
+
74
+ export const WithBottomSearch = headerTemplate.bind({})
75
+ WithBottomSearch.args = {
76
+ searchPosition: 'bottom',
77
+ searchEnabled: true,
78
+ }
79
+
80
+ export const WithTopSearch = headerTemplate.bind({})
81
+ WithTopSearch.args = {
82
+ searchPosition: 'top',
83
+ searchEnabled: true,
84
+ }