@teammodlr/ui-kit 2.0.6 → 2.0.8

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 (31) hide show
  1. package/lib/components/index.d.ts +1 -0
  2. package/lib/components/pagination/Pagination.vue.d.ts +75 -0
  3. package/lib/components/pagination/style/Pagination.css.d.ts +10 -0
  4. package/lib/components/pagination/style/index.d.ts +1 -0
  5. package/lib/components/table/TableHead.vue.d.ts +11 -1
  6. package/lib/components/tooltip/Tooltip.vue.d.ts +2 -0
  7. package/lib/components/tooltip/style/Tooltip.css.d.ts +4 -0
  8. package/lib/composables/usePopperV2.d.ts +231 -0
  9. package/lib/index.cjs.js +4 -4
  10. package/lib/index.es.js +2268 -2034
  11. package/lib/style.css +1 -1
  12. package/package.json +11 -11
  13. package/src/components/form/Form.vue +1 -0
  14. package/src/components/index.ts +1 -0
  15. package/src/components/pagination/Pagination.vue +230 -0
  16. package/src/components/pagination/examples/basic.vue +18 -0
  17. package/src/components/pagination/examples/index.stories.ts +15 -0
  18. package/src/components/pagination/examples/index.ts +1 -0
  19. package/src/components/pagination/style/Pagination.css.ts +88 -0
  20. package/src/components/pagination/style/index.ts +1 -0
  21. package/src/components/table/TableHead.vue +26 -2
  22. package/src/components/table/examples/empty.vue +1 -1
  23. package/src/components/tooltip/Tooltip.vue +7 -5
  24. package/src/components/tooltip/examples/index.stories.ts +2 -1
  25. package/src/components/tooltip/examples/index.ts +1 -0
  26. package/src/components/tooltip/examples/placement.vue +9 -0
  27. package/src/components/tooltip/style/Tooltip.css.ts +44 -1
  28. package/src/composables/usePopper.ts +1 -1
  29. package/src/composables/usePopperV2.ts +89 -0
  30. package/src/types/popper.d.ts +14 -0
  31. package/src/components/table/Table.css +0 -45
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <span
3
3
  v-bind="$attrs"
4
+ style="display: inline-flex"
4
5
  @mouseenter="() => { isOpen = true }"
5
6
  @mouseleave="() => { isOpen = false }"
6
7
  ref="wrapper"
@@ -69,13 +70,13 @@ export default defineComponent({
69
70
  const offset = computed(() => {
70
71
  switch(placement.value) {
71
72
  case 'top':
72
- return [0, 8];
73
+ return [8, 0];
73
74
  case 'bottom':
74
- return [0, -8];
75
+ return [-8, 0];
75
76
  case 'left':
76
- return [8, 0];
77
+ return [0, 8];
77
78
  case 'right':
78
- return [-8, 0];
79
+ return [0, 8];
79
80
  }
80
81
  });
81
82
 
@@ -109,7 +110,8 @@ export default defineComponent({
109
110
  transferTo,
110
111
  isOpen,
111
112
  computedClasses,
112
- zIndex
113
+ zIndex,
114
+ style
113
115
  }
114
116
  }
115
117
  })
@@ -1,7 +1,7 @@
1
1
  import MTooltip from "../Tooltip.vue";
2
2
  import MButton from "@/components/button/Button.vue";
3
3
  import {
4
- MTooltipBasic
4
+ MTooltipBasic, MTooltipPlacement
5
5
  } from "./index";
6
6
 
