@teammodlr/ui-kit 1.0.6 → 2.0.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.
Files changed (254) hide show
  1. package/lib/__storybook__/argTypes.d.ts +10 -1
  2. package/lib/components/avatar/Avatar.vue.d.ts +16 -30
  3. package/lib/components/avatar/style/Avatar.css.d.ts +9 -0
  4. package/lib/components/avatar/style/index.d.ts +1 -0
  5. package/lib/components/avatargroup/AvatarGroup.vue.d.ts +28 -13
  6. package/lib/components/avatargroup/style/AvatarGroup.css.d.ts +2 -0
  7. package/lib/components/avatargroup/style/index.d.ts +1 -0
  8. package/lib/components/avatargroup/symbol.d.ts +13 -0
  9. package/lib/components/badge/Badge.vue.d.ts +30 -0
  10. package/lib/components/badge/style/Badge.css.d.ts +4 -0
  11. package/lib/components/badge/style/index.d.ts +1 -0
  12. package/lib/components/breadcrumb/Breadcrumb.vue.d.ts +12 -3
  13. package/lib/components/{breadcrumbitem → breadcrumb}/BreadcrumbItem.vue.d.ts +11 -0
  14. package/lib/components/breadcrumb/style/Breadcrumb.css.d.ts +4 -0
  15. package/lib/components/breadcrumb/style/index.d.ts +1 -0
  16. package/lib/components/breadcrumb/symbol.d.ts +13 -0
  17. package/lib/components/button/Button.vue.d.ts +39 -28
  18. package/lib/components/button/style/Button.css.d.ts +24 -0
  19. package/lib/components/button/style/index.d.ts +1 -0
  20. package/lib/components/buttongroup/ButtonGroup.vue.d.ts +2 -13
  21. package/lib/components/buttongroup/style/ButtonGroup.css.d.ts +2 -0
  22. package/lib/components/buttongroup/style/index.d.ts +1 -0
  23. package/lib/components/buttongroup/symbol.d.ts +6 -0
  24. package/lib/components/checkbox/Checkbox.vue.d.ts +17 -20
  25. package/lib/components/checkbox/style/Checkbox.css.d.ts +16 -0
  26. package/lib/components/checkbox/style/index.d.ts +1 -0
  27. package/lib/components/colorpicker/ColorPicker.vue.d.ts +75 -0
  28. package/lib/components/colorpicker/style/ColorPicker.css.d.ts +9 -0
  29. package/lib/components/colorpicker/style/index.d.ts +1 -0
  30. package/lib/components/colorpicker/utils.d.ts +16 -0
  31. package/lib/components/dropdown/Dropdown.vue.d.ts +5 -4
  32. package/lib/components/dropdown/DropdownItem.vue.d.ts +12 -5
  33. package/lib/components/dropdown/DropdownList.vue.d.ts +4 -1
  34. package/lib/components/dropdown/style/Dropdown.css.d.ts +5 -0
  35. package/lib/components/dropdown/style/index.d.ts +1 -0
  36. package/lib/components/dropdown/symbol.d.ts +6 -0
  37. package/lib/components/index.d.ts +10 -1
  38. package/lib/components/input/Input.vue.d.ts +35 -19
  39. package/lib/components/input/style/Input.css.d.ts +23 -0
  40. package/lib/components/input/style/index.d.ts +1 -0
  41. package/lib/components/link/Link.vue.d.ts +2 -2
  42. package/lib/components/messageprovider/Message.vue.d.ts +13 -1
  43. package/lib/components/messageprovider/MessageProvider.vue.d.ts +6 -5
  44. package/lib/components/messageprovider/style/Message.css.d.ts +12 -0
  45. package/lib/components/messageprovider/style/index.d.ts +1 -0
  46. package/lib/components/messageprovider/types.d.ts +2 -1
  47. package/lib/components/modal/Modal.vue.d.ts +52 -0
  48. package/lib/components/modal/style/Modal.css.d.ts +21 -0
  49. package/lib/components/modal/style/index.d.ts +1 -0
  50. package/lib/components/radio/Radio.vue.d.ts +85 -0
  51. package/lib/components/radio/style/Checkbox.css.d.ts +16 -0
  52. package/lib/components/radio/style/index.d.ts +1 -0
  53. package/lib/components/radiobutton/RadioButton.vue.d.ts +98 -0
  54. package/lib/components/radiobutton/style/RadioButton.css.d.ts +14 -0
  55. package/lib/components/radiobutton/style/index.d.ts +1 -0
  56. package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +48 -0
  57. package/lib/components/radiobuttongroup/style/RadioButtonGroup.css.d.ts +3 -0
  58. package/lib/components/radiobuttongroup/style/index.d.ts +1 -0
  59. package/lib/components/radiobuttongroup/symbol.d.ts +9 -0
  60. package/lib/components/select/Select.vue.d.ts +22 -13
  61. package/lib/components/select/style/Select.css.d.ts +30 -0
  62. package/lib/components/select/style/index.d.ts +1 -0
  63. package/lib/components/skeleton/Skeleton.vue.d.ts +15 -21
  64. package/lib/components/skeleton/style/Skeleton.css.d.ts +8 -0
  65. package/lib/components/skeleton/style/index.d.ts +2 -0
  66. package/lib/components/slider/Slider.vue.d.ts +32 -0
  67. package/lib/components/slider/style/Slider.css.d.ts +4 -0
  68. package/lib/components/slider/style/index.d.ts +1 -0
  69. package/lib/components/tab/TabGroup.vue.d.ts +1 -1
  70. package/lib/components/table/Table.vue.d.ts +1 -1
  71. package/lib/components/tag/Tag.vue.d.ts +44 -0
  72. package/lib/components/tag/style/Tag.css.d.ts +11 -0
  73. package/lib/components/tag/style/index.d.ts +1 -0
  74. package/lib/components/tooltip/Tooltip.vue.d.ts +17 -2
  75. package/lib/components/tooltip/style/Tooltip.css.d.ts +6 -0
  76. package/lib/components/tooltip/style/index.d.ts +1 -0
  77. package/lib/components/virtualscroll/VirtualScroll.vue.d.ts +46 -16
  78. package/lib/components/virtualscroll/style/VirtualScroll.css.d.ts +1 -0
  79. package/lib/components/virtualscroll/style/index.d.ts +1 -0
  80. package/lib/composables/useInput.d.ts +1 -1
  81. package/lib/composables/useInteractive.d.ts +15 -0
  82. package/lib/composables/useZIndex.d.ts +8 -0
  83. package/lib/index.cjs.js +8 -2
  84. package/lib/index.d.ts +0 -1
  85. package/lib/index.es.js +3688 -1692
  86. package/lib/style.css +1 -1
  87. package/lib/styles/theme.css.d.ts +147 -0
  88. package/lib/styles/typography.css.d.ts +22 -0
  89. package/lib/types/props.d.ts +1 -0
  90. package/package.json +33 -26
  91. package/src/__storybook__/argTypes.ts +19 -1
  92. package/src/components/avatar/Avatar.vue +33 -26
  93. package/src/components/avatar/examples/index.stories.ts +1 -1
  94. package/src/components/avatar/style/Avatar.css.ts +92 -0
  95. package/src/components/avatar/style/index.ts +1 -0
  96. package/src/components/avatargroup/AvatarGroup.vue +71 -32
  97. package/src/components/avatargroup/examples/basic.vue +33 -7
  98. package/src/components/avatargroup/examples/index.stories.ts +4 -8
  99. package/src/components/avatargroup/style/AvatarGroup.css.ts +21 -0
  100. package/src/components/avatargroup/style/index.ts +1 -0
  101. package/src/components/avatargroup/symbol.ts +17 -0
  102. package/src/components/badge/Badge.css +128 -0
  103. package/src/components/badge/Badge.vue +43 -0
  104. package/src/components/badge/examples/basic.vue +10 -0
  105. package/src/components/badge/examples/index.stories.ts +21 -0
  106. package/src/components/badge/examples/index.ts +1 -0
  107. package/src/components/badge/style/Badge.css.ts +124 -0
  108. package/src/components/badge/style/index.ts +1 -0
  109. package/src/components/breadcrumb/Breadcrumb.vue +22 -15
  110. package/src/components/breadcrumb/BreadcrumbItem.vue +73 -0
  111. package/src/components/breadcrumb/examples/basic.vue +5 -7
  112. package/src/components/breadcrumb/examples/index.stories.ts +2 -2
  113. package/src/components/breadcrumb/style/Breadcrumb.css.ts +40 -0
  114. package/src/components/breadcrumb/style/index.ts +1 -0
  115. package/src/components/breadcrumb/symbol.ts +17 -0
  116. package/src/components/button/Button.vue +194 -107
  117. package/src/components/button/examples/icon-left.vue +12 -0
  118. package/src/components/button/examples/icon.vue +6 -7
  119. package/src/components/button/examples/index.stories.ts +9 -7
  120. package/src/components/button/examples/index.ts +3 -2
  121. package/src/components/button/examples/variants-secondary.vue +8 -0
  122. package/src/components/button/examples/variants.vue +8 -0
  123. package/src/components/button/style/Button.css.ts +585 -0
  124. package/src/components/button/style/index.ts +1 -0
  125. package/src/components/buttongroup/ButtonGroup.vue +36 -47
  126. package/src/components/buttongroup/examples/basic.vue +2 -2
  127. package/src/components/buttongroup/examples/icon-group.vue +22 -0
  128. package/src/components/buttongroup/examples/index.stories.ts +4 -2
  129. package/src/components/buttongroup/examples/index.ts +1 -0
  130. package/src/components/buttongroup/style/ButtonGroup.css.ts +40 -0
  131. package/src/components/buttongroup/style/index.ts +1 -0
  132. package/src/components/buttongroup/symbol.ts +8 -0
  133. package/src/components/checkbox/Checkbox.vue +70 -54
  134. package/src/components/checkbox/examples/index.stories.ts +1 -1
  135. package/src/components/checkbox/style/Checkbox.css.ts +127 -0
  136. package/src/components/checkbox/style/index.ts +1 -0
  137. package/src/components/colorpicker/ColorPicker.vue +283 -0
  138. package/src/components/colorpicker/examples/basic.vue +3 -0
  139. package/src/components/colorpicker/examples/index.stories.ts +17 -0
  140. package/src/components/colorpicker/examples/index.ts +1 -0
  141. package/src/components/colorpicker/style/ColorPicker.css.ts +97 -0
  142. package/src/components/colorpicker/style/index.ts +1 -0
  143. package/src/components/colorpicker/utils.ts +188 -0
  144. package/src/components/dropdown/Dropdown.vue +45 -24
  145. package/src/components/dropdown/DropdownItem.vue +121 -118
  146. package/src/components/dropdown/DropdownList.vue +3 -3
  147. package/src/components/dropdown/DropdownWrapper.vue +2 -1
  148. package/src/components/dropdown/examples/custom.vue +13 -0
  149. package/src/components/dropdown/examples/index.stories.ts +4 -2
  150. package/src/components/dropdown/examples/index.ts +1 -0
  151. package/src/components/dropdown/style/Dropdown.css.ts +48 -0
  152. package/src/components/dropdown/style/index.ts +1 -0
  153. package/src/components/dropdown/symbol.ts +8 -0
  154. package/src/components/form/examples/basic.vue +4 -2
  155. package/src/components/form/examples/index.stories.ts +4 -2
  156. package/src/components/image/examples/index.stories.ts +1 -1
  157. package/src/components/index.ts +10 -2
  158. package/src/components/input/Input.vue +84 -42
  159. package/src/components/input/examples/basic.vue +2 -1
  160. package/src/components/input/examples/index.stories.ts +1 -1
  161. package/src/components/input/examples/prefix.vue +4 -2
  162. package/src/components/input/examples/suffix.vue +4 -2
  163. package/src/components/input/style/Input.css.ts +221 -0
  164. package/src/components/input/style/index.ts +1 -0
  165. package/src/components/link/examples/index.stories.ts +1 -1
  166. package/src/components/messageprovider/Message.vue +52 -5
  167. package/src/components/messageprovider/MessageProvider.css +0 -13
  168. package/src/components/messageprovider/MessageProvider.vue +18 -16
  169. package/src/components/messageprovider/examples/basic.vue +56 -5
  170. package/src/components/messageprovider/examples/index.stories.ts +0 -1
  171. package/src/components/messageprovider/examples/index.ts +1 -0
  172. package/src/components/messageprovider/examples/update.vue +34 -0
  173. package/src/components/messageprovider/examples/wrapper.vue +1 -1
  174. package/src/components/messageprovider/style/Message.css.ts +109 -0
  175. package/src/components/messageprovider/style/index.ts +1 -0
  176. package/src/components/messageprovider/types.ts +9 -1
  177. package/src/components/modal/Modal.vue +126 -0
  178. package/src/components/modal/examples/basic.vue +40 -0
  179. package/src/components/modal/examples/index.stories.ts +20 -0
  180. package/src/components/modal/examples/index.ts +2 -0
  181. package/src/components/modal/examples/modal-form.vue +99 -0
  182. package/src/components/modal/style/Modal.css.ts +257 -0
  183. package/src/components/modal/style/index.ts +1 -0
  184. package/src/components/radio/Checkbox.css +185 -0
  185. package/src/components/radio/Radio.vue +137 -0
  186. package/src/components/radio/examples/basic.vue +9 -0
  187. package/src/components/radio/examples/index.stories.ts +19 -0
  188. package/src/components/radio/examples/index.ts +2 -0
  189. package/src/components/radio/style/Checkbox.css.ts +132 -0
  190. package/src/components/radio/style/index.ts +1 -0
  191. package/src/components/radiobutton/RadioButton.vue +131 -0
  192. package/src/components/radiobutton/style/RadioButton.css.ts +185 -0
  193. package/src/components/radiobutton/style/index.ts +1 -0
  194. package/src/components/radiobuttongroup/RadioButtonGroup.vue +75 -0
  195. package/src/components/radiobuttongroup/examples/basic.vue +17 -0
  196. package/src/components/radiobuttongroup/examples/index.stories.ts +22 -0
  197. package/src/components/radiobuttongroup/examples/index.ts +2 -0
  198. package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +37 -0
  199. package/src/components/radiobuttongroup/style/index.ts +1 -0
  200. package/src/components/radiobuttongroup/symbol.ts +11 -0
  201. package/src/components/select/Select.css +0 -226
  202. package/src/components/select/Select.vue +116 -48
  203. package/src/components/select/examples/index.stories.ts +1 -1
  204. package/src/components/select/examples/multiple.vue +1 -2
  205. package/src/components/select/style/Select.css.ts +254 -0
  206. package/src/components/select/style/index.ts +1 -0
  207. package/src/components/skeleton/Skeleton.vue +55 -47
  208. package/src/components/skeleton/examples/index.stories.ts +1 -8
  209. package/src/components/skeleton/style/Skeleton.css.ts +57 -0
  210. package/src/components/skeleton/style/index.ts +2 -0
  211. package/src/components/slider/Slider.vue +76 -0
  212. package/src/components/slider/style/Slider.css.ts +43 -0
  213. package/src/components/slider/style/index.ts +1 -0
  214. package/src/components/tab/examples/index.stories.ts +1 -1
  215. package/src/components/table/examples/index.stories.ts +1 -1
  216. package/src/components/tag/Tag.css +0 -0
  217. package/src/components/tag/Tag.vue +66 -0
  218. package/src/components/tag/examples/basic.vue +5 -0
  219. package/src/components/tag/examples/index.stories.ts +22 -0
  220. package/src/components/tag/examples/index.ts +1 -0
  221. package/src/components/tag/style/Tag.css.ts +79 -0
  222. package/src/components/tag/style/index.ts +1 -0
  223. package/src/components/tooltip/Tooltip.css +0 -6
  224. package/src/components/tooltip/Tooltip.vue +53 -22
  225. package/src/components/tooltip/examples/basic.vue +2 -5
  226. package/src/components/tooltip/examples/index.stories.ts +1 -1
  227. package/src/components/tooltip/style/Tooltip.css.ts +48 -0
  228. package/src/components/tooltip/style/index.ts +1 -0
  229. package/src/components/virtualscroll/VirtualScroll.vue +159 -53
  230. package/src/components/virtualscroll/examples/basic.vue +21 -27
  231. package/src/components/virtualscroll/examples/index.stories.ts +2 -18
  232. package/src/components/virtualscroll/style/VirtualScroll.css.ts +18 -0
  233. package/src/components/virtualscroll/style/index.ts +1 -0
  234. package/src/composables/useInput.ts +2 -2
  235. package/src/composables/useInteractive.ts +20 -0
  236. package/src/composables/usePopper.ts +1 -1
  237. package/src/composables/useZIndex.ts +31 -0
  238. package/src/css/components.css +4 -3
  239. package/src/css/normalize.css +0 -379
  240. package/src/css/variables.css +2 -2
  241. package/src/examples/cards/cards.stories.ts +9 -0
  242. package/src/examples/cards/sidebar.vue +263 -0
  243. package/src/index.ts +1 -1
  244. package/src/styles/theme.css.ts +149 -0
  245. package/src/styles/typography.css.ts +91 -0
  246. package/src/types/props.ts +2 -0
  247. package/lib/components/breadcrumbitem/index.d.ts +0 -1
  248. package/src/components/avatar/Avatar.css +0 -69
  249. package/src/components/breadcrumbitem/BreadcrumbItem.vue +0 -66
  250. package/src/components/breadcrumbitem/index.ts +0 -1
  251. package/src/components/button/examples/colors-secondary.vue +0 -8
  252. package/src/components/button/examples/colors.vue +0 -8
  253. package/src/components/dropdown/Dropdown.css +0 -68
  254. /package/src/components/button/{Button.css → Button-old.css} +0 -0
