@teammodlr/ui-kit 1.0.7 → 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
@@ -1,37 +1,38 @@
1
1
  <template>
2
- <div :class="wrapperComputedClasses" ref="container">
3
- <label v-if="label" :for="id" class="m-input__label" :id="`${id}-label`">
2
+ <div ref="container" :class="computedContainerClasses">
3
+ <label v-if="label" :for="id" :id="`${id}-label`" :class="style.label">
4
4
  {{ label }}
5
5
  </label>
6
+ <div v-if="description" :class="style.description">
7
+ {{ description }}
8
+ </div>
6
9
 
7
- <div :class="inputComputedClasses">
8
- <div v-if="hasPrefix" class="m-input__prefix">
9
- <slot name="prefix" />
10
+ <div :class="wrapperComputedClasses">
11
+ <div v-if="hasLeftIcon" :class="style.leftIcon">
12
+ <slot name="icon-left" />
10
13
  </div>
11
14
  <input
12
- ref="input"
15
+ ref="element"
13
16
  :id="id"
14
17
  :type="inputType"
15
18
  :placeholder="placeholder"
16
19
  :name="name"
17
20
  :value="modelValue || ''"
18
21
  :readonly="readonly"
19
- v-on="listeners"
22
+ v-on="inputListeners"
23
+ :class="inputComputedClasses"
20
24
  v-bind="$attrs"
21
25
  :disabled="disabled || loading"
22
26
  :aria-disabled="disabled ? 'true' : 'false'"
23
27
  :aria-labelledby="`${id}-label`"
24
28
  />
25
- <div v-if="hasSuffix" class="m-input__suffix">
26
- <slot name="suffix" />
29
+ <div v-if="hasRightIcon" :class="style.rightIcon">
30
+ <slot name="icon-right" />
27
31
  </div>
28
32
  </div>
29
- <p v-if="help && !inputError" class="m-input__help">
30
- {{ help }}
31
- </p>
32
- <p v-else-if="inputError" class="m-input__error">
33
+ <div v-if="inputError" :class="style.errorMessage">
33
34
  {{ inputError }}
34
- </p>
35
+ </div>
35
36
  </div>
36
37
  </template>
37
38
 
@@ -43,13 +44,17 @@ import {
43
44
  ref,
44
45
  computed,
45
46
  toRef,
47
+ defineExpose
46
48
  } from "vue";
47
49
  import { useInput } from "../../composables/useInput";
