@rocketui/vue 0.0.47 → 0.0.49

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 (169) hide show
  1. package/dist/rocket-ui-vue.cjs.js +1 -0
  2. package/dist/rocket-ui-vue.d.ts +1812 -0
  3. package/dist/rocket-ui-vue.es.js +9270 -0
  4. package/dist/rocket-ui-vue.umd.js +1 -0
  5. package/dist/style.css +2 -0
  6. package/package.json +7 -1
  7. package/.eslintrc.cjs +0 -79
  8. package/.gitattributes +0 -2
  9. package/.github/workflows/chromatic.yml +0 -28
  10. package/.github/workflows/publish-storybook.yml +0 -41
  11. package/.husky/pre-commit +0 -4
  12. package/.prettierrc.cjs +0 -10
  13. package/.storybook/Theme.js +0 -17
  14. package/.storybook/main.ts +0 -20
  15. package/.storybook/manager-head.html +0 -3
  16. package/.storybook/manager.js +0 -8
  17. package/.storybook/preview-head.html +0 -3
  18. package/.storybook/preview.ts +0 -36
  19. package/.storybook/source-panel/manager.js +0 -28
  20. package/.storybook/withSource.js +0 -91
  21. package/.vscode/extensions.json +0 -11
  22. package/.vscode/settings.json +0 -20
  23. package/index.html +0 -13
  24. package/lib/main.ts +0 -48
  25. package/postcss.config.cjs +0 -9
  26. package/resources/rocket-ui-logo-dark.svg +0 -27
  27. package/resources/rocket-ui-logo-light.svg +0 -27
  28. package/shims-rocketui.d.ts +0 -9
  29. package/src/App.vue +0 -15
  30. package/src/assets/blank-avatar.svg +0 -3
  31. package/src/assets/icons/mdi.js +0 -7302
  32. package/src/assets/logo.svg +0 -1
  33. package/src/components/Accordion/Accordion.mdx +0 -88
  34. package/src/components/Accordion/Accordion.stories.ts +0 -257
  35. package/src/components/Accordion/RAccordion.vue +0 -73
  36. package/src/components/Accordion/accordion.css +0 -75
  37. package/src/components/Accordion/accordion.spec.ts +0 -123
  38. package/src/components/Alert/Alert.mdx +0 -120
  39. package/src/components/Alert/Alert.stories.ts +0 -118
  40. package/src/components/Alert/RAlert.vue +0 -119
  41. package/src/components/Alert/alert.css +0 -136
  42. package/src/components/Alert/alert.spec.ts +0 -32
  43. package/src/components/Avatar/Avatar.mdx +0 -96
  44. package/src/components/Avatar/Avatar.stories.ts +0 -65
  45. package/src/components/Avatar/RAvatar.vue +0 -115
  46. package/src/components/Avatar/avatar.css +0 -82
  47. package/src/components/Avatar/avatar.spec.ts +0 -38
  48. package/src/components/Badge/Badge.mdx +0 -112
  49. package/src/components/Badge/Badge.stories.ts +0 -99
  50. package/src/components/Badge/RBadge.vue +0 -89
  51. package/src/components/Badge/badge.css +0 -63
  52. package/src/components/Badge/badge.spec.ts +0 -20
  53. package/src/components/Box/Box.mdx +0 -20
  54. package/src/components/Box/Box.stories.ts +0 -56
  55. package/src/components/Box/RBox.vue +0 -97
  56. package/src/components/Breadcrumb/Breadcrumb.stories.ts +0 -115
  57. package/src/components/Breadcrumb/RBreadcrumb.vue +0 -43
  58. package/src/components/Breadcrumb/breadcrumb.css +0 -29
  59. package/src/components/Button/Button.mdx +0 -148
  60. package/src/components/Button/Button.spec.ts +0 -29
  61. package/src/components/Button/Button.stories.ts +0 -118
  62. package/src/components/Button/RButton.vue +0 -179
  63. package/src/components/Button/button.css +0 -146
  64. package/src/components/Checkbox/Checkbox.mdx +0 -100
  65. package/src/components/Checkbox/Checkbox.stories.ts +0 -67
  66. package/src/components/Checkbox/RCheckbox.vue +0 -195
  67. package/src/components/Checkbox/checkbox.css +0 -67
  68. package/src/components/Checkbox/checkbox.spec.ts +0 -60
  69. package/src/components/Chips/Chip.mdx +0 -113
  70. package/src/components/Chips/Chip.stories.ts +0 -122
  71. package/src/components/Chips/RChip.vue +0 -125
  72. package/src/components/Chips/chip.css +0 -62
  73. package/src/components/Chips/chip.spec.ts +0 -40
  74. package/src/components/Dropdown/Dropdown.mdx +0 -135
  75. package/src/components/Dropdown/Dropdown.stories.ts +0 -84
  76. package/src/components/Dropdown/RDropdown.vue +0 -392
  77. package/src/components/Dropdown/dropdown.css +0 -113
  78. package/src/components/Dropdown/dropdown.spec.ts +0 -98
  79. package/src/components/Flex/Flex.mdx +0 -20
  80. package/src/components/Flex/Flex.stories.js +0 -127
  81. package/src/components/Flex/RFlex.vue +0 -91
  82. package/src/components/Grid/Grid.mdx +0 -20
  83. package/src/components/Grid/Grid.stories.js +0 -107
  84. package/src/components/Grid/RGrid.vue +0 -138
  85. package/src/components/Icon/Icon.mdx +0 -68
  86. package/src/components/Icon/Icon.stories.ts +0 -33
  87. package/src/components/Icon/RIcon.vue +0 -56
  88. package/src/components/Icon/icon.spec.ts +0 -25
  89. package/src/components/ItemGroup/ItemGroup.stories.ts +0 -91
  90. package/src/components/ItemGroup/RItem.vue +0 -74
  91. package/src/components/ItemGroup/RItemGroup.vue +0 -122
  92. package/src/components/ItemGroup/__snapshots__/itemgroup.spec.ts.snap +0 -13
  93. package/src/components/ItemGroup/itemgroup.spec.ts +0 -67
  94. package/src/components/Label/Label.mdx +0 -50
  95. package/src/components/Label/Label.stories.ts +0 -38
  96. package/src/components/Label/RLabel.vue +0 -42
  97. package/src/components/Label/label.css +0 -0
  98. package/src/components/Modal/Modal.mdx +0 -91
  99. package/src/components/Modal/Modal.stories.ts +0 -125
  100. package/src/components/Modal/RModal.vue +0 -130
  101. package/src/components/Modal/modal.css +0 -41
  102. package/src/components/Modal/modal.spec.ts +0 -25
  103. package/src/components/Pagination/Pagination.stories.ts +0 -24
  104. package/src/components/Pagination/RPagination.vue +0 -103
  105. package/src/components/Pagination/pagination.css +0 -47
  106. package/src/components/Pagination/pagination.spec.ts +0 -17
  107. package/src/components/ProgressBar/ProgressBar.stories.ts +0 -34
  108. package/src/components/ProgressBar/RProgressBar.vue +0 -21
  109. package/src/components/ProgressBar/progressbar.css +0 -24
  110. package/src/components/ProgressBar/progressbar.spec.ts +0 -17
  111. package/src/components/Shared/Enums.ts +0 -1
  112. package/src/components/Sidebar/RSidebar.vue +0 -27
  113. package/src/components/Sidebar/Sidebar.mdx +0 -31
  114. package/src/components/Sidebar/Sidebar.stories.ts +0 -34
  115. package/src/components/Sidebar/sidebar.css +0 -18
  116. package/src/components/Sidebar/sidebar.spec.ts +0 -33
  117. package/src/components/Snackbar/RSnackbar.vue +0 -136
  118. package/src/components/Snackbar/Snackbar.mdx +0 -126
  119. package/src/components/Snackbar/Snackbar.stories.ts +0 -93
  120. package/src/components/Snackbar/snackbar.css +0 -99
  121. package/src/components/Snackbar/snackbar.spec.ts +0 -56
  122. package/src/components/Switch/RSwitch.vue +0 -147
  123. package/src/components/Switch/Switch.mdx +0 -102
  124. package/src/components/Switch/Switch.stories.ts +0 -79
  125. package/src/components/Switch/switch.css +0 -102
  126. package/src/components/Switch/switch.spec.ts +0 -31
  127. package/src/components/TabItem/RTabItem.vue +0 -175
  128. package/src/components/TabItem/TabItem.mdx +0 -95
  129. package/src/components/TabItem/TabItem.spec.ts +0 -29
  130. package/src/components/TabItem/TabItem.stories.ts +0 -97
  131. package/src/components/TabItem/common.ts +0 -6
  132. package/src/components/TabItem/tab-item.css +0 -29
  133. package/src/components/Tabs/RTabs.vue +0 -94
  134. package/src/components/Tabs/Tabs.mdx +0 -78
  135. package/src/components/Tabs/Tabs.spec.ts +0 -28
  136. package/src/components/Tabs/Tabs.stories.ts +0 -191
  137. package/src/components/Tabs/tabs.css +0 -13
  138. package/src/components/Tabs/types.ts +0 -11
  139. package/src/components/TextArea/RTextArea.vue +0 -142
  140. package/src/components/TextArea/TextArea.mdx +0 -108
  141. package/src/components/TextArea/TextArea.stories.ts +0 -55
  142. package/src/components/TextArea/textarea.css +0 -51
  143. package/src/components/TextArea/textarea.spec.ts +0 -36
  144. package/src/components/Textfield/RTextfield.vue +0 -372
  145. package/src/components/Textfield/Textfield.mdx +0 -159
  146. package/src/components/Textfield/Textfield.stories.ts +0 -121
  147. package/src/components/Textfield/textfield.css +0 -81
  148. package/src/components/Textfield/textfield.spec.ts +0 -34
  149. package/src/components/Tooltip/RTooltip.vue +0 -325
  150. package/src/components/Tooltip/Tooltip.mdx +0 -111
  151. package/src/components/Tooltip/Tooltip.stories.ts +0 -203
  152. package/src/components/Tooltip/common.ts +0 -91
  153. package/src/components/Tooltip/tooltip.css +0 -34
  154. package/src/components/Tooltip/tooltip.spec.ts +0 -81
  155. package/src/components/Typography/Typography.mdx +0 -109
  156. package/src/components/Typography/typography.css +0 -128
  157. package/src/directives/index.ts +0 -19
  158. package/src/index.css +0 -241
  159. package/src/main.ts +0 -5
  160. package/src/scripts/buildIcons.js +0 -21
  161. package/src/stories/Colors.mdx +0 -355
  162. package/src/stories/GettingStarted.mdx +0 -121
  163. package/src/stories/Layout.mdx +0 -15
  164. package/tailwind.config.cjs +0 -16
  165. package/tsconfig.json +0 -24
  166. package/vite.config.ts +0 -39
  167. package/vitest.config.ts +0 -12
  168. /package/{public → dist}/design-tokens.source.json +0 -0
  169. /package/{public → dist}/favicon.ico +0 -0
