@teammodlr/ui-kit 1.0.7 → 2.0.1

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 (260) 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/form/Form.vue.d.ts +12 -1
  38. package/lib/components/form/style/Form.css.d.ts +4 -0
  39. package/lib/components/form/style/index.d.ts +2 -0
  40. package/lib/components/index.d.ts +10 -1
  41. package/lib/components/input/Input.vue.d.ts +35 -19
  42. package/lib/components/input/style/Input.css.d.ts +23 -0
  43. package/lib/components/input/style/index.d.ts +1 -0
  44. package/lib/components/link/Link.vue.d.ts +2 -2
  45. package/lib/components/messageprovider/Message.vue.d.ts +13 -1
  46. package/lib/components/messageprovider/MessageProvider.vue.d.ts +6 -5
  47. package/lib/components/messageprovider/style/Message.css.d.ts +12 -0
  48. package/lib/components/messageprovider/style/index.d.ts +1 -0
  49. package/lib/components/messageprovider/types.d.ts +2 -1
  50. package/lib/components/modal/Modal.vue.d.ts +52 -0
  51. package/lib/components/modal/style/Modal.css.d.ts +21 -0
  52. package/lib/components/modal/style/index.d.ts +1 -0
  53. package/lib/components/radio/Radio.vue.d.ts +85 -0
  54. package/lib/components/radio/style/Checkbox.css.d.ts +16 -0
  55. package/lib/components/radio/style/index.d.ts +1 -0
  56. package/lib/components/radiobutton/RadioButton.vue.d.ts +98 -0
  57. package/lib/components/radiobutton/style/RadioButton.css.d.ts +14 -0
  58. package/lib/components/radiobutton/style/index.d.ts +1 -0
  59. package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +48 -0
  60. package/lib/components/radiobuttongroup/style/RadioButtonGroup.css.d.ts +3 -0
  61. package/lib/components/radiobuttongroup/style/index.d.ts +1 -0
  62. package/lib/components/radiobuttongroup/symbol.d.ts +9 -0
  63. package/lib/components/select/Select.vue.d.ts +22 -13
  64. package/lib/components/select/style/Select.css.d.ts +30 -0
  65. package/lib/components/select/style/index.d.ts +1 -0
  66. package/lib/components/skeleton/Skeleton.vue.d.ts +15 -21
  67. package/lib/components/skeleton/style/Skeleton.css.d.ts +8 -0
  68. package/lib/components/skeleton/style/index.d.ts +2 -0
  69. package/lib/components/slider/Slider.vue.d.ts +32 -0
  70. package/lib/components/slider/style/Slider.css.d.ts +4 -0
  71. package/lib/components/slider/style/index.d.ts +1 -0
  72. package/lib/components/tab/TabGroup.vue.d.ts +1 -1
  73. package/lib/components/table/Table.vue.d.ts +1 -1
  74. package/lib/components/tag/Tag.vue.d.ts +44 -0
  75. package/lib/components/tag/style/Tag.css.d.ts +11 -0
  76. package/lib/components/tag/style/index.d.ts +1 -0
  77. package/lib/components/tooltip/Tooltip.vue.d.ts +17 -2
  78. package/lib/components/tooltip/style/Tooltip.css.d.ts +6 -0
  79. package/lib/components/tooltip/style/index.d.ts +1 -0
  80. package/lib/components/virtualscroll/VirtualScroll.vue.d.ts +46 -16
  81. package/lib/components/virtualscroll/style/VirtualScroll.css.d.ts +1 -0
  82. package/lib/components/virtualscroll/style/index.d.ts +1 -0
  83. package/lib/composables/useInput.d.ts +1 -1
  84. package/lib/composables/useInteractive.d.ts +15 -0
  85. package/lib/composables/useZIndex.d.ts +8 -0
  86. package/lib/index.cjs.js +8 -2
  87. package/lib/index.d.ts +0 -1
  88. package/lib/index.es.js +3699 -1694
  89. package/lib/style.css +1 -1
  90. package/lib/styles/theme.css.d.ts +147 -0
  91. package/lib/styles/typography.css.d.ts +22 -0
  92. package/lib/types/props.d.ts +1 -0
  93. package/package.json +34 -26
  94. package/src/__storybook__/argTypes.ts +19 -1
  95. package/src/components/avatar/Avatar.vue +33 -26
  96. package/src/components/avatar/examples/index.stories.ts +1 -1
  97. package/src/components/avatar/style/Avatar.css.ts +92 -0
  98. package/src/components/avatar/style/index.ts +1 -0
  99. package/src/components/avatargroup/AvatarGroup.vue +71 -32
  100. package/src/components/avatargroup/examples/basic.vue +33 -7
  101. package/src/components/avatargroup/examples/index.stories.ts +4 -8
  102. package/src/components/avatargroup/style/AvatarGroup.css.ts +21 -0
  103. package/src/components/avatargroup/style/index.ts +1 -0
  104. package/src/components/avatargroup/symbol.ts +17 -0
  105. package/src/components/badge/Badge.css +128 -0
  106. package/src/components/badge/Badge.vue +43 -0
  107. package/src/components/badge/examples/basic.vue +10 -0
  108. package/src/components/badge/examples/index.stories.ts +21 -0
  109. package/src/components/badge/examples/index.ts +1 -0
  110. package/src/components/badge/style/Badge.css.ts +124 -0
  111. package/src/components/badge/style/index.ts +1 -0
  112. package/src/components/breadcrumb/Breadcrumb.vue +22 -15
  113. package/src/components/breadcrumb/BreadcrumbItem.vue +73 -0
  114. package/src/components/breadcrumb/examples/basic.vue +5 -7
  115. package/src/components/breadcrumb/examples/index.stories.ts +2 -2
  116. package/src/components/breadcrumb/style/Breadcrumb.css.ts +40 -0
  117. package/src/components/breadcrumb/style/index.ts +1 -0
  118. package/src/components/breadcrumb/symbol.ts +17 -0
  119. package/src/components/button/Button.vue +194 -107
  120. package/src/components/button/examples/icon-left.vue +12 -0
  121. package/src/components/button/examples/icon.vue +6 -7
  122. package/src/components/button/examples/index.stories.ts +9 -7
  123. package/src/components/button/examples/index.ts +3 -2
  124. package/src/components/button/examples/variants-secondary.vue +8 -0
  125. package/src/components/button/examples/variants.vue +8 -0
  126. package/src/components/button/style/Button.css.ts +585 -0
  127. package/src/components/button/style/index.ts +1 -0
  128. package/src/components/buttongroup/ButtonGroup.vue +36 -47
  129. package/src/components/buttongroup/examples/basic.vue +2 -2
  130. package/src/components/buttongroup/examples/icon-group.vue +22 -0
  131. package/src/components/buttongroup/examples/index.stories.ts +4 -2
  132. package/src/components/buttongroup/examples/index.ts +1 -0
  133. package/src/components/buttongroup/style/ButtonGroup.css.ts +40 -0
  134. package/src/components/buttongroup/style/index.ts +1 -0
  135. package/src/components/buttongroup/symbol.ts +8 -0
  136. package/src/components/checkbox/Checkbox.vue +70 -54
  137. package/src/components/checkbox/examples/index.stories.ts +1 -1
  138. package/src/components/checkbox/style/Checkbox.css.ts +127 -0
  139. package/src/components/checkbox/style/index.ts +1 -0
  140. package/src/components/colorpicker/ColorPicker.vue +283 -0
  141. package/src/components/colorpicker/examples/basic.vue +3 -0
  142. package/src/components/colorpicker/examples/index.stories.ts +17 -0
  143. package/src/components/colorpicker/examples/index.ts +1 -0
  144. package/src/components/colorpicker/style/ColorPicker.css.ts +97 -0
  145. package/src/components/colorpicker/style/index.ts +1 -0
  146. package/src/components/colorpicker/utils.ts +188 -0
  147. package/src/components/dropdown/Dropdown.vue +45 -24
  148. package/src/components/dropdown/DropdownItem.vue +121 -118
  149. package/src/components/dropdown/DropdownList.vue +3 -3
  150. package/src/components/dropdown/DropdownWrapper.vue +2 -1
  151. package/src/components/dropdown/examples/custom.vue +13 -0
  152. package/src/components/dropdown/examples/index.stories.ts +4 -2
  153. package/src/components/dropdown/examples/index.ts +1 -0
  154. package/src/components/dropdown/style/Dropdown.css.ts +48 -0
  155. package/src/components/dropdown/style/index.ts +1 -0
  156. package/src/components/dropdown/symbol.ts +8 -0
  157. package/src/components/form/Form.vue +12 -3
  158. package/src/components/form/examples/basic.vue +4 -2
  159. package/src/components/form/examples/index.stories.ts +4 -2
  160. package/src/components/form/style/Form.css.ts +23 -0
  161. package/src/components/form/style/index.ts +2 -0
  162. package/src/components/image/examples/index.stories.ts +1 -1
  163. package/src/components/index.ts +10 -2
  164. package/src/components/input/Input.vue +84 -42
  165. package/src/components/input/examples/basic.vue +2 -1
  166. package/src/components/input/examples/index.stories.ts +1 -1
  167. package/src/components/input/examples/prefix.vue +4 -2
  168. package/src/components/input/examples/suffix.vue +4 -2
  169. package/src/components/input/style/Input.css.ts +221 -0
  170. package/src/components/input/style/index.ts +1 -0
  171. package/src/components/link/examples/index.stories.ts +1 -1
  172. package/src/components/messageprovider/Message.vue +52 -5
  173. package/src/components/messageprovider/MessageProvider.css +0 -13
  174. package/src/components/messageprovider/MessageProvider.vue +18 -16
  175. package/src/components/messageprovider/examples/basic.vue +56 -5
  176. package/src/components/messageprovider/examples/index.stories.ts +0 -1
  177. package/src/components/messageprovider/examples/index.ts +1 -0
  178. package/src/components/messageprovider/examples/update.vue +34 -0
  179. package/src/components/messageprovider/examples/wrapper.vue +1 -1
  180. package/src/components/messageprovider/style/Message.css.ts +109 -0
  181. package/src/components/messageprovider/style/index.ts +1 -0
  182. package/src/components/messageprovider/types.ts +9 -1
  183. package/src/components/modal/Modal.vue +126 -0
  184. package/src/components/modal/examples/basic.vue +40 -0
  185. package/src/components/modal/examples/index.stories.ts +20 -0
  186. package/src/components/modal/examples/index.ts +2 -0
  187. package/src/components/modal/examples/modal-form.vue +99 -0
  188. package/src/components/modal/style/Modal.css.ts +257 -0
  189. package/src/components/modal/style/index.ts +1 -0
  190. package/src/components/radio/Checkbox.css +185 -0
  191. package/src/components/radio/Radio.vue +137 -0
  192. package/src/components/radio/examples/basic.vue +9 -0
  193. package/src/components/radio/examples/index.stories.ts +19 -0
  194. package/src/components/radio/examples/index.ts +2 -0
  195. package/src/components/radio/style/Checkbox.css.ts +132 -0
  196. package/src/components/radio/style/index.ts +1 -0
  197. package/src/components/radiobutton/RadioButton.vue +131 -0
  198. package/src/components/radiobutton/style/RadioButton.css.ts +185 -0
  199. package/src/components/radiobutton/style/index.ts +1 -0
  200. package/src/components/radiobuttongroup/RadioButtonGroup.vue +75 -0
  201. package/src/components/radiobuttongroup/examples/basic.vue +17 -0
  202. package/src/components/radiobuttongroup/examples/index.stories.ts +22 -0
  203. package/src/components/radiobuttongroup/examples/index.ts +2 -0
  204. package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +37 -0
  205. package/src/components/radiobuttongroup/style/index.ts +1 -0
  206. package/src/components/radiobuttongroup/symbol.ts +11 -0
  207. package/src/components/select/Select.css +0 -226
  208. package/src/components/select/Select.vue +116 -48
  209. package/src/components/select/examples/index.stories.ts +1 -1
  210. package/src/components/select/examples/multiple.vue +1 -2
  211. package/src/components/select/style/Select.css.ts +254 -0
  212. package/src/components/select/style/index.ts +1 -0
  213. package/src/components/skeleton/Skeleton.vue +55 -47
  214. package/src/components/skeleton/examples/index.stories.ts +1 -8
  215. package/src/components/skeleton/style/Skeleton.css.ts +57 -0
  216. package/src/components/skeleton/style/index.ts +2 -0
  217. package/src/components/slider/Slider.vue +76 -0
  218. package/src/components/slider/style/Slider.css.ts +43 -0
  219. package/src/components/slider/style/index.ts +1 -0
  220. package/src/components/tab/examples/index.stories.ts +1 -1
  221. package/src/components/table/examples/index.stories.ts +1 -1
  222. package/src/components/tag/Tag.css +0 -0
  223. package/src/components/tag/Tag.vue +66 -0
  224. package/src/components/tag/examples/basic.vue +5 -0
  225. package/src/components/tag/examples/index.stories.ts +22 -0
  226. package/src/components/tag/examples/index.ts +1 -0
  227. package/src/components/tag/style/Tag.css.ts +79 -0
  228. package/src/components/tag/style/index.ts +1 -0
  229. package/src/components/tooltip/Tooltip.css +0 -6
  230. package/src/components/tooltip/Tooltip.vue +53 -22
  231. package/src/components/tooltip/examples/basic.vue +2 -5
  232. package/src/components/tooltip/examples/index.stories.ts +1 -1
  233. package/src/components/tooltip/style/Tooltip.css.ts +48 -0
  234. package/src/components/tooltip/style/index.ts +1 -0
  235. package/src/components/virtualscroll/VirtualScroll.vue +159 -53
  236. package/src/components/virtualscroll/examples/basic.vue +21 -27
  237. package/src/components/virtualscroll/examples/index.stories.ts +2 -18
  238. package/src/components/virtualscroll/style/VirtualScroll.css.ts +18 -0
  239. package/src/components/virtualscroll/style/index.ts +1 -0
  240. package/src/composables/useInput.ts +2 -2
  241. package/src/composables/useInteractive.ts +20 -0
  242. package/src/composables/usePopper.ts +1 -1
  243. package/src/composables/useZIndex.ts +31 -0
  244. package/src/css/components.css +4 -3
  245. package/src/css/normalize.css +0 -379
  246. package/src/css/variables.css +2 -2
  247. package/src/examples/cards/cards.stories.ts +9 -0
  248. package/src/examples/cards/sidebar.vue +263 -0
  249. package/src/index.ts +1 -1
  250. package/src/styles/theme.css.ts +149 -0
  251. package/src/styles/typography.css.ts +91 -0
  252. package/src/types/props.ts +2 -0
  253. package/lib/components/breadcrumbitem/index.d.ts +0 -1
  254. package/src/components/avatar/Avatar.css +0 -69
  255. package/src/components/breadcrumbitem/BreadcrumbItem.vue +0 -66
  256. package/src/components/breadcrumbitem/index.ts +0 -1
  257. package/src/components/button/examples/colors-secondary.vue +0 -8
  258. package/src/components/button/examples/colors.vue +0 -8
  259. package/src/components/dropdown/Dropdown.css +0 -68
  260. /package/src/components/button/{Button.css → Button-old.css} +0 -0
