@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,138 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed, type CSSProperties } from 'vue';
3
- import '../../index.css';
4
- export interface IProps extends CSSProperties {
5
- /**
6
- * Shorthand prop for `gridTemplateColumns`
7
- * @type CSSProperties["gridTemplateColumns"]
8
- * @default 'none'
9
- * @example
10
- * <Grid templateColumns="repeat(12, 1fr)" />
11
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
12
- */
13
- templateColumns?: CSSProperties['gridTemplateColumns'];
14
-
15
- /**
16
- * Shorthand prop for `gridGap`
17
- * @type CSSProperties["gridGap"]
18
- * @default '0'
19
- * @example
20
- * <Grid gap="0" />
21
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/gap
22
- */
23
- gap?: CSSProperties['gap'];
24
-
25
- /**
26
- * Shorthand prop for `rowGap`
27
- * @type CSSProperties["rowGap"]
28
- * @default '1rem'
29
- * @example
30
- * <Grid rowGap="1rem" />
31
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap
32
- */
33
- rowGap?: CSSProperties['rowGap'];
34
-
35
- /**
36
- * Shorthand prop for `columnGap`
37
- * @type CSSProperties["columnGap"]
38
- * @default '1rem'
39
- * @example
40
- * <Grid columnGap="1rem" />
41
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap
42
- */
43
- columnGap?: CSSProperties['columnGap'];
44
-
45
- /**
46
- * Shorthand prop for `gridAutoFlow`
47
- * @type CSSProperties["gridAutoFlow"]
48
- * @default 'row'
49
- * @example
50
- * <Grid autoFlow="row" />
51
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow
52
- */
53
- autoFlow?: CSSProperties['gridAutoFlow'];
54
-
55
- /**
56
- * Shorthand prop for `gridAutoRows`
57
- * @type CSSProperties["gridAutoRows"]
58
- * @default 'auto'
59
- * @example
60
- * <Grid autoRows="auto" />
61
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows
62
- */
63
- autoRows?: CSSProperties['gridAutoRows'];
64
-
65
- /**
66
- * Shorthand prop for `gridAutoColumns`
67
- * @type CSSProperties["gridAutoColumns"]
68
- * @default 'auto'
69
- * @example
70
- * <Grid autoColumns="auto" />
71
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns
72
- */
73
- autoColumns?: CSSProperties['gridAutoColumns'];
74
-
75
- /**
76
- * Shorthand prop for `gridTemplateRows`
77
- * @type CSSProperties["gridTemplateRows"]
78
- * @default 'repeat(12, 1fr)'
79
- * @example
80
- * <Grid templateRows="repeat(12, 1fr)" />
81
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows
82
- */
83
- templateRows?: CSSProperties['gridTemplateRows'];
84
-
85
- /**
86
- * Shorthand prop for `gridTemplateAreas`
87
- * @type CSSProperties["gridTemplateAreas"]
88
- * @default 'repeat(12, 1fr)'
89
- * @example
90
- * <Grid templateAreas="repeat(12, 1fr)" />
91
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas
92
- */
93
- templateAreas?: CSSProperties['gridTemplateAreas'];
94
-
95
- /**
96
- * Shorthand prop for `gridColumn`
97
- * @type CSSProperties["gridColumn"]
98
- * @example
99
- * <Grid column="1 / 3" />
100
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column
101
- */
102
- column?: CSSProperties['gridColumn'];
103
-
104
- /**
105
- * Shorthand prop for `gridRow`
106
- * @type CSSProperties["gridRow"]
107
- * @example
108
- * <Grid row="1 / 3" />
109
- * @link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row
110
- */
111
- row?: CSSProperties['gridRow'];
112
- }
113
- const props = defineProps<IProps>();
114
-
115
- const gridStyle = computed(() => ({
116
- gridTemplateColumns: props.templateColumns,
117
- gridGap: props.gap,
118
- rowGap: props.rowGap,
119
- columnGap: props.columnGap,
120
- gridAutoFlow: props.autoFlow,
121
- gridAutoRows: props.autoRows,
122
- gridAutoColumns: props.autoColumns,
123
- gridTemplateRows: props.templateRows,
124
- gridTemplateAreas: props.templateAreas,
125
- gridColumn: props.column,
126
- gridRow: props.row,
127
- }));
128
- </script>
129
- <template>
130
- <div class="grid" :style="gridStyle">
131
- <slot />
132
- </div>
133
- </template>
134
- <style scoped>
135
- .grid {
136
- display: grid;
137
- }
138
- </style>
@@ -1,68 +0,0 @@
1
- import { Canvas, Meta, Story, Controls } from '@storybook/blocks';
2
- import * as IconStories from './Icon.stories';
3
-
4
- <Meta of={IconStories} />
5
-
6
- # Icon
7
-
8
- The Icon component is used to display a graphical icon in your application.
9
-
10
- - [Overview](#overview)
11
-
12
- - [Playground](#playground)
13
-
14
- - [Usage with props](#usage)
15
-
16
- - [Tips](#tips)
17
-
18
- ## Overview <a id="overview" />
19
-
20
- The Icon component is a graphical element that is used to visually represent an idea, concept, or action. It is typically used in conjunction with text or other graphical elements to provide a clear and concise way of conveying information to the user. It is highly customizable, allowing the developer to control the size, color, and style of the icon to match the design of the application.
21
-
22
- The Icon component is a versatile and useful tool for adding visual emphasis and clarity to an application's user interface. It is important to use icons consistently and thoughtfully in order to create a cohesive and intuitive user experience.
23
-
24
- To access a comprehensive list of icons available in our design system, please refer to the icon list page by clicking [the following link](https://pictogrammers.com/library/mdi/).
25
-
26
- <Canvas>
27
- <Story of={IconStories.Overview} />
28
- </Canvas>
29
-
30
- ### Playground <a id="playground" />
31
-
32
- > Changes you make in the controls will be reflected in the example above.
33
-
34
- <Controls of={IconStories.Overview} />
35
-
36
- ## Usage with props <a id="usage" />
37
-
38
- ### name (required)
39
-
40
- The **name** prop is a string that specifies the name of the icon you want to display. The list of available icons and their names can be found in the design system's icon library.
41
-
42
- ### size (optional)
43
-
44
- The **size** prop is a number that specifies the size of the icon.
45
-
46
- ### viewBox (optional)
47
-
48
- The **viewBox** prop is a string that specifies the viewBox of the icon.
49
-
50
- ### flip (optional)
51
-
52
- The **flip** prop is a string that specifies the flip of the icon.
53
-
54
- ### rotate (optional)
55
-
56
- The **rotate** prop is a number that specifies the rotation of the icon.
57
-
58
- ### Tips <a id="tips" />
59
-
60
- 💡 Choose a set of icons that are visually consistent and easy to understand. This will help create a cohesive look and feel for your application.
61
-
62
- 💡 Icons should be used to supplement text, not replace it. Text is still the most effective way to convey information, so make sure to use icons in conjunction with clear, concise text labels.
63
-
64
- 💡 Make sure to choose an icon that accurately represents the action or concept it is being used to represent. Using the wrong icon can lead to confusion for the user.
65
-
66
- 💡 Choose colors and sizes for your icons that are consistent with the overall design of your application. Large, bright icons may be attention-grabbing, but they can also be overwhelming if used too frequently.
67
-
68
- 💡 Make sure to consider accessibility when using icons. Use appropriate alt text for your icons, and consider providing additional information for users who may be unable to see the icons.
@@ -1,33 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/vue3';
2
- import { action } from '@storybook/addon-actions';
3
-
4
- import Icon from './RIcon.vue';
5
-
6
- const DefaultArgs = {};
7
-
8
- const DefaultArgTypes = {};
9
-
10
- // More on how to set up stories at: https://storybook.js.org/docs/vue/writing-stories/introduction
11
- const IconStory = {
12
- title: 'Components/Icon',
13
- component: Icon,
14
- setup: (args: typeof Icon) => ({
15
- args,
16
- onClick: action('click'),
17
- }),
18
- template: `<Icon v-bind="args" @click="onClick"/>`,
19
- // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/autodocs
20
- tags: [],
21
- args: DefaultArgs,
22
- argTypes: DefaultArgTypes,
23
- } as Meta<typeof Icon>;
24
-
25
- export default IconStory;
26
-
27
- type Story = StoryObj<typeof IconStory>;
28
-
29
- export const Overview: Story = {
30
- args: {
31
- name: 'mdiFaceMan',
32
- },
33
- };
@@ -1,56 +0,0 @@
1
- <script setup lang="ts">
2
- import type { SVGAttributes } from 'vue';
3
- // @ts-ignore
4
- import icons from '@/assets/icons/mdi.js';
5
-
6
- export interface IProps {
7
- /**
8
- * Name of the icon
9
- * @type SVGAttributes['name']
10
- * @default ''
11
- * @example
12
- * <Icon name="icon" />
13
- */
14
- name: SVGAttributes['name'];
15
-
16
- /**
17
- * Size of the icon
18
- * @type SVGAttributes['width'] | SVGAttributes['height']
19
- * @default 24
20
- * @example
21
- * <Icon size="24" />
22
- */
23
- size?: SVGAttributes['width'] | SVGAttributes['height'];
24
-
25
- /**
26
- * Viewbox of the icon
27
- * @type SVGAttributes['viewBox']
28
- * @default '0 0 24 24'
29
- * @example
30
- * <Icon viewBox="0 0 24 24" />
31
- */
32
- viewBox?: SVGAttributes['viewBox'];
33
- }
34
- const props = withDefaults(defineProps<IProps>(), {
35
- name: '',
36
- size: 24,
37
- viewBox: '0 0 24 24',
38
- });
39
- </script>
40
- <template>
41
- <svg
42
- class="r-icon"
43
- :width="props.size"
44
- :height="props.size"
45
- :viewBox="props.viewBox"
46
- >
47
- <path :d="icons[props.name]" />
48
- </svg>
49
- </template>
50
- <style>
51
- .r-icon {
52
- path {
53
- fill: currentColor;
54
- }
55
- }
56
- </style>
@@ -1,25 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
-
3
- import { mount } from '@vue/test-utils';
4
- import Icon from './RIcon.vue';
5
-
6
- describe('Icon', () => {
7
- it('renders properly', () => {
8
- const wrapper = mount(Icon, {
9
- props: {
10
- name: 'face',
11
- size: '24',
12
- color: 'rgb(255, 255, 255)',
13
- kind: 'outlined',
14
- fontWeight: 'bold',
15
- },
16
- });
17
- expect(wrapper.exists()).toBe(true);
18
- expect(wrapper.find('span').exists()).toBe(true);
19
- expect(wrapper.find('span').classes().includes('material-icons-outlined'));
20
- expect(wrapper.find('span').text()).toBe('face');
21
- expect(wrapper.find('span').attributes('style')).toContain(
22
- 'font-size: 24px; font-weight: bold; color: rgb(255, 255, 255);'
23
- );
24
- });
25
- });
@@ -1,91 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/vue3';
2
-
3
- import ItemGroup from './RItemGroup.vue';
4
- import Item from './RItem.vue';
5
-
6
- const ItemGroupStory = {
7
- title: 'Selections/ItemGroup',
8
- component: ItemGroup,
9
- setup(args: typeof ItemGroup) {
10
- return { args };
11
- },
12
- tags: ['autodocs'],
13
- argTypes: {
14
- default: {
15
- description: 'Slot for the items',
16
- table: {
17
- type: {
18
- summary: JSON.stringify({
19
- select: '(id: number, value: boolean) => void',
20
- isSelected: '(id: number) => boolean',
21
- selected: 'number[]',
22
- }),
23
- },
24
- },
25
- },
26
- itemProps: {
27
- table: {
28
- category: 'component',
29
- type: {
30
- summary: JSON.stringify({
31
- value: 'number',
32
- disabled: 'boolean',
33
- selectedClass: 'string',
34
- }),
35
- },
36
- },
37
- },
38
- itemSlot: {
39
- table: {
40
- category: 'component',
41
- type: {
42
- summary: JSON.stringify({
43
- isSelected: '(id: number) => boolean',
44
- value: 'number',
45
- selectedClass: 'string',
46
- disabled: 'boolean',
47
- select: '(id: number, value: boolean) => void',
48
- toggle: '(id: number) => void',
49
- }),
50
- },
51
- },
52
- },
53
- },
54
- } as Meta<typeof ItemGroup>;
55
-
56
- export default ItemGroupStory;
57
-
58
- type Story = StoryObj<typeof ItemGroupStory>;
59
-
60
- export const Overview: Story = {
61
- render: (args: any) => ({
62
- components: { ItemGroup, Item },
63
- setup() {
64
- return { args, selected: [] };
65
- },
66
- template: `
67
- <ItemGroup v-model="selected" selectedClass="bg-blue-500 text-white">
68
- <div class="flex gap-2">
69
- <Item
70
- v-for="i in 5"
71
- :key="i"
72
- :value="i"
73
- :disabled="i === 3"
74
- v-slot="{ isSelected, toggle, disabled, selectedClass }"
75
- >
76
- <div
77
- :class="[
78
- 'p-2 border border-gray-300 rounded cursor-pointer',
79
- isSelected ? selectedClass : 'bg-white',
80
- disabled ? 'opacity-50 cursor-not-allowed' : 'hover:bg-gray-100',
81
- ]"
82
- @click="toggle"
83
- >
84
- <div>{{ isSelected ? 'Selected' : 'Click Me!' }}</div>
85
- </div>
86
- </Item>
87
- </div>
88
- </ItemGroup>
89
- `,
90
- }),
91
- };
@@ -1,74 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed, inject, withDefaults } from 'vue';
3
-
4
- export interface ItemProps {
5
- /**
6
- * The value of the item
7
- * @default null
8
- * @type any
9
- * @example
10
- * <RItem :value="1" />
11
- */
12
- value: any;
13
-
14
- /**
15
- * Whether the item is disabled
16
- * @default false
17
- * @type boolean
18
- * @example
19
- * <RItem :disabled="true" />
20
- */
21
- disabled?: boolean;
22
-
23
- /**
24
- * The class to apply to the selected item
25
- * @default ''
26
- * @type string
27
- * @example
28
- * <RItem selectedClass="bg-blue-500 text-white" />
29
- */
30
- selectedClass?: string;
31
- }
32
-
33
- const RItemGroupSymbol = 'rocket-ui:r-item-group';
34
-
35
- const props = withDefaults(defineProps<ItemProps>(), {
36
- disabled: false,
37
- selectedClass: '',
38
- value: null,
39
- });
40
-
41
- const isSelected = inject(`${RItemGroupSymbol}:isSelected`) as (
42
- id: number
43
- ) => boolean;
44
-
45
- const classes = inject(`${RItemGroupSymbol}:selectedClass`, '') as string;
46
- const selectedClass = computed(() => {
47
- return isSelected(props.value) && [classes, props.selectedClass];
48
- });
49
-
50
- const select = inject(`${RItemGroupSymbol}:select`) as (
51
- id: number,
52
- value: boolean
53
- ) => void;
54
-
55
- const handleToggle = () => {
56
- if (props.disabled) return;
57
- select(props.value as number, !isSelected(props.value as number));
58
- };
59
-
60
- const handleSelect = () => {
61
- if (props.disabled) return;
62
- select(props.value as number, true);
63
- };
64
- </script>
65
- <template>
66
- <slot
67
- :isSelected="isSelected(props.value as number)"
68
- :value="props.value"
69
- :selectedClass="selectedClass"
70
- :disabled="props.disabled"
71
- :select="handleSelect"
72
- :toggle="handleToggle"
73
- />
74
- </template>
@@ -1,122 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref, computed, provide, withDefaults } from 'vue';
3
-
4
- export interface ItemGroupProps {
5
- /**
6
- * The value of the selected items
7
- * @default []
8
- * @model
9
- * @type number[]
10
- * @example
11
- * <RItemGroup v-model="selectedItems" />
12
- */
13
- modelValue: number[];
14
-
15
- /**
16
- * The class to apply to the selected items
17
- * @default ''
18
- * @type string
19
- * @example
20
- * <RItemGroup selectedClass="bg-blue-500 text-white" />
21
- */
22
- selectedClass?: string;
23
-
24
- /**
25
- * Whether the item group is disabled
26
- * @default false
27
- * @type boolean
28
- * @example
29
- * <RItemGroup :disabled="true" />
30
- */
31
- disabled?: boolean;
32
-
33
- /**
34
- * Whether the item group is mandatory
35
- * @default false
36
- * @type boolean
37
- * @example
38
- * ```js
39
- * const selected = ref<number[]>([1]);
40
- * ```
41
- * ```html
42
- * <RItemGroup :mandatory="true" v-model="selected" />
43
- * ```
44
- */
45
- mandatory?: boolean;
46
-
47
- /**
48
- * The maximum number of items that can be selected
49
- * @default 0
50
- * @type number
51
- * @example
52
- * <RItemGroup :max="5" />
53
- */
54
- max?: number;
55
-
56
- /**
57
- * The tag to use for the item group
58
- * @default div
59
- * @type string
60
- * @example
61
- * <RItemGroup as="ul" />
62
- */
63
- as?: string;
64
-
65
- /**
66
- * Whether the item group allows multiple selections
67
- * @default false
68
- * @type boolean
69
- * @example
70
- * <RItemGroup :multiple="true" />
71
- */
72
- multiple?: boolean;
73
- }
74
-
75
- const RItemGroupSymbol = 'rocket-ui:r-item-group';
76
-
77
- const props = withDefaults(defineProps<ItemGroupProps>(), {
78
- disabled: false,
79
- mandatory: false,
80
- max: 0,
81
- as: 'div',
82
- selectedClass: '',
83
- modelValue: () => [] as number[],
84
- });
85
-
86
- const emits = defineEmits(['update:modelValue']);
87
-
88
- const tag = ref<string>(props.as ?? 'div');
89
-
90
- const selectedItems = ref<number[]>(props.modelValue ?? []);
91
-
92
- const selectedClass = computed(() => props.selectedClass);
93
- provide(`${RItemGroupSymbol}:selectedClass`, selectedClass.value);
94
-
95
- const isSelected = (id: number) => {
96
- return selectedItems.value.includes(id);
97
- };
98
- provide(`${RItemGroupSymbol}:isSelected`, isSelected);
99
-
100
- const select = (id: number, value: boolean) => {
101
- if (props.disabled) return;
102
- if (props.mandatory && selectedItems.value.length === 1 && value) return;
103
- if (props.max && selectedItems.value.length === props.max && value) return;
104
- if (props.multiple) {
105
- if (value) {
106
- selectedItems.value.push(id);
107
- } else {
108
- selectedItems.value = selectedItems.value.filter((item) => item !== id);
109
- }
110
- } else {
111
- selectedItems.value = value ? [id] : [];
112
- }
113
-
114
- emits('update:modelValue', selectedItems.value);
115
- };
116
- provide(`${RItemGroupSymbol}:select`, select);
117
- </script>
118
- <template>
119
- <component :is="tag">
120
- <slot :select="select" :isSelected="isSelected" :selected="selectedItems" />
121
- </component>
122
- </template>
@@ -1,13 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`ItemGroup > should render correctly 1`] = `
4
- "<div>
5
- <div>Item</div>
6
- </div>"
7
- `;
8
-
9
- exports[`RItemGroup > should render correctly 1`] = `
10
- "<div>
11
- <div>Item</div>
12
- </div>"
13
- `;
@@ -1,67 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import { mount } from '@vue/test-utils';
4
-
5
- import { h } from 'vue';
6
-
7
- import RItemGroup from './RItemGroup.vue';
8
- import RItem from './RItem.vue';
9
-
10
- const defaultSlot = () => [
11
- h(
12
- RItem,
13
- { value: 'foo' },
14
- {
15
- default: ({ toggle }: any) =>
16
- h('div', { id: 'item', onClick: toggle }, ['foo']),
17
- }
18
- ),
19
- h(
20
- RItem,
21
- { value: 'bar' },
22
- {
23
- default: ({ toggle }: any) =>
24
- h('div', { id: 'item', onClick: toggle }, ['bar']),
25
- }
26
- ),
27
- ];
28
-
29
- describe('RItemGroup', () => {
30
- it('should render correctly', async () => {
31
- const wrapper = mount(RItemGroup, {
32
- slots: {
33
- default: defaultSlot,
34
- },
35
- });
36
-
37
- const items = wrapper.findAll('#item');
38
-
39
- await items[0].trigger('click');
40
- await items[1].trigger('click');
41
-
42
- const events = wrapper.emitted('update:modelValue');
43
-
44
- expect(events).toHaveLength(2);
45
- expect(events).toEqual([[['foo']], [['bar']]]);
46
- });
47
-
48
- it('should not deselect value when using mandatory prop', async () => {
49
- const wrapper = mount(RItemGroup, {
50
- props: {
51
- mandatory: true,
52
- modelValue: 'foo',
53
- },
54
- slots: {
55
- default: defaultSlot,
56
- },
57
- });
58
-
59
- const items = wrapper.findAll('#item');
60
-
61
- await items[0].trigger('click');
62
-
63
- const events = wrapper.emitted('update:modelValue');
64
-
65
- expect(events).toHaveLength(1);
66
- });
67
- });