@teammodlr/ui-kit 2.1.4 → 2.1.6

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 (64) hide show
  1. package/lib/call.d.ts +7 -0
  2. package/lib/components/confirm/Confirm.vue.d.ts +46 -0
  3. package/lib/components/{dialog/DialogProvider.vue.d.ts → confirm/ConfirmProvider.vue.d.ts} +5 -5
  4. package/lib/components/{dialog → confirm}/props.d.ts +2 -2
  5. package/lib/components/confirm/types.d.ts +27 -0
  6. package/lib/components/confirm/useConfirm.d.ts +2 -0
  7. package/lib/components/dialog/Dialog.vue.d.ts +90 -41
  8. package/lib/components/dialog/style/Dialog.css.d.ts +11 -0
  9. package/lib/components/dialog/style/index.d.ts +1 -0
  10. package/lib/components/dialog/types.d.ts +0 -27
  11. package/lib/components/index.d.ts +3 -1
  12. package/lib/components/select/Select.vue.d.ts +21 -1
  13. package/lib/components/select/style/Select.css.d.ts +6 -0
  14. package/lib/components/tree/Tree.vue.d.ts +103 -0
  15. package/lib/components/tree/TreeNode.vue.d.ts +18 -0
  16. package/lib/components/tree/props.d.ts +70 -0
  17. package/lib/components/tree/types.d.ts +53 -0
  18. package/lib/composables/index.d.ts +1 -1
  19. package/lib/composables/useMergedState.d.ts +2 -0
  20. package/lib/index.cjs.js +18 -2
  21. package/lib/index.es.js +4706 -2754
  22. package/lib/style.css +1 -1
  23. package/lib/styles/theme.css.d.ts +7 -1
  24. package/lib/utils/injection.d.ts +2 -0
  25. package/package.json +6 -4
  26. package/src/call.ts +34 -0
  27. package/src/components/confirm/Confirm.vue +60 -0
  28. package/src/components/{dialog/DialogProvider.vue → confirm/ConfirmProvider.vue} +18 -18
  29. package/src/components/confirm/examples/basic.vue +48 -0
  30. package/src/components/confirm/examples/index.stories.ts +29 -0
  31. package/src/components/confirm/examples/index.ts +1 -0
  32. package/src/components/{dialog → confirm}/props.ts +2 -2
  33. package/src/components/confirm/types.ts +34 -0
  34. package/src/components/confirm/useConfirm.ts +12 -0
  35. package/src/components/dialog/Dialog.vue +102 -44
  36. package/src/components/dialog/examples/basic.vue +8 -40
  37. package/src/components/dialog/examples/index.stories.ts +11 -22
  38. package/src/components/dialog/examples/index.ts +1 -1
  39. package/src/components/dialog/style/Dialog.css.ts +99 -0
  40. package/src/components/dialog/style/index.ts +1 -0
  41. package/src/components/dialog/types.ts +0 -34
  42. package/src/components/index.ts +3 -1
  43. package/src/components/select/Select.vue +100 -34
  44. package/src/components/select/examples/multiple.vue +1 -1
  45. package/src/components/select/style/Select.css.ts +91 -11
  46. package/src/components/tag/style/Tag.css.ts +0 -1
  47. package/src/components/tree/Tree.vue +126 -0
  48. package/src/components/tree/TreeNode.vue +71 -0
  49. package/src/components/tree/examples/basic.vue +33 -0
  50. package/src/components/tree/examples/index.stories.ts +16 -0
  51. package/src/components/tree/examples/index.ts +1 -0
  52. package/src/components/tree/props.ts +87 -0
  53. package/src/components/tree/types.ts +96 -0
  54. package/src/composables/index.ts +1 -1
  55. package/src/composables/useMergedState.ts +18 -0
  56. package/src/styles/theme.css.ts +3 -1
  57. package/src/utils/injection.ts +5 -0
  58. package/lib/components/dialog/useDialog.d.ts +0 -2
  59. package/lib/styles/typography.css.d.ts +0 -22
  60. package/src/components/dialog/useDialog.ts +0 -12
  61. package/src/styles/typography.css.ts +0 -91
  62. /package/lib/components/{dialog → confirm}/providerProps.d.ts +0 -0
  63. /package/src/components/{dialog → confirm}/examples/wrapper.vue +0 -0
  64. /package/src/components/{dialog → confirm}/providerProps.ts +0 -0