@@ -0,0 +1,132 @@
1
+ import {createVar, globalKeyframes, globalStyle, style, styleVariants} from "@vanilla-extract/css";
2
+ import { themeVars } from "../../../styles/theme.css";
3
+ import { fonts} from "../../../styles/typography.css";
4
+
5
+ const sizes = {
6
+ xs: '16px',
7
+ sm: '18px',
8
+ md: '20px',
9
+ lg: '22px',
10
+ xl: '24px',
11
+ };
12
+
13
+ export const vars = {
14
+ height: createVar(),
15
+ radius: createVar(),
16
+ backgroundColor: createVar(),
17
+ borderColor: createVar(),
18
+ color: createVar()
19
+ }
20
+
21
+ export const base = style({
22
+ position: "relative",
23
+ display: "inline-flex",
24
+ alignItems: "center",
25
+ cursor: "pointer",
26
+ gap: themeVars.space['1.5'],
27
+ });
28
+
29
+ export const input = style({
30
+ position: 'absolute',
31
+ opacity: 0,
32
+ cursor: "pointer"
33
+ });
34
+
35
+ export const checkmark = style({
36
+ position: "absolute",
37
+ width: `calc(${vars.height} - 2px)`,
38
+ height: `calc(${vars.height} - 2px)`,
39
+ top: "50%",
40
+ left: "50%",
41
+ transform: "translate(-50%, -50%)",
42
+ color: "white",
43
+ });
44
+
45
+ export const checkbox = style({
46
+ vars: {
47
+ [vars.height]: sizes.md,
48
+ [vars.radius]: themeVars.rounded.full,
49
+ [vars.backgroundColor]: 'white',
50
+ [vars.borderColor]: themeVars.color.gray[300],
51
+ [vars.color]: themeVars.color.gray[600],
52
+ },
53
+ position: "relative",
54
+ width: vars.height,
55
+ height: vars.height,
56
+ borderRadius: vars.radius,
57
+ backgroundColor: vars.backgroundColor,
58
+ border: `1px solid ${vars.borderColor}`,
59
+ color: vars.color,
60
+ cursor: 'pointer',
61
+ transition: `all 0.125s ${themeVars.transition.default}`
62
+ });
63
+
64
+ export const checked = style({
65
+ vars: {
66
+ [vars.borderColor]: themeVars.color.blue[500],
67
+ [vars.backgroundColor]: themeVars.color.blue[500],
68
+ },
69
+ selectors: {
70
+ ['&:after']: {
71
+ content: '',
72
+ position: 'absolute',
73
+ top: '50%',
74
+ left: '50%',
75
+ transform: 'translate(-50%, -50%)',
76
+ width: `calc(${vars.height} - 10px)`,
77
+ height: `calc(${vars.height} - 10px)`,
78
+ borderRadius: themeVars.rounded.full,
79
+ backgroundColor: "#FFF"
80
+ }
81
+ }
82
+ });
83
+
84
+ export const disabled = style({
85
+ opacity: 0.5,
86
+ cursor: 'not-allowed',
87
+ });
88
+
89
+ export const indeterminate = style({
90
+ vars: {
91
+ [vars.borderColor]: themeVars.color.blue[500],
92
+ [vars.backgroundColor]: themeVars.color.blue[500],
93
+ }
94
+ });
95
+
96
+ export const label = style({
97
+ marginLeft: themeVars.space['0.5'],
98
+ fontVariationSettings: `"wght" ${fonts.INTER.wghts[500]}`,
99
+ display: 'inline-block',
100
+ fontSize: themeVars.fontSize.base,
101
+ wordBreak: 'break-word',
102
+ cursor: 'pointer',
103
+ })
104
+
105
+ export const size = styleVariants({
106
+ xs: {
107
+ vars: {
108
+ [vars.height]: sizes.xs
109
+ }
110
+ },
111
+ sm: {
112
+ vars: {
113
+ [vars.height]: sizes.sm
114
+ }
115
+ },
116
+ md: {
117
+ vars: {
118
+ [vars.height]: sizes.md
119
+ },
120
+ },
121
+ lg: {
122
+ vars: {
123
+ [vars.height]: sizes.lg,
124
+ },
125
+ },
126
+ xl: {
127
+ vars: {
128
+ [vars.height]: sizes.xl,
129
+ },
130
+ },
131
+ });
132
+
@@ -0,0 +1 @@
1
+ export * from './Checkbox.css'
@@ -0,0 +1,131 @@
1
+ <template>
2
+ <label :class="computedClasses" :disabled="disabled" @click="handleClick" v-bind="$attrs" :aria-selected="selected" :aria-disabled="disabled">
3
+ <input type="radio" :class="computedRadioClasses" :name="name" :value="id" :disabled="disabled">
4
+ <span>
5
+ <slot />
6
+ </span>
7
+ </label>
8
+ </template>
9
+
10
+ <script lang="ts">
11
+ import type {PropType} from "vue";
12
+ import {computed, defineComponent, defineExpose, inject, ref} from "vue";
13
+ import type {Size} from "../../types/props";
14
+ import * as style from "./style";
15
+ import {useInteractive} from "../../composables/useInteractive";
16
+ import {useInput} from "../../composables/useInput";
17
+ import {RADIO_BUTTON_GROUP_STATE} from "../radiobuttongroup/symbol";
18
+
19
+ export default defineComponent({
20
+ name: "MRadioButton",
21
+ props: {
22
+ ...useInput.props(),
23
+ ...useInteractive.props(),
24
+ id: {
25
+ type: [String, Number],
26
+ required: true
27
+ },
28
+ type: {
29
+ type: String,
30
+ default: 'button',
31
+ },
32
+ size: {
33
+ type: String as PropType<Size>,
34
+ default: 'md'
35
+ },
36
+ disabled: {
37
+ type: Boolean,
38
+ default: false
39
+ },
40
+ icon: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ onClick: {
45
+ type: Function as PropType<(e: MouseEvent) => void>,
46
+ default: () => {
47
+ }
48
+ }
49
+ },
50
+ emits: ['update:modelValue'],
51
+ setup(props, {emit}) {
52
+ const radioRef = ref<HTMLElement | null>(null);
53
+ const parentState = inject(RADIO_BUTTON_GROUP_STATE, null);
54
+ const value = computed(() => {
55
+ return parentState?.modelValue;
56
+ });
57
+ const sizeValue = computed<Size>(() => {
58
+ return parentState?.size || props.size;
59
+ });
60
+
61
+ const name = computed(() => {
62
+ return parentState?.name;
63
+ });
64
+
65
+ const {focus, blur} = useInteractive(radioRef);
66
+
67
+ const {
68
+ id,
69
+ insideForm,
70
+ reset,
71
+ validate,
72
+ setError,
73
+ formError,
74
+ formDisabled,
75
+ formLoading,
76
+ inputListeners
77
+ } = useInput(props, {focus, emit});
78
+
79
+ const selected = computed(() => {
80
+ // @ts-ignore
81
+ return value.value === props.id;
82
+ });
83
+
84
+ const computedClasses = computed(() => {
85
+ return [
86
+ style.base,
87
+ [style.size[sizeValue.value]],
88
+ {
89
+ [style.icon]: props.icon,
90
+ [style.variant.default]: !selected.value,
91
+ [style.variant.active]: selected.value,
92
+ }
93
+ ]
94
+ });
95
+
96
+ const computedRadioClasses = computed(() => {
97
+ return [
98
+ style.radio
99
+ ]
100
+ });
101
+
102
+ const handleClick = (e: MouseEvent): void => {
103
+ if (props.disabled) {
104
+ e.preventDefault();
105
+ return;
106
+ }
107
+
108
+ // @ts-ignore
109
+ parentState.doUpdateValue(props.id);
110
+ props.onClick(e);
111
+ };
112
+
113
+ defineExpose({
114
+ focus,
115
+ blur,
116
+ })
117
+
118
+ return {
119
+ radioRef,
120
+ computedClasses,
121
+ handleClick,
122
+ selected,
123
+ value,
124
+ name,
125
+ focus,
126
+ blur,
127
+ computedRadioClasses
128
+ }
129
+ }
130
+ })
131
+ </script>
@@ -0,0 +1,185 @@
1
+ import {createVar, globalStyle, style, styleVariants} from "@vanilla-extract/css";
2
+ import {themeVars} from "../../../styles/theme.css";
3
+ import {fonts} from "../../../styles/typography.css";
4
+
5
+ const sizes = {
6
+ xs: '22px',
7
+ sm: '28px',
8
+ md: '36px',
9
+ lg: '40px',
10
+ xl: '45px',
11
+ };
12
+
13
+ const borderRadiuses = {
14
+ xs: '2px',
15
+ sm: '3px',
16
+ md: '4px',
17
+ lg: '6px',
18
+ xl: '8px',
19
+ };
20
+
21
+ const padding = {
22
+ xs: `0 ${themeVars.space[1]}`,
23
+ sm: `0 ${themeVars.space[2]}`,
24
+ md: `0 ${themeVars.space[3]}`,
25
+ lg: `0 ${themeVars.space[3]}`,
26
+ xl: `0 ${themeVars.space[4]}`,
27
+ }
28
+
29
+ export const vars = {
30
+ height: createVar(),
31
+ radius: createVar(),
32
+ padding: createVar(),
33
+ backgroundColor: createVar(),
34
+ borderColor: createVar(),
35
+ boxShadowColor: createVar(),
36
+ color: createVar(),
37
+ }
38
+
39
+ export const base = style({
40
+ vars: {
41
+ [vars.borderColor]: "transparent",
42
+ },
43
+ alignItems: 'center',
44
+ boxSizing: 'border-box',
45
+ display: 'inline-flex',
46
+ fontSize: themeVars.fontSize.base,
47
+ fontVariationSettings: `"wght" ${fonts.INTER.wghts[500]}`,
48
+ maxWidth: '100%',
49
+ width: 'auto',
50
+ position: 'relative',
51
+ textAlign: 'center',
52
+ textDecoration: 'none',
53
+ verticalAlign: 'middle',
54
+ whiteSpace: 'nowrap',
55
+ justifyContent: 'center',
56
+ height: vars.height,
57
+ lineHeight: vars.height,
58
+ borderRadius: vars.radius,
59
+ padding: vars.padding,
60
+ zIndex: "auto",
61
+ backgroundColor: vars.backgroundColor,
62
+ border: `1px solid ${vars.borderColor}`,
63
+ color: vars.color,
64
+ transition: `color .3s ${themeVars.transition.default},
65
+ background-color .3s ${themeVars.transition.default},
66
+ box-shadow .3s ${themeVars.transition.default},
67
+ border-color .3s ${themeVars.transition.default}`,
68
+ fontFamily: 'inherit',
69
+ ':hover': {
70
+ cursor: 'pointer',
71
+ },
72
+ ':focus': {
73
+ outline: 'none',
74
+ }
75
+ });
76
+
77
+ export const variant = styleVariants({
78
+ active: {
79
+ vars: {
80
+ [vars.backgroundColor]: "white",
81
+ [vars.color]: themeVars.color.blue[500],
82
+ [vars.boxShadowColor]: themeVars.color.gray[900],
83
+ [vars.borderColor]: themeVars.color.gray[200],
84
+ },
85
+ boxShadow: `0 .5px 0px 4px rgba(0, 0, 0, 0.01)`,
86
+ ':hover': {
87
+ vars: {
88
+ [vars.color]: themeVars.color.blue[600],
89
+ },
90
+ },
91
+ ':focus': {
92
+ vars: {
93
+ [vars.color]: themeVars.color.blue[500],
94
+ }
95
+ }
96
+ },
97
+ default: {
98
+ vars: {
99
+ [vars.color]: themeVars.color.gray[400],
100
+ [vars.backgroundColor]: 'transparent',
101
+ [vars.boxShadowColor]: themeVars.color.blue[500],
102
+ [vars.borderColor]: "transparent",
103
+ },
104
+ ':hover': {
105
+ vars: {
106
+ [vars.color]: themeVars.color.blue[400],
107
+ },
108
+ },
109
+ ':focus': {
110
+ vars: {
111
+ [vars.color]: themeVars.color.blue[400],
112
+ }
113
+ }
114
+ }
115
+ });
116
+
117
+ export const size = styleVariants({
118
+ xs: {
119
+ vars: {
120
+ [vars.height]: sizes.xs,
121
+ [vars.radius]: borderRadiuses.xs,
122
+ [vars.padding]: padding.xs,
123
+ },
124
+ fontSize: themeVars.fontSize.small,
125
+ },
126
+ sm: {
127
+ vars: {
128
+ [vars.height]: sizes.sm,
129
+ [vars.radius]: borderRadiuses.sm,
130
+ [vars.padding]: padding.sm,
131
+ },
132
+ fontSize: themeVars.fontSize.small,
133
+ },
134
+ md: {
135
+ vars: {
136
+ [vars.height]: sizes.md,
137
+ [vars.radius]: borderRadiuses.md,
138
+ [vars.padding]: padding.md,
139
+ },
140
+ },
141
+ lg: {
142
+ vars: {
143
+ [vars.height]: sizes.lg,
144
+ [vars.radius]: borderRadiuses.lg,
145
+ [vars.padding]: padding.lg,
146
+ },
147
+ fontSize: themeVars.fontSize.large,
148
+ },
149
+ xl: {
150
+ vars: {
151
+ [vars.height]: sizes.xl,
152
+ [vars.radius]: borderRadiuses.xl,
153
+ [vars.padding]: padding.xl,
154
+ },
155
+ fontSize: themeVars.fontSize.large,
156
+ },
157
+ });
158
+
159
+ export const icon = style({
160
+ display: 'flex',
161
+ flexGrow: 0,
162
+ flexShrink: 0,
163
+ fontSize: 0,
164
+ lineHeight: 0,
165
+ userSelect: 'none'
166
+ });
167
+
168
+ globalStyle(`${icon} > svg`, {
169
+ overflow: 'hidden',
170
+ pointerEvents: 'none',
171
+ maxWidth: '100%',
172
+ maxHeight: '100%',
173
+ verticalAlign: 'middle'
174
+ });
175
+
176
+ export const radio = style({
177
+ pointerEvents: "none",
178
+ position: "absolute",
179
+ border: 0,
180
+ left: 0,
181
+ right: 0,
182
+ top: 0,
183
+ bottom: 0,
184
+ opacity: 0
185
+ })
@@ -0,0 +1 @@
1
+ export * from './RadioButton.css';
@@ -0,0 +1,75 @@
1
+ <template>
2
+ <div
3
+ :class="computedClasses"
4
+ >
5
+ <slot/>
6
+ </div>
7
+ </template>
8
+
9
+ <script lang="ts">
10
+ import {computed, defineComponent, type PropType, provide, reactive, toRef} from "vue";
11
+ import type {Size} from '../../types/props';
12
+ import * as style from "./style";
13
+ import type {RadioButtonGroupState} from "./symbol";
14
+ import {RADIO_BUTTON_GROUP_STATE} from "./symbol";
15
+
16
+ export default defineComponent({
17
+ name: "MRadioButtonGroup",
18
+ props: {
19
+ modelValue: {
20
+ type: [String, Number],
21
+ default: ""
22
+ },
23
+ size: {
24
+ type: String as PropType<Size>,
25
+ default: 'md'
26
+ },
27
+ name: {
28
+ type: String,
29
+ required: true
30
+ },
31
+ block: {
32
+ type: Boolean,
33
+ default: false
34
+ }
35
+ },
36
+ emits: ['update:modelValue'],
37
+ setup(props, {emit}) {
38
+
39
+ function doUpdateValue (value: string | number) {
40
+ emit('update:modelValue', value)
41
+ }
42
+
43
+ const selectedValue = computed({
44
+ get() {
45
+ return props.modelValue;
46
+ },
47
+ set(value) {
48
+ doUpdateValue(value);
49
+ }
50
+ });
51
+
52
+ const state: RadioButtonGroupState = reactive({
53
+ size: toRef(props, 'size'),
54
+ name: toRef(props, 'name'),
55
+ modelValue: selectedValue,
56
+ doUpdateValue
57
+ });
58
+
59
+ provide(RADIO_BUTTON_GROUP_STATE, state);
60
+
61
+ const computedClasses = computed(() => {
62
+ return [
63
+ style.base,
64
+ {
65
+ [style.block]: props.block
66
+ }
67
+ ]
68
+ })
69
+
70
+ return {
71
+ computedClasses
72
+ }
73
+ }
74
+ });
75
+ </script>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <MRadioButtonGroup v-model="value" size="sm" name="text-align">
3
+ <MRadioButton icon id="left-align">
4
+ <svg width="24px" height="24px" stroke-width="2" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 10h14M3 6h18M3 18h14M3 14h18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
5
+ </MRadioButton>
6
+ <MRadioButton icon id="center-align">
7
+ <svg width="24px" height="24px" stroke-width="2" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 6h18M3 14h18M6 10h12M6 18h12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
8
+ </MRadioButton>
9
+ <MRadioButton icon id="right-align">
10
+ <svg width="24px" height="24px" stroke-width="2" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 10h14M3 6h18M7 18h14M3 14h18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
11
+ </MRadioButton>
12
+ </MRadioButtonGroup>
13
+ </template>
14
+ <script setup lang="ts">
15
+ import { ref } from 'vue'
16
+ const value = ref("left-align");
17
+ </script>
@@ -0,0 +1,22 @@
1
+ import MRadioButtonGroup from "../RadioButtonGroup.vue";
2
+ import MRadioButton from "../../radiobutton/RadioButton.vue";
3
+ import {
4
+ MRadioButtonGroupBasic,
5
+ } from "./index";
6
+
7
+ import {
8
+ createStory, sizeArgType, colorArgType
9
+ } from "../../../__storybook__";
10
+
11
+ export default {
12
+ component: MRadioButtonGroup,
13
+ subcomponents: {
14
+ MRadioButton
15
+ },
16
+ title: 'Components/Radio Button Group',
17
+ argTypes: {
18
+ ...sizeArgType(),
19
+ }
20
+ }
21
+
22
+ export const Basic = createStory(MRadioButtonGroupBasic);
@@ -0,0 +1,2 @@
1
+ export { default as MRadioButtonGroupBasic } from './basic.vue';
2
+
@@ -0,0 +1,37 @@
1
+ import {createVar, globalStyle, style} from "@vanilla-extract/css";
2
+ import {base as button} from "../../radiobutton/style/RadioButton.css";
3
+ import {themeVars} from "../../../styles/theme.css";
4
+
5
+ const vars = {
6
+ padding: createVar(),
7
+ borderRadius: createVar(),
8
+ gap: createVar()
9
+ }
10
+
11
+ export const base = style({
12
+ vars: {
13
+ [vars.padding]: themeVars.space[1],
14
+ [vars.borderRadius]: themeVars.rounded.default,
15
+ [vars.gap]: themeVars.space[1],
16
+ },
17
+ display: "inline-flex",
18
+ position: "relative",
19
+ flexWrap: "nowrap",
20
+ backgroundColor: themeVars.color.gray[100],
21
+ padding: vars.padding,
22
+ borderRadius: vars.borderRadius,
23
+ gap: vars.gap,
24
+ });
25
+
26
+ export const vertical = style({
27
+ flexDirection: "column",
28
+ });
29
+
30
+ export const block = style({
31
+ display: "flex",
32
+ alignItems: "stretch",
33
+ });
34
+
35
+ globalStyle(`${base}${block} > ${button}`, {
36
+ flex: 1,
37
+ });
@@ -0,0 +1 @@
1
+ export * from './RadioButtonGroup.css';
@@ -0,0 +1,11 @@
1
+ import type {InjectionKey} from "vue";
2
+ import type {Size} from "../../types/props";
3
+
4
+ export interface RadioButtonGroupState {
5
+ size: Size,
6
+ name: string,
7
+ modelValue: string | number,
8
+ doUpdateValue: (value: string | number) => void
9
+ }
10
+
11
+ export const RADIO_BUTTON_GROUP_STATE: InjectionKey<RadioButtonGroupState> = Symbol('RADIO_BUTTON_GROUP_STATE');