@@ -1,67 +0,0 @@
1
- @import '../../index.css';
2
-
3
- .checkbox-wrapper {
4
- @apply flex items-start;
5
- }
6
-
7
- .checkbox-container {
8
- @apply flex;
9
-
10
- &__input {
11
- @apply absolute opacity-0 z-20 cursor-pointer h-5 w-5;
12
- }
13
- }
14
-
15
- .checkbox {
16
- @apply transition-all duration-200 ease-in-out flex items-center justify-center text-[var(--neutral-200)] cursor-pointer h-5 w-5 border-[var(--neutral-200)] rounded border-2;
17
-
18
- &:hover {
19
- @apply border-[var(--primary-500)];
20
- }
21
-
22
- &--checked {
23
- @apply text-white border-[var(--primary-500)] bg-[var(--primary-500)];
24
- &:hover {
25
- @apply text-white border-[var(--primary-700)] bg-[var(--primary-700)];
26
- }
27
- }
28
- &--indeterminate {
29
- @apply border-[var(--primary-500)] text-[var(--primary-500)];
30
- &:hover {
31
- @apply text-white border-[var(--primary-700)] bg-[var(--primary-700)];
32
- }
33
- }
34
- &--error {
35
- @apply border-[var(--error-500)] bg-[var(--error-100)] text-white;
36
- &:hover {
37
- @apply border-[var(--error-700)];
38
- }
39
- }
40
- &--error&--checked {
41
- @apply bg-[var(--error-500)];
42
- &:hover {
43
- @apply bg-[var(--error-700)];
44
- }
45
- }
46
- &[data-disabled='true'] {
47
- @apply bg-[var(--neutral-100)] border-[var(--neutral-200)] text-[var(--neutral-200)] cursor-not-allowed;
48
- }
49
- }
50
-
51
- .checkbox-texts {
52
- @apply flex flex-col ml-3.5;
53
-
54
- &__label {
55
- @apply text-[var(--neutral-900)] cursor-auto text-sm;
56
-
57
- &[data-disabled='true'] {
58
- @apply cursor-not-allowed;
59
- }
60
- }
61
- &__hint {
62
- @apply text-[var(--neutral-500)] text-xs;
63
- }
64
- &__error {
65
- @apply text-[var(--error-500)] text-xs;
66
- }
67
- }
@@ -1,60 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
-
3
- import { mount } from '@vue/test-utils';
4
- import Checkbox from './RCheckbox.vue';
5
-
6
- describe('Checkbox', () => {
7
- it('renders properly', () => {
8
- const wrapper = mount(Checkbox, {
9
- props: {
10
- id: 'checkbox-id',
11
- label: 'Checkbox label',
12
- disabled: false,
13
- },
14
- });
15
- expect(wrapper.exists()).toBe(true);
16
- expect(wrapper.find('label').exists()).toBe(true);
17
- expect(wrapper.find('label').element.getAttribute('for')).toBe(
18
- 'checkbox-id'
19
- );
20
- expect(wrapper.find('input').exists()).toBe(true);
21
- expect(wrapper.find('input').element.getAttribute('id')).toBe(
22
- 'checkbox-id'
23
- );
24
- expect(wrapper.find('input').element.getAttribute('type')).toBe('checkbox');
25
- expect(wrapper.find('input').element.getAttribute('disabled')).toBe(null);
26
- expect(
27
- wrapper
28
- .find('.checkbox')
29
- .trigger('click')
30
- .then(() => {
31
- expect(wrapper.find('.checkbox').classes()).toContain(
32
- 'checkbox--checked'
33
- );
34
- })
35
- );
36
- });
37
- it('indeterminate', () => {
38
- const wrapper = mount(Checkbox, {
39
- props: {
40
- id: 'checkbox-id',
41
- label: 'Checkbox label',
42
- disabled: false,
43
- indeterminate: true,
44
- },
45
- });
46
- expect(wrapper.find('.checkbox').classes()).toContain(
47
- 'checkbox--indeterminate'
48
- );
49
- expect(
50
- wrapper
51
- .find('.checkbox')
52
- .trigger('click')
53
- .then(() => {
54
- expect(wrapper.find('.checkbox').classes()).toContain(
55
- 'checkbox--checked'
56
- );
57
- })
58
- );
59
- });
60
- });
@@ -1,113 +0,0 @@
1
- import { Canvas, Meta, Story, Controls } from '@storybook/blocks';
2
- import * as ChipStories from './Chip.stories';
3
-
4
- <Meta of={ChipStories} />
5
-
6
- # Chip
7
-
8
- A Chip component is a small, compact element that is used to represent a complex piece of information, an attribute, or a status in a small space. Chips are often used in lists, grids, and other data-heavy layouts to help users easily identify and understand important information.
9
-
10
- - [Overview](#overview)
11
-
12
- - [Playground](#playground)
13
-
14
- - [Usage with props](#usage)
15
-
16
- - [Stories](#stories)
17
-
18
- - [Tips](#tips)
19
-
20
- ### Overview <a id="overview" />
21
-
22
- Chips are typically displayed as small, rectangular elements with a small amount of text or an icon inside. They may have a border, a background color, and/or a drop shadow to visually distinguish them from the rest of the layout.
23
- They can be interactable, meaning that users can click or tap on them to trigger an action. For example, a Chip might open a detailed view of the information it represents, delete itself from a list, or mark itself as selected. Chips can come in various types, depending on the information or status they represent.
24
-
25
- <Canvas>
26
- <Story of={ChipStories.Overview} />
27
- </Canvas>
28
-
29
- ### Playground <a id="playground" />
30
-
31
- > Changes you make in the controls will be reflected in the example above.
32
-
33
- <Controls of={ChipStories.Overview} exclude={/^(click.*|on.*)$/} />
34
-
35
- ## Usage with props <a id="usage" />
36
-
37
- ## prependIcon (optional)
38
-
39
- The **prependIcon** prop allows you to specify an icon to be displayed at the beginning (or "prepend") of the Chip. This can help to visually distinguish the Chip or to add additional context or meaning.
40
-
41
- ## variant (required)
42
-
43
- The **variant** prop allows you to specify the appearance of the Chip. Possible values for this prop might include "primary", "secondary", "success", "error", "warning" or "info". The variant determines the visual styles of the Chip.
44
-
45
- ## size (optional)
46
-
47
- The **size** prop allows you to specify the size of the Chip. Possible values for this prop might include "small", "medium", or "large". The size determines the height and width of the Chip.
48
-
49
- ## label (optional)
50
-
51
- The **label** prop allows you to specify the text label of the Chip. This is the main content of the Chip and should be concise and informative.
52
-
53
- ## disabled (optional)
54
-
55
- The **disabled** prop allows you to specify whether the Chip is disabled or not. A disabled Chip cannot be interacted with and may have a different appearance to indicate this.
56
-
57
- ## appendIcon (optional)
58
-
59
- The **appendIcon** prop allows you to specify an icon to be displayed at the end (or "append") of the Chip. This can be used for actions such as deleting the Chip or opening a detailed view.
60
-
61
- ## ghost (optional)
62
-
63
- The **ghost** prop allows you to specify whether the Chip should have a transparent background. A ghost Chip appears "hollow" and may be used for overlaid or partially transparent layouts.
64
-
65
- ## Stories <a id="stories" />
66
-
67
- ### Primary
68
-
69
- <Canvas>
70
- <Story of={ChipStories.Primary} />
71
- </Canvas>
72
-
73
- ### Secondary
74
-
75
- <Canvas>
76
- <Story of={ChipStories.Secondary} />
77
- </Canvas>
78
-
79
- ### Success
80
-
81
- <Canvas>
82
- <Story of={ChipStories.Success} />
83
- </Canvas>
84
-
85
- ### Error
86
-
87
- <Canvas>
88
- <Story of={ChipStories.Error} />
89
- </Canvas>
90
-
91
- ### Warning
92
-
93
- <Canvas>
94
- <Story of={ChipStories.Warning} />
95
- </Canvas>
96
-
97
- ### Info
98
-
99
- <Canvas>
100
- <Story of={ChipStories.Info} />
101
- </Canvas>
102
-
103
- ### Tips <a id="tips" />
104
-
105
- 💡 Chips are best used to represent specific, atomic pieces of information or actions, such as labels, categories, metadata, or buttons. Avoid using chips for long or complex pieces of text, as they are designed to be compact and concise.
106
-
107
- 💡 Make sure that the labels on your chips are clear and descriptive, as they are the main content of the chips and the primary means of communicating information to users. Avoid using abbreviations or jargon unless they are widely understood by your target audience.
108
-
109
- 💡 Choose the appropriate type and variant of chip for the information or action it represents.
110
-
111
- 💡 Choose the appropriate size of chip for the context in which it will be used. Small chips are best for dense layouts with many chips, while medium or large chips are better for more spacious layouts or for emphasis.
112
-
113
- 💡 Make sure that your chips are accessible to all users, including those using assistive technologies. This means that chips should have clear, descriptive text labels, and that the actions they trigger should be clearly announced to screen reader users. Chips should also be keyboard-navigable, meaning that users should be able to focus on them and trigger their actions using the keyboard.
@@ -1,122 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/vue3';
2
-
3
- import Chip from './RChip.vue';
4
- import Icon from '../Icon/RIcon.vue';
5
-
6
- const DefaultArgTypes = {
7
- variant: {
8
- type: 'select',
9
- options: ['primary', 'secondary', 'success', 'error', 'warning', 'info'],
10
- },
11
- 'onClick:chip': {
12
- action: 'click:chip',
13
- },
14
- 'onClick:close': {
15
- action: 'click:close',
16
- },
17
- };
18
-
19
- const DefaultArgs = {
20
- label: 'Chip',
21
- prependIcon: '',
22
- appendIcon: 'mdiClose',
23
- ghost: false,
24
- variant: 'primary',
25
- disabled: false,
26
- closable: true,
27
- };
28
-
29
- const ChipStory = {
30
- title: 'Components/Chip',
31
- component: Chip,
32
- setup: (args: typeof Chip) => {
33
- return {
34
- args,
35
- };
36
- },
37
- template: `
38
- <Chip v-bind="args"/>
39
- `,
40
- args: DefaultArgs,
41
- argTypes: DefaultArgTypes,
42
- } as Meta<typeof Chip>;
43
-
44
- export default ChipStory;
45
-
46
- type Story = StoryObj<typeof ChipStory>;
47
-
48
- export const Overview: Story = {
49
- args: {
50
- prependIcon: 'mdiFaceMan',
51
- },
52
- };
53
-
54
- export const Primary: Story = {};
55
-
56
- export const Secondary: Story = {
57
- args: {
58
- variant: 'secondary',
59
- },
60
- };
61
-
62
- export const Success: Story = {
63
- args: {
64
- variant: 'success',
65
- },
66
- };
67
-
68
- export const Error: Story = {
69
- args: {
70
- variant: 'error',
71
- },
72
- };
73
-
74
- export const Warning: Story = {
75
- args: {
76
- variant: 'warning',
77
- },
78
- };
79
-
80
- export const Info: Story = {
81
- args: {
82
- variant: 'info',
83
- },
84
- };
85
-
86
- export const Ghost: Story = {
87
- args: {
88
- ghost: true,
89
- },
90
- };
91
-
92
- export const Disabled: Story = {
93
- args: {
94
- disabled: true,
95
- },
96
- };
97
-
98
- export const Closable: Story = {
99
- args: {
100
- closable: true,
101
- },
102
- };
103
-
104
- export const Slots = {
105
- render: (args: any) => ({
106
- components: { Chip, Icon },
107
- setup() {
108
- return { args };
109
- },
110
- template: `
111
- <Chip v-bind="args">
112
- <template v-slot:prepend>
113
- <Icon name="mdiCircle" size="16" />
114
- </template>
115
- <template v-slot:append>
116
- <Icon name="mdiClose" size="20" />
117
- </template>
118
- </Chip>
119
- `,
120
- }),
121
- args: {},
122
- };
@@ -1,125 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue';
3
- import Icon from '../Icon/RIcon.vue';
4
- import './chip.css';
5
-
6
- export interface Props {
7
- /**
8
- * Variant of the Chip
9
- * @type 'primary' | 'secondary' | 'success' | 'error' | 'warning' | 'info'
10
- * @default 'primary'
11
- * @example
12
- * <Chip variant="primary" />
13
- */
14
- variant: 'primary' | 'secondary' | 'success' | 'error' | 'warning' | 'info';
15
-
16
- /**
17
- * Label of the Chip
18
- * @type string | number
19
- * @default 'label'
20
- * @example
21
- * <Chip label="Label" />
22
- */
23
- label?: string | number;
24
-
25
- /**
26
- * Disabled state of the Chip
27
- * @type boolean
28
- * @default false
29
- * @example
30
- * <Chip disabled />
31
- */
32
- disabled?: boolean;
33
-
34
- /**
35
- * Prepend icon of the Chip
36
- * @type string
37
- * @default ''
38
- * @example
39
- * <Chip prependIcon="icon" />
40
- */
41
- prependIcon?: string;
42
-
43
- /**
44
- * Append icon of the Chip
45
- * @type string
46
- * @default ''
47
- * @example
48
- * <Chip appendIcon="icon" />
49
- */
50
- appendIcon?: string;
51
-
52
- /**
53
- * Ghost state of the Chip
54
- * @type boolean
55
- * @default false
56
- * @example
57
- * <Chip ghost />
58
- */
59
- ghost?: boolean;
60
-
61
- /**
62
- * Closable state of the Chip
63
- * @type boolean
64
- * @default false
65
- * @example
66
- * <Chip closable />
67
- */
68
- closable?: boolean;
69
- }
70
- const props = withDefaults(defineProps<Props>(), {
71
- variant: 'primary',
72
- label: 'label',
73
- disabled: false,
74
- prependIcon: '',
75
- appendIcon: '',
76
- ghost: false,
77
- closable: false,
78
- });
79
- const emit = defineEmits(['click:chip', 'click:close']);
80
- const classes = computed<object>(() => {
81
- return {
82
- chip: true,
83
- 'chip--disabled': props.disabled,
84
- [`chip__${props.variant}`]: props.variant,
85
- [`chip__${props.variant}--ghost`]: props.ghost,
86
- };
87
- });
88
-
89
- const clickChip = (e: MouseEvent) => {
90
- if (props.closable) e.stopPropagation();
91
- if (props.disabled) return;
92
- emit('click:chip', e);
93
- };
94
- const clickClose = (e: MouseEvent) => {
95
- if (props.disabled || !props.closable) return;
96
- e.stopPropagation();
97
- emit('click:close', e);
98
- };
99
- </script>
100
- <template>
101
- <div :class="classes">
102
- <div class="chip__content" @click="clickChip($event)">
103
- <slot name="prepend">
104
- <Icon
105
- v-if="props.prependIcon"
106
- class="chip__content__prepend-icon"
107
- :aria-disabled="props.disabled"
108
- :name="props.prependIcon"
109
- :size="12"
110
- />
111
- </slot>
112
- <span class="chip__content__label">{{ props.label }}</span>
113
- </div>
114
- <slot name="append">
115
- <Icon
116
- v-if="props.appendIcon"
117
- class="chip__content__append-icon"
118
- :aria-disabled="props.disabled"
119
- :name="props.appendIcon"
120
- :size="12"
121
- @click="clickClose($event)"
122
- />
123
- </slot>
124
- </div>
125
- </template>
@@ -1,62 +0,0 @@
1
- @import '../../index.css';
2
-
3
- .chip {
4
- @apply cursor-pointer text-white inline-flex items-center px-2 py-1 text-xs font-medium leading-4 rounded-full;
5
-
6
- &__primary {
7
- @apply bg-[var(--primary-500)];
8
-
9
- &--ghost {
10
- @apply bg-[var(--primary-100)] text-[var(--primary-500)];
11
- }
12
- }
13
- &__secondary {
14
- @apply bg-[var(--secondary-500)];
15
-
16
- &--ghost {
17
- @apply bg-[var(--secondary-100)] text-[var(--secondary-500)];
18
- }
19
- }
20
- &__success {
21
- @apply bg-[var(--success-500)];
22
-
23
- &--ghost {
24
- @apply bg-[var(--success-100)] text-[var(--success-500)];
25
- }
26
- }
27
- &__error {
28
- @apply bg-[var(--error-500)];
29
-
30
- &--ghost {
31
- @apply bg-[var(--error-100)] text-[var(--error-500)];
32
- }
33
- }
34
- &__warning {
35
- @apply bg-[var(--warning-500)];
36
-
37
- &--ghost {
38
- @apply bg-[var(--warning-100)] text-[var(--warning-500)];
39
- }
40
- }
41
- &__info {
42
- @apply bg-[var(--info-500)];
43
-
44
- &--ghost {
45
- @apply bg-[var(--info-100)] text-[var(--info-500)];
46
- }
47
- }
48
- &--reverse {
49
- @apply flex-row-reverse;
50
- }
51
- &--disabled {
52
- @apply opacity-50 cursor-not-allowed;
53
- }
54
-
55
- &__content {
56
- @apply whitespace-nowrap flex items-center;
57
-
58
- &__label {
59
- @apply mx-1;
60
- }
61
- }
62
- }
@@ -1,40 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
-
3
- import { mount } from '@vue/test-utils';
4
-
5
- import Chip from './RChip.vue';
6
-
7
- describe('Chip', () => {
8
- it('renders properly', () => {
9
- const wrapper = mount(Chip, {
10
- props: {
11
- variant: 'primary',
12
- label: 'Hello',
13
- size: 'small',
14
- appendIcon: 'close',
15
- },
16
- });
17
- expect(wrapper.exists()).toBe(true);
18
- expect(wrapper.classes()).toContain('chip');
19
- expect(wrapper.classes()).toContain('chip__primary');
20
- expect(wrapper.classes()).toContain('chip--small');
21
- // expect(wrapper.find('.chip__text').text()).toBe('Hello');
22
- // expect(
23
- // wrapper
24
- // .find('.chip__text')
25
- // .trigger('click')
26
- // .then(() => {
27
- // expect(wrapper.emitted('clickChip')).toBeTruthy();
28
- // })
29
- // );
30
- expect(wrapper.find('.chip__append-icon').exists()).toBe(true);
31
- expect(
32
- wrapper
33
- .find('.chip__append-icon')
34
- .trigger('click')
35
- .then(() => {
36
- expect(wrapper.emitted('clickIcon')).toBeTruthy();
37
- })
38
- );
39
- });
40
- });