@@ -3,30 +3,37 @@
3
3
  <slot />
4
4
  </ol>
5
5
  </template>
6
-
7
- <script lang="ts">
8
- import {
9
- defineComponent, reactive, computed, provide, toRef
10
- } from "vue";
11
6
 
12
- interface BreadcrumbState {
13
- separator: string,
14
- refreshItems: () => void
15
- }
7
+ <script lang="ts">
8
+ import type {PropType} from "vue";
9
+ import {computed, defineComponent, provide, reactive, toRef} from "vue";
10
+ import type {BreadcrumbItemState, BreadcrumbOptions, BreadcrumbState} from "./symbol";
11
+ import {BREADCRUMB_STATE} from "./symbol";
12
+ import * as style from "./style";
16
13
 
17
14
  export default defineComponent({
18
15
  name: "Breadcrumb",
19
16
  components: {
20
- BreadcrumbItem: () => import("../breadcrumbitem/BreadcrumbItem.vue")
17
+ BreadcrumbItem: () => import('./BreadcrumbItem.vue')
21
18
  },
22
19
  props: {
23
20
  seperator: {
24
21
  type: String,
25
22
  default: "/"
23
+ },
24
+ options: {
25
+ type: Array as PropType<BreadcrumbOptions[]>,
26
26
  }
27
27
  },
28
28
  setup(props) {
29
- const refreshItems = () => { };
29
+ const itemStates = new Set<BreadcrumbItemState>();
30
+ const refreshItems = () => {
31
+ Array.from(itemStates).forEach((item, index) => {
32
+ if (!item.label) {
33
+ item.label = index + 1;
34
+ }
35
+ });
36
+ };
30
37
 
31
38
  const state: BreadcrumbState = reactive({
32
39
  separator: toRef(props, 'seperator'),
@@ -34,12 +41,12 @@ export default defineComponent({
34
41
  });
35
42
 
36
43
  const classes = computed(() => {
37
- return {
38
- 'm-breadcrumbs': true
39
- }
44
+ return [
45
+ style.base
46
+ ]
40
47
  });
41
48
 
42
- provide('breadcrumb', state);
49
+ provide(BREADCRUMB_STATE, state);
43
50
 
44
51
  return {
45
52
  props,
@@ -0,0 +1,73 @@
1
+ <template>
2
+ <li :class="style.item">
3
+ <a tabindex="0" @click="handleClick" :class="style.link">
4
+ <slot>{{ label }}</slot>
5
+ </a>
6
+ <span :class="style.separator" role="separator">
7
+ {{ separator }}
8
+ </span>
9
+ </li>
10
+ </template>
11
+
12
+ <script lang="ts">
13
+ import {defineComponent, inject, onBeforeUnmount, ref, watch} from "vue";
14
+
15
+ import {BREADCRUMB_STATE} from "./symbol";
16
+ import * as style from "./style";
17
+
18
+ export default defineComponent({
19
+ name: 'BreadcrumbItem',
20
+ props: {
21
+ label: {
22
+ type: [String, Number],
23
+ default: null
24
+ },
25
+ onClick: {
26
+ type: Function,
27
+ default: () => {
28
+ }
29
+ }
30
+ },
31
+ setup(props) {
32
+ const breadcrumbState = inject(BREADCRUMB_STATE);
33
+
34
+ const label = ref(props.label);
35
+ const separator = ref("/");
36
+
37
+ watch(
38
+ () => props.label,
39
+ value => {
40
+ label.value = value;
41
+ breadcrumbState?.refreshItems()
42
+ }
43
+ )
44
+
45
+ if (breadcrumbState) {
46
+ // const state: BreadcrumbItemState = reactive({
47
+ // label: label
48
+ // })
49
+
50
+ watch(() => breadcrumbState?.separator, (value) => {
51
+ separator.value = value
52
+ },
53
+ {immediate: true}
54
+ );
55
+
56
+ onBeforeUnmount(() => {
57
+ });
58
+ }
59
+
60
+ const handleClick = () => {
61
+ props.onClick();
62
+ };
63
+
64
+ return {
65
+ label,
66
+ separator,
67
+ style,
68
+ handleClick
69
+ }
70
+ }
71
+ })
72
+ </script>
73
+
@@ -1,9 +1,7 @@
1
1
  <template>
2
- <div>
3
- <MBreadcrumb>
4
- <MBreadcrumbItem>Home</MBreadcrumbItem>
5
- <MBreadcrumbItem>Category One</MBreadcrumbItem>
6
- <MBreadcrumbItem>Category Two</MBreadcrumbItem>
7
- </MBreadcrumb>
8
- </div>
2
+ <MBreadcrumb>
3
+ <MBreadcrumbItem>Home</MBreadcrumbItem>
4
+ <MBreadcrumbItem>Category One</MBreadcrumbItem>
5
+ <MBreadcrumbItem>Category Two</MBreadcrumbItem>
6
+ </MBreadcrumb>
9
7
  </template>
@@ -1,5 +1,5 @@
1
1
  import MBreadcrumb from "../Breadcrumb.vue";
2
- import MBreadcrumbItem from "../../breadcrumbitem/BreadcrumbItem.vue";
2
+ import MBreadcrumbItem from "../BreadcrumbItem.vue";
3
3
 
4
4
  import {
5
5
  MBreadcrumbBasic
@@ -7,7 +7,7 @@ import {
7
7
 
8
8
  import {
9
9
  createStory
10
- } from "@/__storybook__";
10
+ } from "../../../__storybook__";
11
11
 
12
12
  export default {
13
13
  component: MBreadcrumb,
@@ -0,0 +1,40 @@
1
+ import {globalStyle, style} from "@vanilla-extract/css";
2
+ import {themeVars} from "../../../styles/theme.css";
3
+
4
+ export const base = style({
5
+ display: "flex",
6
+ position: "relative",
7
+ margin: 0,
8
+ padding: 0,
9
+ listStyle: "none",
10
+ boxSizing: "border-box",
11
+ });
12
+
13
+ export const item = style({
14
+ display: "flex",
15
+ alignItems: "center",
16
+ fontSize: themeVars.fontSize.base,
17
+ });
18
+
19
+ export const link = style({
20
+ padding: `0 ${themeVars.space[2]}`,
21
+ color: themeVars.color.gray[600],
22
+ cursor: "pointer",
23
+ textDecoration: "none",
24
+ outline: 0,
25
+ transition: `color 0.2s ${themeVars.transition.default}`,
26
+ ":hover": {
27
+ color: themeVars.color.blue[500],
28
+ }
29
+ });
30
+
31
+ export const separator = style({
32
+ padding: `0 ${themeVars.space[1]}`,
33
+ display: "inline-flex",
34
+ color: themeVars.color.gray[300],
35
+ userSelect: "none"
36
+ });
37
+
38
+ globalStyle(`${base} ${item}:last-child ${separator}`, {
39
+ display: "none"
40
+ });
@@ -0,0 +1 @@
1
+ export * from "./Breadcrumb.css";
@@ -0,0 +1,17 @@
1
+ import type {InjectionKey} from "vue";
2
+
3
+ export interface BreadcrumbOptions {
4
+ label: string;
5
+ name?: string | (() => string);
6
+ }
7
+
8
+ export interface BreadcrumbItemState {
9
+ label: string | number;
10
+ }
11
+
12
+ export interface BreadcrumbState {
13
+ separator: string;
14
+ refreshItems: () => void
15
+ }
16
+
17
+ export const BREADCRUMB_STATE: InjectionKey<BreadcrumbState> = Symbol('BREADCRUMB_STATE');
@@ -1,108 +1,195 @@
1
- <template>
2
- <component :is="computedTag" :to="to" :href="href" :type="type" :class="computedClasses" :disabled="disabled">
3
- <div v-if="hasIconLeft" class="m-button__icon">
4
- <slot name="icon-left" />
5
- </div>
6
- <span class="m-button__content">
7
- <slot />
8
- </span>
9
- <div v-if="hasIconRight" class="m-button__icon">
10
- <slot name="icon-right" />
11
- </div>
12
- </component>
13
- </template>
14
-
15
- <script lang="ts">
16
- import { computed, defineComponent, inject } from "vue";
17
- import type { PropType } from 'vue';
18
- import type { Color, Size } from "../../types/props";
19
-
20
- export default defineComponent({
21
- name: "MButton",
22
- props: {
23
- type: {
24
- type: String,
25
- default: 'button',
26
- },
27
- color: {
28
- type: String as PropType<Color>,
29
- default: ''
30
- },
31
- size: {
32
- type: String as PropType<Size>,
33
- default: 'md'
34
- },
35
- rounded: {
36
- type: Boolean,
37
- default: false
38
- },
39
- disabled: {
40
- type: Boolean,
41
- default: false
42
- },
43
- block: {
44
- type: Boolean,
45
- default: false
46
- },
47
- secondary: {
48
- type: Boolean,
49
- default: false
50
- },
51
- to: {
52
- type: [String, Object],
53
- default: ''
54
- },
55
- href: {
56
- type: String,
57
- default: '',
58
- },
59
- icon: {
60
- type: Boolean,
61
- default: false
62
- },
63
- strong: {
64
- type: Boolean,
65
- default: false
66
- }
67
- },
68
- setup(props, { slots }) {
69
- const group = inject('buttonGroup', {
70
- groupProps: {},
71
- isGroup: false
72
- });
73
-
74
- const hasIconLeft = computed(() => !!(slots['icon-left']));
75
- const hasIconRight = computed(() => !!(slots['icon-right']));
76
-
77
- const computedClasses = computed(() => {
78
- // @ts-ignore
79
- const size = group.groupProps.size || props.size;
80
- return [
81
- 'm-button',
82
- `m-button--${size}`,
83
- {
84
- [`m-button--${props.color}`]: props.color,
85
- 'm-button--rounded': props.rounded,
86
- 'm-button--block': props.block,
87
- 'm-button--icon': props.icon,
88
- 'm-button--secondary': props.secondary,
89
- 'm-button--disabled': props.disabled,
90
- 'm-button--strong': props.strong,
91
- 'm-button--icon-left': hasIconLeft.value,
92
- 'm-button--icon-right': hasIconRight.value,
93
- }
94
- ]
95
- });
96
-
97
- const computedTag = computed(() => (props.to ? 'router-link' : props.href ? 'a' : 'button'));
98
-
99
- return {
100
- computedClasses,
101
- computedTag,
102
- hasIconLeft,
103
- hasIconRight
104
- }
105
- }
106
- })
107
- </script>
1
+ <template>
2
+ <component :is="computedTag" :to="to" :href="href" :type="type" :class="computedClasses" :disabled="disabled"
3
+ @click="handleClick" v-bind="$attrs">
4
+ <!-- <div :class="computedWaveClasses" :key="waveTimerId"></div>-->
5
+ <div :class="computedBorderClasses"></div>
6
+ <div :class="computedBorderStateClasses"></div>
7
+ <span v-if="hasIconLeft" :class="iconLeft">
8
+ <slot name="icon-left"/>
9
+ </span>
10
+ <span>
11
+ <slot/>
12
+ </span>
13
+ <span v-if="hasIconRight" :class="iconRight">
14
+ <slot name="icon-right"/>
15
+ </span>
16
+ </component>
17
+ </template>
18
+
19
+ <script lang="ts">
20
+ import type {PropType} from "vue";
21
+ import {computed, defineComponent, inject, nextTick, onBeforeUnmount, onMounted, ref} from "vue";
22
+ import type {Size, Variant} from "../../types/props";
23
+ import * as style from "./style";
24
+ import {BUTTON_GROUP_STATE} from "../buttongroup/symbol";
25
+
26
+ export default defineComponent({
27
+ name: "MButton",
28
+ props: {
29
+ type: {
30
+ type: String,
31
+ default: 'button',
32
+ },
33
+ variant: {
34
+ type: String as PropType<Variant>,
35
+ default: 'default'
36
+ },
37
+ size: {
38
+ type: String as PropType<Size>,
39
+ default: 'md'
40
+ },
41
+ rounded: {
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ disabled: {
46
+ type: Boolean,
47
+ default: false
48
+ },
49
+ block: {
50
+ type: Boolean,
51
+ default: false
52
+ },
53
+ secondary: {
54
+ type: Boolean,
55
+ default: false
56
+ },
57
+ to: {
58
+ type: [String, Object],
59
+ default: null
60
+ },
61
+ href: {
62
+ type: String,
63
+ default: '',
64
+ },
65
+ link: {
66
+ type: Boolean,
67
+ default: false
68
+ },
69
+ icon: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ onClick: {
74
+ type: Function as PropType<(e: MouseEvent) => void>,
75
+ default: () => {
76
+ }
77
+ }
78
+ },
79
+ setup(props, {slots}) {
80
+ const group = inject(BUTTON_GROUP_STATE, null);
81
+ const state = inject("dropdown", null);
82
+ const sizeValue = ref<Size>('md');
83
+ const waveActive = ref<boolean>(false);
84
+ const waveTimerId = ref<number | null>(0);
85
+
86
+ const dropdownOpen = computed(() => {
87
+ // @ts-ignore
88
+ return state?.isOpen.value;
89
+ });
90
+
91
+ const groupSize = computed(() => {
92
+ return group?.size;
93
+ });
94
+
95
+ const size = computed<Size>(() => {
96
+ return groupSize.value || props.size;
97
+ })
98
+
99
+ const hasIconLeft = computed(() => !!(slots['icon-left']));
100
+ const hasIconRight = computed(() => !!(slots['icon-right']));
101
+
102
+ const computedClasses = computed(() => {
103
+ // TODO: We can use dropdownOpen (T or F) to style the open button :)
104
+ return [
105
+ style.base,
106
+ [style.size[size.value]],
107
+ style.variant[props.variant],
108
+ {
109
+ [style.rounded]: props.rounded,
110
+ [style.secondary[props.variant]]: props.secondary,
111
+ [style.block]: props.block,
112
+ [style.link[props.variant]]: props.link,
113
+ [style.iconButton]: props.icon,
114
+ }
115
+ ]
116
+ });
117
+
118
+ const computedWaveClasses = computed(() => {
119
+ return [
120
+ style.wave,
121
+ {
122
+ [style.waveActive]: waveActive.value
123
+ }
124
+ ]
125
+ });
126
+
127
+ const computedBorderClasses = computed(() => {
128
+ return [
129
+ style.border
130
+ ]
131
+ });
132
+
133
+ const computedBorderStateClasses = computed(() => {
134
+ return [
135
+ style.borderState
136
+ ]
137
+ });
138
+
139
+ const computedTag = computed(() => (props.to ? 'nuxt-link' : props.href ? 'a' : 'button'));
140
+
141
+ onMounted(() => {
142
+ sizeValue.value = groupSize.value || props.size;
143
+ });
144
+
145
+ onBeforeUnmount(() => {
146
+ if (waveTimerId.value) {
147
+ clearTimeout(waveTimerId.value);
148
+ }
149
+ });
150
+
151
+ // const playWave = () => {
152
+ // if (props.disabled || props.secondary) {
153
+ // return;
154
+ // }
155
+ // if (waveTimerId.value) {
156
+ // clearTimeout(waveTimerId.value);
157
+ // waveActive.value = false;
158
+ // waveTimerId.value = null;
159
+ // }
160
+ // nextTick(() => {
161
+ // waveActive.value = true;
162
+ // waveTimerId.value = setTimeout(() => {
163
+ // waveActive.value = false;
164
+ // waveTimerId.value = null;
165
+ // }, 800);
166
+ // })
167
+ // }
168
+
169
+ const handleClick = (e: MouseEvent): void => {
170
+ if (props.disabled) {
171
+ e.preventDefault();
172
+ return;
173
+ }
174
+ // playWave();
175
+ props.onClick(e);
176
+ };
177
+
178
+ return {
179
+ dropdownOpen,
180
+ computedClasses,
181
+ computedWaveClasses,
182
+ computedBorderClasses,
183
+ computedBorderStateClasses,
184
+ computedTag,
185
+ hasIconLeft,
186
+ hasIconRight,
187
+ handleClick,
188
+ waveTimerId,
189
+ iconLeft: style.iconLeft,
190
+ iconRight: style.iconRight,
191
+ }
192
+ }
193
+ })
194
+ </script>
108
195
 
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <MButton>
3
+ <template #icon-left>
4
+ <svg width="24" height="24" viewBox="0 0 24 24" role="presentation">
5
+ <path
6
+ d="M12.072 17.284l-3.905 2.053a1 1 0 01-1.451-1.054l.745-4.349-3.159-3.08a1 1 0 01.554-1.705l4.366-.635 1.953-3.956a1 1 0 011.794 0l1.952 3.956 4.366.635a1 1 0 01.555 1.705l-3.16 3.08.746 4.349a1 1 0 01-1.45 1.054l-3.906-2.053z"
7
+ fill="currentColor" fill-rule="evenodd"></path>
8
+ </svg>
9
+ </template>
10
+ Hello World
11
+ </MButton>
12
+ </template>
@@ -1,10 +1,9 @@
1
1
  <template>
2
- <MButton>
3
- <template #icon-left>
4
- <svg style="width: 20px; height: 20px;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
5
- <path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6h9.75M10.5 6a1.5 1.5 0 11-3 0m3 0a1.5 1.5 0 10-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-9.75 0h9.75" />
6
- </svg>
7
- </template>
8
- Hello World
2
+ <MButton icon>
3
+ <svg width="24" height="24" viewBox="0 0 24 24" role="presentation">
4
+ <path
5
+ d="M12.072 17.284l-3.905 2.053a1 1 0 01-1.451-1.054l.745-4.349-3.159-3.08a1 1 0 01.554-1.705l4.366-.635 1.953-3.956a1 1 0 011.794 0l1.952 3.956 4.366.635a1 1 0 01.555 1.705l-3.16 3.08.746 4.349a1 1 0 01-1.45 1.054l-3.906-2.053z"
6
+ fill="currentColor" fill-rule="evenodd"></path>
7
+ </svg>
9
8
  </MButton>
10
9
  </template>
@@ -3,23 +3,24 @@ import {
3
3
  MButtonBasic,
4
4
  MButtonSize,
5
5
  MButtonRounded,
6
- MButtonColor,
7
- MButtonColorSecondary,
6
+ MButtonVariant,
7
+ MButtonVariantSecondary,
8
8
  MButtonDisabled,
9
+ MButtonIconLeft,
9
10
  MButtonIcon
10
11
  } from "./index";
11
12
 
12
13
  import {
13
- colorArgType,
14
+ variantArgType,
14
15
  createStory,
15
16
  sizeArgType
16
- } from "@/__storybook__";
17
+ } from "../../../__storybook__";
17
18
 
18
19
  export default {
19
20
  component: MButton,
20
21
  title: 'Components/Buttons/Button',
21
22
  argTypes: {
22
- ...colorArgType(),
23
+ ...variantArgType(),
23
24
  ...sizeArgType()
24
25
  }
25
26
  }
@@ -27,7 +28,8 @@ export default {
27
28
  export const Basic = createStory(MButtonBasic);
28
29
  export const Size = createStory(MButtonSize);
29
30
  export const Rounded = createStory(MButtonRounded);
30
- export const Colors = createStory(MButtonColor);
31
- export const ColorsSecondary = createStory(MButtonColorSecondary);
31
+ export const Colors = createStory(MButtonVariant);
32
+ export const ColorsSecondary = createStory(MButtonVariantSecondary);
32
33
  export const Disabled = createStory(MButtonDisabled);
34
+ export const IconLeft = createStory(MButtonIconLeft);
33
35
  export const Icon = createStory(MButtonIcon);
@@ -1,7 +1,8 @@
1
1
  export { default as MButtonBasic } from './basic.vue';
2
2
  export { default as MButtonSize } from './size.vue';
3
3
  export { default as MButtonRounded } from './rounded.vue';
4
- export { default as MButtonColor } from './colors.vue';
5
- export { default as MButtonColorSecondary } from './colors-secondary.vue';
4
+ export { default as MButtonVariant } from './variants.vue';
5
+ export { default as MButtonVariantSecondary } from './variants-secondary.vue';
6
6
  export { default as MButtonDisabled } from './disabled.vue';
7
+ export { default as MButtonIconLeft } from './icon-left.vue';
7
8
  export { default as MButtonIcon } from './icon.vue';
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <MButton secondary>Default</MButton><br/><br/>
3
+ <MButton secondary variant="tertiary">Tertiary</MButton><br/><br/>
4
+ <MButton secondary variant="primary">Primary</MButton><br/><br/>
5
+ <MButton secondary variant="success">Success</MButton><br/><br/>
6
+ <MButton secondary variant="warning">Warning</MButton><br/><br/>
7
+ <MButton secondary variant="error">Error</MButton><br/><br/>
8
+ </template>
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <MButton>Default</MButton><br/><br/>
3
+ <MButton variant="tertiary">Tertiary</MButton><br/><br/>
4
+ <MButton variant="primary">Primary</MButton><br/><br/>
5
+ <MButton variant="success">Success</MButton><br/><br/>
6
+ <MButton variant="warning">Warning</MButton><br/><br/>
7
+ <MButton variant="error">Error</MButton><br/><br/>
8
+ </template>