50
+ import { useInteractive } from "../../composables/useInteractive";
51
+ import * as style from './style';
52
+
48
53
  export default defineComponent({
49
54
  name: 'MInput',
50
- emits: useInput.emits(),
51
55
  props: {
52
56
  ...useInput.props(),
57
+ ...useInteractive.props(),
53
58
  label: {
54
59
  type: String
55
60
  },
@@ -60,7 +65,7 @@ export default defineComponent({
60
65
  type: {
61
66
  type: String,
62
67
  default: 'text',
63
- validator: (value: string) => ['text', 'password', 'number', 'email'].includes(value)
68
+ validator: (value: string) => ['text', 'password', 'number', 'email', 'date', 'datetime'].includes(value)
64
69
  },
65
70
  placeholder: {
66
71
  type: String,
@@ -78,18 +83,28 @@ export default defineComponent({
78
83
  type: Boolean,
79
84
  default: false
80
85
  },
81
- help: {
86
+ description: {
82
87
  type: String,
83
88
  default: ''
84
- }
89
+ },
90
+ block: {
91
+ type: Boolean,
92
+ default: false
93
+ },
94
+ error: {
95
+ type: String,
96
+ default: ''
97
+ },
85
98
  },
99
+ emits: useInput.emits(),
86
100
  setup(props, { slots, emit }) {
87
- const focus = () => {};
101
+ const element = ref<HTMLInputElement|null>(null);
102
+ const { focus, blur } = useInteractive(element);
88
103
  const {
89
104
  id,
90
105
  insideForm,
91
106
  reset,
92
- listeners,
107
+ inputListeners,
93
108
  validate,
94
109
  setError,
95
110
  formError,
@@ -97,13 +112,11 @@ export default defineComponent({
97
112
  formLoading
98
113
  } = useInput(props, { focus, emit });
99
114
 
100
- const input = ref<HTMLInputElement>();
101
- const focused = ref(false);
102
115
  const showPassword = ref(false);
103
116
  const name = toRef(props, 'name');
104
117
 
105
- const hasPrefix = computed(() => !!(slots.prefix));
106
- const hasSuffix = computed(() => !!(slots.suffix));
118
+ const hasLeftIcon = computed(() => !!(slots['icon-left']));
119
+ const hasRightIcon = computed(() => !!(slots['icon-right']));
107
120
  const disabled = computed(() => formDisabled || props.disabled);
108
121
  const loading = computed(() => formLoading || props.loading);
109
122
 
@@ -117,31 +130,51 @@ export default defineComponent({
117
130
  });
118
131
 
119
132
  const readonly = computed(() => (props.loading || props.readonly));
120
-
133
+
134
+ const computedContainerClasses = computed(() => {
135
+ return [
136
+ {
137
+ [style.block]: props.block,
138
+ }
139
+ ]
140
+ });
141
+
121
142
  const wrapperComputedClasses = computed(() => {
122
143
  return [
123
- 'm-input__container',
144
+ style.wrapper,
124
145
  {
125
- 'm-form__input': insideForm
146
+ [style.block]: props.block,
126
147
  }
127
148
  ]
128
149
  });
129
150
 
130
151
  const inputComputedClasses = computed(() => {
131
152
  return [
132
- 'm-input',
133
- `m-input--${props.size}`,
153
+ style.base,
154
+ style.size[props.size],
134
155
  {
135
- 'm-input--disabled': disabled.value || loading.value,
136
- 'm-input--readonly': readonly.value,
137
- 'm-input--focused': focused.value,
138
- 'm-input--error': inputError.value,
139
- 'm-input--prefix': hasPrefix.value,
140
- 'm-input--suffix': hasSuffix.value,
141
- 'm-input--loading': props.loading,
142
- 'm-input--password': props.type === 'password'
156
+ [style.block]: props.block,
157
+ [style.disabled]: disabled.value || loading.value,
158
+ [style.error]: inputError.value,
159
+ [style.hasLeftIcon]: hasLeftIcon.value,
160
+ [style.hasRightIcon]: hasRightIcon.value,
143
161
  }
144
- ]
162
+ ];
163
+
164
+ // return [
165
+ // 'm-input',
166
+ // `m-input--${props.size}`,
167
+ // {
168
+ // 'm-input--disabled': disabled.value || loading.value,
169
+ // 'm-input--readonly': readonly.value,
170
+ // 'm-input--focused': focused.value,
171
+ // 'm-input--error': inputError.value,
172
+ // 'm-input--icon-left': hasLeftIcon.value,
173
+ // 'm-input--icon-right': hasRightIcon.value,
174
+ // 'm-input--loading': props.loading,
175
+ // 'm-input--password': props.type === 'password'
176
+ // }
177
+ // ]
145
178
  });
146
179
 
147
180
  const inputError = computed(() => {
@@ -152,7 +185,13 @@ export default defineComponent({
152
185
  emit('update:modelValue', '');
153
186
  };
154
187
 
188
+ defineExpose({
189
+ focus,
190
+ blur,
191
+ })
192
+
155
193
  return {
194
+ element,
156
195
  id,
157
196
  inputType,
158
197
  disabled,
@@ -160,16 +199,19 @@ export default defineComponent({
160
199
  readonly,
161
200
  inputComputedClasses,
162
201
  wrapperComputedClasses,
202
+ computedContainerClasses,
163
203
  name,
164
- hasPrefix,
165
- hasSuffix,
204
+ hasLeftIcon,
205
+ hasRightIcon,
166
206
  inputError,
207
+ style,
167
208
 
168
209
  onClear,
169
- focus,
170
210
  validate,
171
211
  setError,
172
- listeners
212
+ focus,
213
+ blur,
214
+ inputListeners
173
215
  }
174
216
  }
175
217
  })
@@ -1,7 +1,8 @@
1
1
  <template>
2
- <MInput
2
+ <MInput
3
3
  label="Email"
4
4
  name="email"
5
5
  placeholder="Email Address"
6
+ autofocus
6
7
  />
7
8
  </template>
@@ -8,7 +8,7 @@ import {
8
8
 
9
9
  import {
10
10
  createStory, sizeArgType
11
- } from "@/__storybook__";
11
+ } from "../../../__storybook__";
12
12
 
13
13
  export default {
14
14
  component: MInput,
@@ -1,7 +1,9 @@
1
1
  <template>
2
2
  <MInput placeholder="Brad Veryard" name="name">
3
- <template #prefix>
4
- Prefix
3
+ <template #icon-left>
4
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" style="width: 20px; height: 20px;">
5
+ <path stroke-linecap="round" d="M16.5 12a4.5 4.5 0 11-9 0 4.5 4.5 0 019 0zm0 0c0 1.657 1.007 3 2.25 3S21 13.657 21 12a9 9 0 10-2.636 6.364M16.5 12V8.25" />
6
+ </svg>
5
7
  </template>
6
8
  </MInput>
7
9
  </template>
@@ -1,7 +1,9 @@
1
1
  <template>
2
2
  <MInput placeholder="Brad Veryard" name="name">
3
- <template #suffix>
4
- Suffix
3
+ <template #icon-right>
4
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 20px; height: 20px;">
5
+ <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd" />
6
+ </svg>
5
7
  </template>
6
8
  </MInput>
7
9
  </template>
@@ -0,0 +1,221 @@
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: '26px',
7
+ sm: '30px',
8
+ md: '38px',
9
+ lg: '42px',
10
+ xl: '48px',
11
+ };
12
+
13
+ const borderRadiuses = {
14
+ xs: '2px',
15
+ sm: '3px',
16
+ md: '4px',
17
+ lg: '6px',
18
+ xl: '8px',
19
+ };
20
+
21
+ export const vars = {
22
+ height: createVar(),
23
+ radius: createVar(),
24
+ paddingX: createVar(),
25
+ paddingY: createVar(),
26
+ borderColor: createVar(),
27
+ backgroundColor: createVar(),
28
+ color: createVar(),
29
+ cursor: createVar(),
30
+ }
31
+
32
+ export const wrapper = style({
33
+ position: 'relative'
34
+ });
35
+
36
+ export const base = style({
37
+ vars: {
38
+ [vars.height]: sizes.md,
39
+ [vars.radius]: borderRadiuses.md,
40
+ [vars.paddingX]: themeVars.space[2],
41
+ [vars.paddingY]: themeVars.space[0.5],
42
+ [vars.borderColor]: themeVars.color.gray[300],
43
+ [vars.color]: themeVars.color.gray[600],
44
+ [vars.backgroundColor]: '#FFFFFF',
45
+ [vars.cursor]: 'text',
46
+ },
47
+ height: vars.height,
48
+ minHeight: vars.height,
49
+ width: '100%',
50
+ borderRadius: vars.radius,
51
+ borderWidth: 1,
52
+ borderStyle: 'solid',
53
+ borderColor: vars.borderColor,
54
+ padding: `${vars.paddingY} ${vars.paddingX}`,
55
+ fontSize: themeVars.fontSize.base,
56
+ display: 'block',
57
+ textAlign: 'left',
58
+ appearance: 'none',
59
+ lineHeight: vars.height,
60
+ boxSizing: 'border-box',
61
+ resize: 'none',
62
+ boxShadow: 'none',
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
+ ':hover': {
69
+ vars: {
70
+ [vars.borderColor]: themeVars.color.blue[400],
71
+ }
72
+ },
73
+ ':focus': {
74
+ vars: {
75
+ [vars.borderColor]: themeVars.color.blue[500],
76
+ },
77
+ outline: 'none',
78
+ boxShadow: `0 0 0 2px ${themeVars.color.blue[200]}`,
79
+ }
80
+ });
81
+
82
+ export const size = styleVariants({
83
+ xs: {
84
+ vars: {
85
+ [vars.height]: sizes.xs,
86
+ [vars.radius]: borderRadiuses.xs,
87
+ [vars.paddingX]: themeVars.space[1],
88
+ },
89
+ fontSize: themeVars.fontSize.small,
90
+ },
91
+ sm: {
92
+ vars: {
93
+ [vars.height]: sizes.sm,
94
+ [vars.radius]: borderRadiuses.sm,
95
+ [vars.paddingX]: themeVars.space[1.5],
96
+ },
97
+ fontSize: themeVars.fontSize.small,
98
+ },
99
+ md: {
100
+ vars: {
101
+ [vars.height]: sizes.md,
102
+ [vars.radius]: borderRadiuses.md
103
+ },
104
+ },
105
+ lg: {
106
+ vars: {
107
+ [vars.height]: sizes.lg,
108
+ [vars.radius]: borderRadiuses.lg,
109
+ [vars.paddingX]: themeVars.space[2.5],
110
+ },
111
+ fontSize: themeVars.fontSize.large,
112
+ },
113
+ xl: {
114
+ vars: {
115
+ [vars.height]: sizes.xl,
116
+ [vars.radius]: borderRadiuses.xl,
117
+ [vars.paddingX]: themeVars.space[3],
118
+ },
119
+ fontSize: themeVars.fontSize.large,
120
+ },
121
+ });
122
+
123
+ export const block = style({
124
+ width: '100%',
125
+ });
126
+
127
+ export const disabled = style({
128
+ vars: {
129
+ [vars.borderColor]: themeVars.color.gray[200],
130
+ [vars.color]: themeVars.color.gray[500],
131
+ [vars.backgroundColor]: themeVars.color.gray[50],
132
+ [vars.cursor]: 'not-allowed',
133
+ },
134
+ ':focus': {
135
+ boxShadow: 'none',
136
+ },
137
+ ':hover': {
138
+ cursor: 'not-allowed',
139
+ }
140
+ });
141
+
142
+ export const label = style({
143
+ fontVariationSettings: `"wght" ${fonts.INTER.wghts[500]}`,
144
+ display: 'inline-block',
145
+ fontSize: themeVars.fontSize.base,
146
+ wordBreak: 'break-word',
147
+ cursor: 'pointer',
148
+ marginBottom: themeVars.space[1],
149
+ });
150
+
151
+ export const description = style({
152
+ display: 'block',
153
+ textDecoration: 'none',
154
+ fontSize: themeVars.fontSize.base,
155
+ color: themeVars.color.gray[600],
156
+ lineHeight: themeVars.fontSize.large,
157
+ wordBreak: 'break-word',
158
+ marginBottom: themeVars.space[1.5],
159
+ });
160
+
161
+ export const errorMessage = style({
162
+ display: 'block',
163
+ textDecoration: 'none',
164
+ fontSize: themeVars.fontSize.base,
165
+ color: themeVars.color.red[600],
166
+ wordBreak: 'break-word',
167
+ marginTop: themeVars.space[1.5],
168
+ });
169
+
170
+ export const error = style({
171
+ vars: {
172
+ [vars.borderColor]: themeVars.color.red[500],
173
+ },
174
+ ':hover': {
175
+ vars: {
176
+ [vars.borderColor]: themeVars.color.red[500],
177
+ }
178
+ },
179
+ ':focus': {
180
+ boxShadow: `0 0 0 2px ${themeVars.color.red[200]}`,
181
+ vars: {
182
+ [vars.borderColor]: themeVars.color.red[500],
183
+ }
184
+ },
185
+ });
186
+
187
+ export const leftIcon = style({
188
+ pointerEvents: 'none',
189
+ position: 'absolute',
190
+ zIndex: 1,
191
+ left: 0,
192
+ top: 0,
193
+ bottom: 0,
194
+ display: 'flex',
195
+ alignItems: 'center',
196
+ justifyContent: 'center',
197
+ width: "2.25rem",
198
+ color: themeVars.color.gray[400],
199
+ });
200
+
201
+ export const hasLeftIcon = style({
202
+ paddingLeft: "2.25rem",
203
+ });
204
+
205
+ export const rightIcon = style({
206
+ pointerEvents: 'none',
207
+ position: 'absolute',
208
+ zIndex: 1,
209
+ right: 0,
210
+ top: 0,
211
+ bottom: 0,
212
+ display: 'flex',
213
+ alignItems: 'center',
214
+ justifyContent: 'center',
215
+ width: "2.25rem",
216
+ color: themeVars.color.gray[400],
217
+ });
218
+
219
+ export const hasRightIcon = style({
220
+ paddingRight: "2.25rem",
221
+ });
@@ -0,0 +1 @@
1
+ export * from './Input.css';
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  createStory,
9
9
  colorArgType
10
- } from "@/__storybook__";
10
+ } from "../../../__storybook__";
11
11
 
12
12
  export default {
13
13
  component: MLink,
@@ -1,8 +1,29 @@
1
1
  <template>
2
- <div
3
- v-if="show"
4
- class="m-message__wrapper"
5
- >
2
+ <div v-if="show" :class="classes">
3
+ <span :class="iconClasses">
4
+ <svg v-if="variant == 'info'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
5
+ <path fill-rule="evenodd"
6
+ d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z"
7
+ clip-rule="evenodd" />
8
+ </svg>
9
+
10
+ <svg v-else-if="variant == 'success'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
11
+ <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" />
12
+ </svg>
13
+
14
+ <svg v-else-if="variant == 'warning'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
15
+ <path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
16
+ </svg>
17
+
18
+ <svg v-else-if="variant == 'error'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
19
+ <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
20
+ </svg>
21
+
22
+ <svg v-else-if="variant == 'loading'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
23
+ <path fill-rule="evenodd" d="M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z" clip-rule="evenodd" />
24
+ </svg>
25
+ </span>
26
+
6
27
  <div class="m-message">
7
28
  {{ content }}
8
29
  </div>
@@ -10,8 +31,11 @@
10
31
  </template>
11
32
 
12
33
  <script lang="ts">
13
- import { defineComponent, onMounted, ref } from 'vue';
34
+ import { defineComponent, onMounted, ref, computed, watch } from 'vue';
14
35
  import type { PropType } from 'vue';
36
+ import * as style from './style';
37
+
38
+ type Variant = 'info' | 'success' | 'warning' | 'error' | 'default' | 'loading'
15
39
 
16
40
  export default defineComponent({
17
41
  name: 'MMessage',
@@ -28,6 +52,10 @@ export default defineComponent({
28
52
  type: String,
29
53
  default: 'default'
30
54
  },
55
+ variant: {
56
+ type: String as PropType<Variant>,
57
+ default: 'default'
58
+ },
31
59
  timeout: {
32
60
  type: Number,
33
61
  default: 10000
@@ -67,9 +95,28 @@ export default defineComponent({
67
95
  }
68
96
  }
69
97
 
98
+ const classes = computed(() => {
99
+ return [
100
+ style.base,
101
+ [style.variant[props.variant]]
102
+ ]
103
+ })
104
+
105
+ const iconClasses = computed(() => {
106
+ return [
107
+ style.icon
108
+ ]
109
+ })
110
+
111
+ watch(() => props.timeout, () => {
112
+ setHideTimeout();
113
+ })
114
+
70
115
  return {
71
116
  show: showRef,
72
117
  hide,
118
+ classes,
119
+ iconClasses
73
120
  }
74
121
  }
75
122
  })
@@ -21,16 +21,3 @@
21
21
  display: flex;
22
22
  align-items: center;
23
23
  }
24
-
25
- .m-message {
26
- box-sizing: border-box;
27
- display: flex;
28
- align-items: center;
29
- padding: 10px 20px;
30
- border-radius: 3px;
31
- flex-wrap: nowrap;
32
- max-width: 720px;
33
- color: var(--gray-700);
34
- background-color: var(--white);
35
- box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
36
- }
@@ -2,13 +2,11 @@
2
2
  <slot />
3
3
  <template v-if="messageList.length">
4
4
  <Teleport :to="teleportTo ?? 'body'">
5
- <div :class="[
6
- `m-message-provider__container`,
7
- `m-message-provider__container--${placement}`
8
- ]">
5
+ <div :class="classes">
9
6
  <MMessage v-for="message in messageList"
10
7
  :key="message.key"
11
8
  :internalKey="message.key"
9
+ :variant="message.type"
12
10
  :content="message.content"
13
11
  :timeout="message.timeout ?? timeout"
14
12
  ref="messageRefs"
@@ -25,12 +23,14 @@ import {
25
23
  reactive,
26
24
  Teleport,
27
25
  defineComponent,
28
- provide
26
+ provide,
27
+ computed
29
28
  } from 'vue';
30
- import type { MessageType, MessageReactive, MessageOptions, MessageApiInjection, ContentType } from './types';
29
+ import type { MessageType, MessageReactive, MessageOptions, MessageApiInjection, ContentType, MessagePlacement } from './types';
31
30
  import type { PropType } from 'vue';
32
31
  import MMessage from './Message.vue';
33
32
  import { useCachedUid } from '../../composables/useCachedUid';
33
+ import * as style from './style';
34
34
 
35
35
  export type MessageProviderInst = MessageApiInjection;
36
36
 
@@ -54,14 +54,7 @@ export default defineComponent({
54
54
  default: 'body'
55
55
  },
56
56
  placement: {
57
- type: String as PropType<
58
- | 'top'
59
- | 'top-left'
60
- | 'top-right'
61
- | 'bottom'
62
- | 'bottom-left'
63
- | 'bottom-right'
64
- >,
57
+ type: String as PropType<MessagePlacement>,
65
58
  default: 'top'
66
59
  },
67
60
  timeout: {
@@ -129,13 +122,22 @@ export default defineComponent({
129
122
  delete messageRefs.value[key];
130
123
  }
131
124
 
125
+ const classes = computed(() => {
126
+ return [
127
+ style.wrapper,
128
+ // @ts-ignore
129
+ [style.placement[props.placement]]
130
+ ]
131
+ });
132
+
132
133
  return Object.assign(
133
134
  {
134
135
  messageRefs,
135
136
  messageList: messageListRef,
136
- onInternalAfterLeave
137
+ onInternalAfterLeave,
138
+ classes
137
139
  },
138
- api
140
+ api,
139
141
  )
140
142
  }
141
143
  });