@@ -1,60 +1,118 @@
1
1
  <template>
2
- <div>
3
- <MModal ref="modal" :title="title" :canClickOutside="false" :onClose="onClose">
4
- <template #body>
5
- {{ content }}
6
- </template>
7
-
8
- <template #footer>
9
- <div style="display: flex; flex-grow: 1; justify-content: end;">
10
- <MButton :variant="okVariant" @click="handleOk">
11
- {{ okText ?? 'Okay' }}
12
- </MButton>
13
- <MButton style="margin-left: 8px;" @click="handleCancel">
14
- {{ cancelText ?? 'Cancel' }}
15
- </MButton>
2
+ <Teleport to="body">
3
+ <div :class="style.root">
4
+ <div :class="backdropClasses">
16
5
  </div>
17
- </template>
18
- </MModal>
19
- </div>
20
- </template>
6
+ <div ref="wrapper" :class="style.wrapper">
7
+ <div ref="dialog" :class="style.dialog" :style="{
8
+ // top: y + 'px',
9
+ // left: x + 'px',
10
+ zIndex: zIndex,
11
+ width: width
12
+ }">
13
+ <div tabindex="0" aria-hidden="true" style="width: 0px; height: 0px; overflow: hidden; outline: none;"></div>
14
+ <div :class="style.content">
15
+ <button role="button" :class="style.close">x</button>
16
+ <div :class="style.header" ref="handle">
17
+ <div :class="style.title">
18
+ <slot name="title">
19
+ Title
20
+ </slot>
21
+ </div>
22
+ </div>
23
+ <div>
24
+ <slot></slot>
25
+ </div>
26
+ <div :class="style.footer">
27
+ <slot name="footer"></slot>
28
+ </div>
29
+ </div>
30
+ <div tabindex="0" aria-hidden="true" style="width: 0px; height: 0px; overflow: hidden; outline: none;"></div>
31
+ </div>
32
+ </div>
33
+ </div>
21
34
 
35
+ </Teleport>
36
+ </template>
22
37
  <script lang="ts">
23
- import { defineComponent, onMounted, ref } from 'vue';
24
- import { useZIndex } from '../../composables/useZIndex';
25
- import { dialogProps } from './props';
26
- import MModal from '../modal/Modal.vue';
38
+ import {computed, defineComponent, type PropType, ref} from "vue";
39
+ import {useZIndex} from "../../composables/useZIndex";
40
+ import {useDraggable} from "@vueuse/core";
41
+ import * as style from "./style";
27
42
 
