@teammodlr/ui-kit 2.1.43 → 2.1.44

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 (67) hide show
  1. package/lib/components/avatar/Avatar.vue.d.ts +1 -1
  2. package/lib/components/avatargroup/AvatarGroup.vue.d.ts +1 -1
  3. package/lib/components/badge/Badge.vue.d.ts +1 -1
  4. package/lib/components/breadcrumb/Breadcrumb.vue.d.ts +1 -1
  5. package/lib/components/breadcrumb/BreadcrumbItem.vue.d.ts +1 -1
  6. package/lib/components/button/Button.vue.d.ts +1 -1
  7. package/lib/components/buttongroup/ButtonGroup.vue.d.ts +1 -1
  8. package/lib/components/checkbox/Checkbox.vue.d.ts +3 -3
  9. package/lib/components/colorpicker/ColorPicker.vue.d.ts +1 -1
  10. package/lib/components/configprovider/ConfigProvider.vue.d.ts +35 -0
  11. package/lib/components/configprovider/types.d.ts +3 -0
  12. package/lib/components/confirm/Confirm.vue.d.ts +1 -1
  13. package/lib/components/confirm/ConfirmProvider.vue.d.ts +1 -1
  14. package/lib/components/dialog/Dialog.vue.d.ts +1 -1
  15. package/lib/components/dropdown/Dropdown.vue.d.ts +1 -1
  16. package/lib/components/dropdown/DropdownHeading.vue.d.ts +1 -1
  17. package/lib/components/dropdown/DropdownItem.vue.d.ts +1 -1
  18. package/lib/components/dropdown/DropdownList.vue.d.ts +1 -1
  19. package/lib/components/dropdown/DropdownSeperator.vue.d.ts +1 -1
  20. package/lib/components/dropdown/DropdownWrapper.vue.d.ts +1 -1
  21. package/lib/components/form/Form.vue.d.ts +1 -1
  22. package/lib/components/image/Image.vue.d.ts +1 -1
  23. package/lib/components/index.d.ts +1 -0
  24. package/lib/components/input/Input.vue.d.ts +2 -2
  25. package/lib/components/link/Link.vue.d.ts +1 -1
  26. package/lib/components/messageprovider/Message.vue.d.ts +1 -1
  27. package/lib/components/messageprovider/MessageProvider.vue.d.ts +1 -1
  28. package/lib/components/modal/Modal.vue.d.ts +1 -1
  29. package/lib/components/pagination/Pagination.vue.d.ts +1 -1
  30. package/lib/components/radio/Radio.vue.d.ts +3 -3
  31. package/lib/components/radiobutton/RadioButton.vue.d.ts +1 -1
  32. package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +1 -1
  33. package/lib/components/renderer/examlpes/basic.vue.d.ts +1 -1
  34. package/lib/components/renderer/renderer.d.ts +1 -1
  35. package/lib/components/select/Select.vue.d.ts +2 -2
  36. package/lib/components/skeleton/Skeleton.vue.d.ts +1 -1
  37. package/lib/components/slider/Slider.vue.d.ts +1 -1
  38. package/lib/components/switch/Switch.vue.d.ts +3 -3
  39. package/lib/components/tab/Tab.vue.d.ts +1 -1
  40. package/lib/components/tab/TabGroup.vue.d.ts +1 -1
  41. package/lib/components/table/Table.vue.d.ts +1 -1
  42. package/lib/components/table/TableBody.vue.d.ts +1 -1
  43. package/lib/components/table/TableCell.vue.d.ts +1 -1
  44. package/lib/components/table/TableHead.vue.d.ts +1 -1
  45. package/lib/components/table/TableHeadRow.vue.d.ts +1 -1
  46. package/lib/components/table/TableRow.vue.d.ts +1 -1
  47. package/lib/components/tag/Tag.vue.d.ts +1 -1
  48. package/lib/components/textarea/Textarea.vue.d.ts +2 -2
  49. package/lib/components/tooltip/Tooltip.vue.d.ts +1 -1
  50. package/lib/components/transfer/Transfer.vue.d.ts +1 -1
  51. package/lib/components/tree/Tree.vue.d.ts +1 -1
  52. package/lib/components/tree/TreeNode.vue.d.ts +1 -1
  53. package/lib/components/tree/TreeNodeToggle.vue.d.ts +1 -1
  54. package/lib/components/virtualscroll/VirtualScroll.vue.d.ts +1 -1
  55. package/lib/composables/useCachedUid.d.ts +1 -13
  56. package/lib/composables/useInput.d.ts +3 -3
  57. package/lib/index.cjs.js +10 -10
  58. package/lib/index.es.js +2069 -2070
  59. package/lib/styles/theme.css.d.ts +1 -1
  60. package/package.json +1 -1
  61. package/src/components/configprovider/ConfigProvider.vue +26 -0
  62. package/src/components/configprovider/types.ts +3 -0
  63. package/src/components/confirm/ConfirmProvider.vue +3 -3
  64. package/src/components/index.ts +1 -0
  65. package/src/components/messageprovider/MessageProvider.vue +1 -1
  66. package/src/composables/useCachedUid.ts +16 -48
  67. package/src/composables/useInput.ts +3 -3