7
7
  import {
@@ -19,3 +19,4 @@ export default {
19
19
  }
20
20
 
21
21
  export const Basic = createStory(MTooltipBasic);
22
+ export const Placement = createStory(MTooltipPlacement);
@@ -1 +1,2 @@
1
1
  export { default as MTooltipBasic } from "./basic.vue";
2
+ export { default as MTooltipPlacement } from "./placement.vue";
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <div style="padding: 200px;">
3
+ <MTooltip text="Hello World" placement="top">
4
+ <div style="width: 100px; height: 50px; background: red;">
5
+
6
+ </div>
7
+ </MTooltip>
8
+ </div>
9
+ </template>
@@ -1,4 +1,4 @@
1
- import {createVar, style} from '@vanilla-extract/css';
1
+ import {createVar, globalKeyframes, style} from '@vanilla-extract/css';
2
2
  import { themeVars } from "../../../styles/theme.css";
3
3
 
4
4
 
@@ -7,6 +7,15 @@ export const vars = {
7
7
  color: createVar(),
8
8
  }
9
9
 
10
+ export const wrapper = style({
11
+ position: 'relative',
12
+ display: 'inline-flex'
13
+ });
14
+
15
+ export const container = style({
16
+ zIndex: 50,
17
+ });
18
+
10
19
  export const tooltip = style({
11
20
  vars: {
12
21
  [vars.backgroundColor]: themeVars.color.gray[900],
@@ -14,6 +23,7 @@ export const tooltip = style({
14
23
  },
15
24
  zIndex: 50,
16
25
  transition: 'opacity 0.3s, ease',
26
+ position: 'fixed',
17
27
  fontSize: "13px",
18
28
  fontWeight: 'normal',
19
29
  color: vars.color,
@@ -46,3 +56,36 @@ export const reverse = style({
46
56
  [vars.color]: themeVars.color.gray[900],
47
57
  }
48
58
  });
59
+
60
+ const fadeOutAnimation = "fade-out-animation";
61
+ globalKeyframes(fadeOutAnimation, {
62
+ 'from': {
63
+ opacity: 1,
64
+ },
65
+ 'to': {
66
+ opacity: 0,
67
+ }
68
+ });
69
+
70
+ const fadeInAnimation = "fade-in-animation";
71
+ globalKeyframes(fadeInAnimation, {
72
+ '0%': {
73
+ opacity: 0,
74
+ },
75
+ '100%': {
76
+ opacity: 1,
77
+ }
78
+ });
79
+
80
+ export const fadeEnter = style({
81
+ animationName: fadeInAnimation,
82
+ animationDuration: '0.125s',
83
+ animationTimingFunction: 'ease-in-out',
84
+ transition: themeVars.transition.default,
85
+ })
86
+
87
+ export const fadeLeave = style({
88
+ animationName: fadeOutAnimation,
89
+ animationDuration: '0.2s',
90
+ animationTimingFunction: 'ease-in-out',
91
+ })
@@ -80,7 +80,7 @@ export function usePopper(initialOptions: UsePopperOptions) {
80
80
  phase: 'afterWrite',
81
81
  fn({ state }) {
82
82
  const origin = setPopperDropOrigin(state.placement);
83
-
83
+
84
84
  if (origin) {
85
85
  state.elements.popper.style.transformOrigin = origin;
86
86
  }
@@ -0,0 +1,89 @@
1
+ import { ref, onMounted, watchEffect, unref } from 'vue'
2
+ import type { Ref } from 'vue'
3
+ import { popperGenerator, defaultModifiers } from '@popperjs/core/lib/popper-lite'
4
+ import type { Instance, VirtualElement } from '@popperjs/core'
5
+ import flip from '@popperjs/core/lib/modifiers/flip'
6
+ import offset from '@popperjs/core/lib/modifiers/offset'
7
+ import preventOverflow from '@popperjs/core/lib/modifiers/preventOverflow'
8
+ import computeStyles from '@popperjs/core/lib/modifiers/computeStyles'
9
+ import eventListeners from '@popperjs/core/lib/modifiers/eventListeners'
10
+ import type { PopperOptions } from 'src/types/popper'
11
+ import { unrefElement } from '@vueuse/core'
12
+ import type { MaybeElement } from '@vueuse/core'
13
+
14
+ export const createPopper = popperGenerator({
15
+ defaultModifiers: [
16
+ ...defaultModifiers,
17
+ offset,
18
+ flip,
19
+ preventOverflow,
20
+ computeStyles,
21
+ eventListeners
22
+ ]
23
+ })
24
+
25
+ export function usePopper ({
26
+ locked = false,
27
+ overflowPadding = 8,
28
+ offsetDistance = 8,
29
+ offsetSkid = 0,
30
+ gpuAcceleration = true,
31
+ adaptive = true,
32
+ scroll = true,
33
+ resize = true,
34
+ placement,
35
+ strategy
36
+ }: PopperOptions, virtualReference?: Ref<Element | VirtualElement>) {
37
+ const reference = ref<MaybeElement>(null)
38
+ const popper = ref<MaybeElement>(null)
39
+ const instance = ref<Instance | null>(null)
40
+
41
+ onMounted(() => {
42
+ watchEffect((onInvalidate) => {
43
+ if (!popper.value) { return }
44
+ if (!reference.value && !virtualReference?.value) { return }
45
+
46
+ const popperEl = unrefElement(popper)
47
+ const referenceEl = virtualReference?.value || unrefElement(reference)
48
+
49
+ // if (!(referenceEl instanceof HTMLElement)) { return }
50
+ if (!(popperEl instanceof HTMLElement)) { return }
51
+ if (!referenceEl) { return }
52
+
53
+ instance.value = createPopper(referenceEl, popperEl, {
54
+ placement,
55
+ strategy,
56
+ modifiers: [{
57
+ name: 'flip',
58
+ enabled: !locked
59
+ }, {
60
+ name: 'preventOverflow',
61
+ options: {
62
+ padding: overflowPadding
63
+ }
64
+ }, {
65
+ name: 'offset',
66
+ options: {
67
+ offset: [offsetSkid, offsetDistance]
68
+ }
69
+ }, {
70
+ name: 'computeStyles',
71
+ options: {
72
+ adaptive,
73
+ gpuAcceleration
74
+ }
75
+ }, {
76
+ name: 'eventListeners',
77
+ options: {
78
+ scroll,
79
+ resize
80
+ }
81
+ }]
82
+ })
83
+
84
+ onInvalidate(instance.value.destroy)
85
+ })
86
+ })
87
+
88
+ return [reference, popper, instance] as const
89
+ }
@@ -0,0 +1,14 @@
1
+ import type { Placement, PositioningStrategy } from '@popperjs/core'
2
+
3
+ export interface PopperOptions {
4
+ locked?: boolean
5
+ overflowPadding?: number
6
+ offsetDistance?: number
7
+ offsetSkid?: number
8
+ placement?: Placement
9
+ strategy?: PositioningStrategy
10
+ gpuAcceleration?: boolean
11
+ adaptive?: boolean
12
+ scroll?: boolean
13
+ resize?: boolean
14
+ }
@@ -1,45 +0,0 @@
1
- .m-table__wrapper {
2
- width: 100%;
3
- overflow-x: auto;
4
- }
5
-
6
- .m-table {
7
- --table-cell-padding: 10px 15px;
8
- border-collapse: collapse;
9
- width: 100%;
10
- }
11
-
12
- .m-table thead tr {
13
-
14
- }
15
-
16
- .m-table thead tr th {
17
- padding: var(--table-cell-padding);
18
- text-align: left;
19
- font-weight: 500;
20
- background-color: var(--gray-150);
21
- white-space: nowrap;
22
- color: var(--gray-700);
23
- font-size: 14px;
24
- line-height: 15px;
25
- }
26
-
27
- .m-table tbody tr:first-child td {
28
- border-top: none;
29
- }
30
-
31
- .m-table tbody tr td {
32
- padding: var(--table-cell-padding);
33
- border-top: 1px solid var(--gray-150);
34
- font-size: 15px;
35
- line-height: 15px;
36
- vertical-align: middle;
37
- }
38
-
39
- .m-table.m-table--striped tbody tr:nth-child(even) td {
40
- background-color: var(--gray-50);
41
- }
42
-
43
- .m-table.m-table--hover tbody tr:hover td {
44
- background-color: var(--gray-50);
45
- }