28
43
  export default defineComponent({
29
44
  name: "Dialog",
30
- props: dialogProps,
31
- setup(props, { slots }) {
32
- const modal = ref();
33
-
34
- const { nextZIndex } = useZIndex();
35
-
36
- async function handleCancel(event: MouseEvent) {
37
- modal.value?.close();
38
- if (props.onCancel) {
39
- await props.onCancel(event)
45
+ props: {
46
+ title: {
47
+ type: String,
48
+ default: ""
49
+ },
50
+ draggable: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ backdrop: {
55
+ type: Boolean,
56
+ default: false,
57
+ },
58
+ onClose: {
59
+ type: Function as PropType<() => void>,
60
+ default: () => {
40
61
  }
62
+ },
63
+ zIndex: {
64
+ type: Number
65
+ },
66
+ width: {
67
+ type: [Number, String],
68
+ default: "500px"
69
+ },
70
+ transformOrigin: {
71
+ type: String as PropType<'center' | 'mouse'>,
72
+ default: 'mouse'
73
+ },
74
+ focusTrap: {
75
+ type: Boolean,
76
+ default: true
41
77
  }
78
+ },
79
+ emits: ['onOpen', 'onClose'],
80
+ setup(props, {slots}) {
81
+ const wrapper = ref<HTMLElement | null>(null);
82
+ const dialog = ref<HTMLElement | null>(null);
83
+ const handle = ref<HTMLElement | null>(null);
84
+ const {x, y} = useDraggable(dialog, {
85
+ handle: handle,
86
+ preventDefault: true,
87
+ // containerElement: wrapper,
88
+ });
89
+ const {nextZIndex} = useZIndex();
42
90
 
43
- async function handleOk(event: MouseEvent) {
44
- modal.value?.close();
45
- if (props.onOk) {
46
- props.onOk(event)
91
+ const backdropClasses = computed(() => {
92
+ return {
93
+ [style.backdrop]: true,
94
+ [style.backdropColor]: props.backdrop === true
47
95
  }
48
- }
49
- onMounted(() => {
50
- modal.value?.open(null);
51
96
  });
97
+
98
+ const width = computed(() => {
99
+ return typeof props.width === "number" ? props.width + "px" : props.width;
100
+ });
101
+
102
+ const zIndex = ref(props.zIndex ?? nextZIndex());
52
103
  return {
53
- modal,
54
- handleOk,
55
- handleCancel
104
+ slots,
105
+ wrapper,
106
+ dialog,
107
+ handle,
108
+ zIndex,
109
+ width,
110
+ x,
111
+ y,
112
+ style,
113
+ backdropClasses,
114
+ nextZIndex
56
115
  };
57
- },
58
- components: { MModal }
116
+ }
59
117
  });
60
118
  </script>
@@ -1,48 +1,16 @@
1
1
  <template>
2
2
  <div>
3
- <button @click="showBasicDialog">
4
- Show Basic</button>
5
-
6
- <button @click="showDangerDialog">
7
- Show Danger
8
- </button>
3
+ <MDialog>
4
+ <input type="text" />
5
+ <input type="text" />
6
+ <template #footer>
7
+ Bootom
8
+ </template>
9
+ </MDialog>
9
10
  </div>
10
11
  </template>
11
12
 
12
13
  <script lang="ts" setup>
13
- import { ref } from 'vue';
14
- import { useDialog } from '../useDialog';
15
-
16
- const dialog = useDialog();
17
-
18
- async function showBasicDialog() {
19
- const result = dialog.create({
20
- title: 'Hello World',
21
- content: 'This is a dialog',
22
- okText: 'OK',
23
- cancelText: 'Cancel',
24
- onOk: () => {
25
- console.log('OK');
26
- },
27
- onCancel: () => {
28
- console.log('Cancel');
29
- }
30
- });
31
- }
14
+ import { ref } from 'vue'
32
15
 
33
- async function showDangerDialog() {
34
- const result = dialog.create({
35
- title: 'Hello World',
36
- content: 'This is a dialog',
37
- okText: 'Continue',
38
- okVariant: 'error',
39
- cancelText: 'Cancel',
40
- onOk: () => {
41
- showBasicDialog()
42
- },
43
- onCancel: () => {
44
- console.log('Cancel');
45
- }
46
- });
47
- }
48
16
  </script>
@@ -1,29 +1,18 @@
1
- import MDialogProvider from "../DialogProvider.vue";
1
+ import MDialog from "../Dialog.vue";
2
2
  import {
3
- MDialogProviderBasic,
3
+ MDialogBasic
4
4
  } from "./index";
5
5
 
6
- const Template = (args: any) => ({
7
- components: {
8
- MDialogProvider,
9
- MDialogProviderBasic
10
- },
11
- setup() {
12
-
13
- return {
14
- args,
15
- };
16
- },
17
- template: `
18
- <m-dialog-provider v-bind="args">
19
- <MDialogProviderBasic />
20
- </m-dialog-provider>
21
- `
22
- })
6
+ import {
7
+ createStory, sizeArgType
8
+ } from "../../../__storybook__";
23
9
 
24
10
  export default {
25
- component: MDialogProvider,
26
- title: 'Components/Dialog'
11
+ component: MDialog,
12
+ title: 'Components/Dialog',
13
+ argTypes: {
14
+ ...sizeArgType(),
15
+ }
27
16
  }
28
17
 
29
- export const Primary = Template.bind({});
18
+ export const Basic = createStory(MDialogBasic);
@@ -1 +1 @@
1
- export { default as MDialogProviderBasic } from './basic.vue';
1
+ export { default as MDialogBasic } from './basic.vue';
@@ -0,0 +1,99 @@
1
+ import {createVar, globalKeyframes, style, styleVariants} from "@vanilla-extract/css";
2
+ import {themeVars} from "../../../styles/theme.css";
3
+
4
+ export const vars = {
5
+
6
+ }
7
+
8
+ export const root = style({
9
+
10
+ });
11
+ export const backdrop = style({
12
+ position: "fixed",
13
+ inset: 0,
14
+ top: 0,
15
+ bottom: 0,
16
+ left: 0,
17
+ right: 0,
18
+ display: "flex",
19
+ justifyContent: "center",
20
+ alignItems: "center",
21
+ pointerEvents: "none",
22
+ });
23
+
24
+ export const backdropColor = style({
25
+ backgroundColor: 'rgba(0,0,0,.45)',
26
+ });
27
+
28
+ export const wrapper = style({
29
+ position: "fixed",
30
+ inset: 0,
31
+ top: 0,
32
+ left: 0,
33
+ right: 0,
34
+ bottom: 0,
35
+ outline: 0,
36
+ overflow: "auto",
37
+ boxSizing: "border-box",
38
+ });
39
+
40
+ export const dialog = style({
41
+ boxSizing: "border-box",
42
+ margin: "0 auto",
43
+ padding: 0,
44
+ position: "relative",
45
+ top: "100px",
46
+ width: "auto",
47
+ maxWidth: `calc(100vw - 32px)`,
48
+ paddingBottom: "24px",
49
+ });
50
+
51
+ export const content = style({
52
+ position: "relative",
53
+ backgroundColor: "#FFF",
54
+ backgroundClip: "padding-box",
55
+ border: 0,
56
+ borderRadius: themeVars.rounded.default,
57
+ pointerEvents: "auto",
58
+ padding: `20px 24px`,
59
+ boxShadow: `0 6px 16px 0 rgba(0,0,0,.08), 0 3px 6px -4px rgba(0,0,0,.12), 0 9px 28px 8px rgba(0,0,0,.05)`
60
+ })
61
+
62
+ export const header = style({
63
+ color: themeVars.color.font.default,
64
+ backgroundColor: "#FFF",
65
+ marginBottom: themeVars.space[2],
66
+ });
67
+
68
+ export const footer = style({
69
+ textAlign: "end",
70
+ background: `0 0`,
71
+ marginTop: themeVars.space[2],
72
+ })
73
+
74
+ export const title = style({
75
+ margin: 0,
76
+ color: themeVars.color.font.default,
77
+ fontWeight: 600,
78
+ lineHeight: 1.5,
79
+ wordWrap: "break-word",
80
+ });
81
+
82
+ export const close = style({
83
+ position: "absolute",
84
+ top: `17px`,
85
+ insetInlineEnd: `17px`,
86
+ padding: 0,
87
+ background: `0 0`,
88
+ borderRadius: themeVars.rounded.small,
89
+ width: `22px`,
90
+ height: `22px`,
91
+ border: 0,
92
+ outline: 0,
93
+ cursor: `pointer`,
94
+ selectors: {
95
+ '&:hover': {
96
+ backgroundColor: `hsla(0,0%,45.1%,0.1)`,
97
+ }
98
+ }
99
+ })
@@ -0,0 +1 @@
1
+ export * from './Dialog.css';
@@ -1,34 +0,0 @@
1
- import type { Variant } from '../../types/props';
2
- import type { VNodeChild } from 'vue';
3
-
4
- export type DialogContentType = string;
5
-
6
- export type DialogContentRender = (props: any) => VNodeChild;
7
-
8
- export interface DialogOptions {
9
- title?: string,
10
- render?: DialogContentRender,
11
- content: DialogContentType,
12
- onClose?: () => void,
13
- onOpen?: () => void,
14
- onOk?: () => void,
15
- onCancel?: () => void,
16
- okVariant?: Variant,
17
- okText?: DialogContentType,
18
- cancelText?: DialogContentType,
19
- }
20
-
21
- export interface DialogResponse {
22
- result: boolean,
23
- data: any
24
- }
25
-
26
- export interface DialogApiInjection {
27
- create: (options: DialogOptions) => Dialog
28
- destroyAll: () => void
29
- }
30
-
31
-
32
- export interface Dialog extends DialogOptions {
33
- destroy: () => void
34
- }
@@ -40,5 +40,7 @@ export { default as MTextarea } from './textarea/Textarea.vue';
40
40
  export { default as MTooltip } from './tooltip/Tooltip.vue';
41
41
  export { default as MTransfer } from './transfer/Transfer.vue';
42
42
  export { default as MVirtualScroll } from './virtualscroll/VirtualScroll.vue';
43
+ export { default as MConfirm } from './confirm/Confirm.vue';
44
+ export { default as MConfirmProvider } from './confirm/ConfirmProvider.vue';
43
45
  export { default as MDialog } from './dialog/Dialog.vue';
44
- export { default as MDialogProvider } from './dialog/DialogProvider.vue';
46
+ export { default as MTree } from './tree/Tree.vue';