@@ -33,7 +33,7 @@ export declare const fontSizeScale: {
33
33
  xlarge: string;
34
34
  xxlarge: string;
35
35
  };
36
- export declare const fontSizeVariants: Record<"base" | "small" | "large" | "xsmall" | "xlarge" | "xxlarge", string>;
36
+ export declare const fontSizeVariants: Record<"small" | "base" | "large" | "xsmall" | "xlarge" | "xxlarge", string>;
37
37
  export declare const shadows: {
38
38
  sm: string;
39
39
  md: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teammodlr/ui-kit",
3
- "version": "2.1.43",
3
+ "version": "2.1.44",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ export interface ConfigProviderProps {
3
+ useId?: () => string
4
+ }
5
+ export default {
6
+ name: 'ConfigProvider',
7
+ }
8
+ </script>
9
+
10
+ <script setup lang="ts">
11
+ import {provide} from "vue";
12
+ import type {ConfigProviderInjection} from "./types";
13
+
14
+ const props = withDefaults(defineProps<ConfigProviderProps>(), {
15
+ useId: undefined
16
+ })
17
+
18
+ const api: ConfigProviderInjection = {
19
+ useId: props['useId'],
20
+ } as const;
21
+
22
+ provide('m-config', api);
23
+ </script>
24
+ <template>
25
+ <slot />
26
+ </template>
@@ -0,0 +1,3 @@
1
+ export interface ConfigProviderInjection {
2
+ useId?: () => string;
3
+ }
@@ -20,7 +20,7 @@
20
20
 
21
21
  <script lang="ts">
22
22
  import { defineComponent, provide, ref } from 'vue';
23
- import { useCachedUid } from '../../composables/useCachedUid';
23
+ import { useId } from '../../composables/useCachedUid';
24
24
  import { providerProps } from './providerProps';
25
25
  import type { Confirm, ConfirmApiInjection, ConfirmOptions } from './types';
26
26
  import MConfirm from './Confirm.vue';
@@ -45,8 +45,8 @@ export default defineComponent({
45
45
  const dialogRefs: Record<string, PrivateConfirmRef> = {};
46
46
 
47
47
  function create(options: ConfirmOptions): Confirm {
48
- const { id } = useCachedUid('m-confirm');
49
- const key = id.value;
48
+ const id = useId(null, 'm-confirm');
49
+ const key = id;
50
50
  const dialog: PrivateConfirm = {
51
51
  ...options,
52
52
  key,
@@ -1,4 +1,5 @@
1
1
  export { default as MRenderer } from './renderer/renderer';
2
+ export { default as MConfigProvider } from './configprovider/ConfigProvider.vue';
2
3
  export { default as MAvatar } from './avatar/Avatar.vue';
3
4
  export { default as MAvatarGroup } from './avatargroup/AvatarGroup.vue';
4
5
  export { default as MBadge } from './badge/Badge.vue';
@@ -43,7 +43,7 @@ import type {
43
43
  } from './types';
44
44
  import type { PropType } from 'vue';
45
45
  import MMessage from './Message.vue';
46
- import { useCachedUid } from '../../composables/useCachedUid';
46
+ import { useId } from '../../composables/useCachedUid';
47
47
  import * as style from './style';
48
48
  import { modalScale } from '../../styles/transitions.css';
49
49
  import { useIsServer } from '../../composables/useIsServer';
@@ -1,49 +1,17 @@
1
- // https://github.com/liip/chusho/blob/main/packages/chusho/lib/composables/useCachedUid.ts#L20-L41 - Legend :D
2
- import { onMounted, readonly, ref } from 'vue';
3
- import { getElement } from './element';
4
- import type { ComponentPublicInstance, Ref } from 'vue';
5
-
6
- const UID_CACHE_ATTR = 'data-modlr-ssr-uid';
7
-
8
- // @ts-nocheck
9
- type CacheElement = HTMLElement | SVGElement | ComponentPublicInstance | null;
10
-
11
- export function uid(prefix = ''): string {
12
- const id =
13
- Date.now().toString(36) + Math.random().toString(36).substring(2);
14
- return prefix ? `${prefix}-${id}` : id;
15
- }
16
-
17
- export interface IUseCacheUid {
18
- id: Readonly<Ref<string>>;
19
- cacheAttrs: {
20
- ref: Ref<CacheElement>;
21
- [UID_CACHE_ATTR]?: string;
22
- };
23
- }
24
-
25
- export function useCachedUid(prefix?: string): IUseCacheUid {
26
- const id = ref(uid(prefix));
27
- const cacheElement = ref<CacheElement>(null);
28
-
29
- onMounted(() => {
30
- if (cacheElement.value) {
31
- const element = getElement(cacheElement);
32
- const serverId = element?.getAttribute(UID_CACHE_ATTR);
33
-
34
- if (serverId) {
35
- id.value = serverId;
36
- }
37
-
38
- element?.removeAttribute(UID_CACHE_ATTR);
39
- }
40
- });
41
-
42
- return {
43
- id: readonly(id),
44
- cacheAttrs: {
45
- ref: cacheElement,
46
- [UID_CACHE_ATTR]: typeof window === undefined ? id.value : undefined
47
- }
48
- };
1
+ import {inject} from 'vue';
2
+
3
+ let count = 0
4
+
5
+ export function useId(deterministicId?: string | null | undefined, prefix = 'ui') {
6
+ if (deterministicId) {
7
+ return deterministicId;
8
+ }
9
+ console.log(count);
10
+ const {useId} = inject('m-config', {useId: undefined});
11
+ if (useId && typeof useId === 'function') {
12
+ // @ts-ignore
13
+ return `${prefix}-${useId()}`;
14
+ }
15
+
16
+ return `${prefix}-${count++}`;
49
17
  }
@@ -1,7 +1,7 @@
1
1
  // inspired by indielayer ui
2
2
  import type { PropType } from 'vue';
3
3
  import { ref, watch, inject, computed, onMounted, onUnmounted } from 'vue';
4
- import { useCachedUid } from './useCachedUid';
4
+ import { useId } from './useCachedUid';
5
5
  import { FORM_STATE } from '../components/form/symbol';
6
6
 
7
7
  export interface FormInput {
@@ -25,8 +25,8 @@ export const useInput = (
25
25
  const isFirstValidation = ref(true);
26
26
  const formError = ref(props.error);
27
27
 
28
- const { id } = useCachedUid('input');
29
- const name = props.name ? props.name : id.value;
28
+ const id = useId(null, 'input');
29
+ const name = props.name ? props.name : id;
30
30
  const _name = ref(name);
31
31
 
32
32
  watch(